Skip to content

[Bioc-devel] Additional summarizeOverlaps counting modes for ChIP-Seq

6 messages · Ryan, Valerie Obenchain

#
Hi Valerie,

I got really busy around May and never got a chance to thank you for 
adding this option to summarizeOverlaps! So thank you!

-Ryan
On Thu 01 May 2014 04:25:33 PM PDT, Valerie Obenchain wrote:
#
Hi again,

I'm looking at the examples in the summarizeOverlaps help page here: 
http://www.bioconductor.org/packages/devel/bioc/manuals/GenomicAlignments/man/GenomicAlignments.pdf

And the examples fod preprocess.reads are a little confusing. One of 
the examples passes some additional "..." options to summarizeOverlaps, 
and implies that these will be passed along as the "..." arguments to 
the proprocess.reads function:

    summarizeOverlaps(grl, reads, mode=Union, 
preprocess.reads=ResizeReads, width=1, fix="end")

The width and fix arguments are implied to be passed through to 
ResizeReads, but I don't see it documented anywhere how this would be 
done. The summarizeOverlaps documentation for "..." says "Additional 
arguments for BAM file methods such as singleEnd, fragments or param 
that apply to the reading of records from a file (see below)." I don't 
see anything about passing through to preprocess.reads.

Incidentally, this is why my original example used a function that 
constructed a closure with these arguments already bound. I would write 
the example like this to ensure no ambiguity in argument passing (pay 
attention to parens):

    ResizeReads <- function(mode, ...) {
        resize.args <- list(...)
        function(reads) {
            reads <- as(reads, "GRanges")
            ## Need strandedness
            stopifnot(all(strand(reads) != "*"))
            do.call(resize, c(list(x=reads), resize.args))
        }
    }

    ## By default ResizeReads() counts reads that overlap on the 5 end:
    summarizeOverlaps(grl, reads, mode=Union, 
preprocess.reads=ResizeReads())

    ## Count reads that overlap on the 3 end by passing new values
    ## for width and fix:
    summarizeOverlaps(grl, reads, mode=Union, 
preprocess.reads=ResizeReads(width=1, fix="end"))

Anyway, I don't have the devel version of R handy to test this out, so 
I don't know if what I've described is a problem in practice. But I 
think that either the preprocess.reads function should be required to 
only take one argument, or else the method of passing through 
additional arguments to it should be documented.

-Ryan
On Tue 05 Aug 2014 05:12:41 PM PDT, Ryan C. Thompson wrote:
#
Hi Ryan,
On 08/05/2014 05:47 PM, Ryan C. Thompson wrote:
This is standard use of '...'. See the ?'...' and ?dotsMethods man 
pages. I've added a sentence in \arguments clarifying that '...' can 
encompass arguments called by any subsequent function/method.

The summarizeOverlaps documentation for "..." says "Additional
The 'resize.args' variable below captures all variables that exist in 
the .dispatchOverlaps() helper, many of which don't need to be passed to 
resize(). The 'preprocess.reads' function can be written this way or it 
can have default values in the signature as I've done in the man page 
example.


Valerie
#
Ok, I had a look at the code, and I think understand now. The help text 
for the "..." argument says "Additional arguments for BAM file methods 
such assingleEnd,fragmentsorparamthat apply to the reading of records 
from a file (see below)." But this is actually referring to the fixed 
set of individual arguments listed below the dots. It doesn't apply to 
the arguments that actually get matched by "..." in a call to 
summarizeOverlaps. These actually get passed straight to 
preprocess.reads. Perhaps the documentaion for "..." should be updated 
to reflect this?
On Wed Aug 6 11:21:20 2014, Valerie Obenchain wrote:
#
The man page '...' section was updated in GenomicAlignments 1.1.24 in 
devel. I've now also updated it in 1.0.5 in release.

The '...' does not refer only to the fixed set of args listed below the 
dots. The '...' encompasses any argument(s) provided to 
summarizeOverlaps() not explicitly stated in the function signature. For 
example, if you passed FOO=3, then FOO would end up in '...'.

Any function/method called inside summarizeOverlaps() with a '...' will 
pass the arguments down; they continue to be passed down until they are 
explicitly stated in a function signature (e.g., 'width' and 'fix' in 
ResizeReads()).

Valerie
On 08/06/2014 11:35 AM, Ryan wrote:
#
Yes, I understand that the "..." doesn't only refer to the fixed set of 
arguments listed below. I was saying that the *documentation* for the 
dots argument in summarizeOverlaps was actually talking about the below 
arguments instead. I don't see it documented anywhere that the dots 
arguments passed to summarizeOverlaps are passed through to 
preprocess.reads. You'd have to read the code to figure that out. I 
guess my issue is that there are a number of internal functions that 
could conceivably receive the dots arguments that are passed to 
summarizeOverlaps, and it's not obvious to me that they will ultimately 
be passed down to preprocess.reads and not some other function or 
functions.
On Wed Aug 6 11:57:10 2014, Valerie Obenchain wrote: