Hi,
I feel like this should construct a new IRanges object that is the
"stack" of all the IRanges objects in my list:
R> library(IRanges)
R> ilist <- list(a=IRanges(1, 30), b=IRanges(10,80), c=IRanges(100,
500))
R> do.call('c', ilist)
But it just returns the same list as ilist.
Shouldn't the above return the equivalent of:
R> c(l$a, l$b, l$c)
No?
R> sessionInfo()
R version 2.11.0 Patched (2010-05-05 r51909)
x86_64-apple-darwin9.8.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] IRanges_1.6.1 ARE.utils_0.1.0
loaded via a namespace (and not attached):
[1] igraph_0.5.3 tools_2.11.0
Thanks,
-steve
--
Steve Lianoglou
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact
Steve,
This outcome is due to how the S4 generic for c is defined
> args(getGeneric("c"))
function (x, ..., recursive = FALSE)
NULL
The dispatch occurs off the argument x. Since all your list elements
are
named, but none are named "x", your object uses the primitive method
> c
function (..., recursive = FALSE) .Primitive("c")
and so you get an undesired result. One solution is to unname your
list
object in the do.call step
R> do.call(c, unname(ilist))
IRanges of length 3
start end width
[1] 1 30 30
[2] 10 80 71
[3] 100 500 401
In your situation, however, I would recommend storing lists of IRanges
objects in an [Simple/Compressed]IRangesList instance. You can then
use
many IRangesList methods as well as its unlist method to get the
object
you were looking for:
R> ilist2 <- IRangesList(ilist)
R> unlist(ilist2, use.names=FALSE)
IRanges of length 3
start end width
[1] 1 30 30
[2] 10 80 71
[3] 100 500 401
R> sessionInfo()
R version 2.12.0 Under development (unstable) (2010-05-02 r51890)
i386-apple-darwin9.8.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] IRanges_1.7.1
Patrick
On 5/7/10 2:23 PM, Steve Lianoglou wrote:
> Hi,
>
> I feel like this should construct a new IRanges object that is the
> "stack" of all the IRanges objects in my list:
>
> R> library(IRanges)
> R> ilist<- list(a=IRanges(1, 30), b=IRanges(10,80), c=IRanges(100,
500))
> R> do.call('c', ilist)
>
> But it just returns the same list as ilist.
>
> Shouldn't the above return the equivalent of:
>
> R> c(l$a, l$b, l$c)
>
> No?
>
> R> sessionInfo()
> R version 2.11.0 Patched (2010-05-05 r51909)
> x86_64-apple-darwin9.8.0
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] IRanges_1.6.1 ARE.utils_0.1.0
>
> loaded via a namespace (and not attached):
> [1] igraph_0.5.3 tools_2.11.0
>
> Thanks,
> -steve
>
>
Ahhh ... I see.
Makes sense, thanks.
-steve
On Fri, May 7, 2010 at 5:46 PM, Patrick Aboyoun <paboyoun at="" fhcrc.org=""> wrote:
> Steve,
> This outcome is due to how the S4 generic for c is defined
>
>> args(getGeneric("c"))
> function (x, ..., recursive = FALSE)
> NULL
>
> The dispatch occurs off the argument x. Since all your list elements
are
> named, but none are named "x", your object uses the primitive method
>
>> c
> function (..., recursive = FALSE) ?.Primitive("c")
>
> and so you get an undesired result. One solution is to unname your
list
> object in the do.call step
>
> R> do.call(c, unname(ilist))
> IRanges of length 3
> ? ?start end width
> [1] ? ? 1 ?30 ? ?30
> [2] ? ?10 ?80 ? ?71
> [3] ? 100 500 ? 401
>
> In your situation, however, I would recommend storing lists of
IRanges
> objects in an [Simple/Compressed]IRangesList instance. You can then
use many
> IRangesList methods as well as its unlist method to get the object
you were
> looking for:
>
> R> ilist2 <- IRangesList(ilist)
> R> unlist(ilist2, use.names=FALSE)
> IRanges of length 3
> ? ?start end width
> [1] ? ? 1 ?30 ? ?30
> [2] ? ?10 ?80 ? ?71
> [3] ? 100 500 ? 401
>
> R> sessionInfo()
> R version 2.12.0 Under development (unstable) (2010-05-02 r51890)
> i386-apple-darwin9.8.0
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] stats ? ? graphics ?grDevices utils ? ? datasets ?methods ? base
>
> other attached packages:
> [1] IRanges_1.7.1
>
>
>
> Patrick
>
>
> On 5/7/10 2:23 PM, Steve Lianoglou wrote:
>>
>> Hi,
>>
>> I feel like this should construct a new IRanges object that is the
>> "stack" of all the IRanges objects in my list:
>>
>> R> ?library(IRanges)
>> R> ?ilist<- list(a=IRanges(1, 30), b=IRanges(10,80), c=IRanges(100,
500))
>> R> ?do.call('c', ilist)
>>
>> But it just returns the same list as ilist.
>>
>> Shouldn't the above return the equivalent of:
>>
>> R> ?c(l$a, l$b, l$c)
>>
>> No?
>>
>> R> ?sessionInfo()
>> R version 2.11.0 Patched (2010-05-05 r51909)
>> x86_64-apple-darwin9.8.0
>>
>> locale:
>> [1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
>>
>> attached base packages:
>> [1] stats ? ? graphics ?grDevices utils ? ? datasets ?methods ?
base
>>
>> other attached packages:
>> [1] IRanges_1.6.1 ? ARE.utils_0.1.0
>>
>> loaded via a namespace (and not attached):
>> [1] igraph_0.5.3 tools_2.11.0
>>
>> Thanks,
>> -steve
>>
>>
>
>
--
Steve Lianoglou
Graduate Student: Computational Systems Biology
| Memorial Sloan-Kettering Cancer Center
| Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact