Greetings,
I haven't worked with IRanges, and I'm still getting used to the R syntax, so I'm not sure, but I think the problem is that IntegerList returns a list of a single element consisting of  (...) whereas list returns a list of however elements you gave as arguments. So depending on how you compare them you will get different answers. Here's a brief example:
> av = strsplit("atomicvector",'')
> av
[[1]]
 [1] "a" "t" "o" "m" "i" "c" "v" "e" "c" "t" "o" "r"
> class(av)
[1] "list"
> lv = unlist(strsplit("atomicvector",''))
> lv
 [1] "a" "t" "o" "m" "i" "c" "v" "e" "c" "t" "o" "r"
> all(sapply(av,identity) == sapply(lv,identity))
[1] TRUE
### so far they look the same, but
> av[1]
[[1]]
 [1] "a" "t" "o" "m" "i" "c" "v" "e" "c" "t" "o" "r"
> lv[1]
[1] "a"

they are not the same.
> lv %in% av
 [1] FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
> av %in% lv
[1] FALSE

Tom
MMI DNA Services Core Facility<http://www.ohsu.edu/xd/research/research-cores/dna-analysis/>
503-494-2442
kellert at ohsu.edu<http://ohsu.edu>
Office: 6588 RJH (CROET/BasicScience)

OHSU Shared Resources<http://www.ohsu.edu/xd/research/research-cores/index.cfm>






On Nov 16, 2011, at 9:25 AM, Steve Lianoglou wrote:

Hi,

On Wed, Nov 16, 2011 at 12:09 PM, Martin Morgan <mtmorgan@fhcrc.org<mailto:mtmorgan@fhcrc.org>> wrote:
On 11/16/2011 03:47 AM, Manuela Hummel wrote:

Hi,

I realized that subsetting an IntegerList object (and probably other
IRanges list objects) by the list names plus replacing list element values
behaves unexpectedly (at least for me) when the list is not sorted by its
element's names.

Here a short example:

IL<- IntegerList(chr2=5, chr1=10)

IL

CompressedIntegerList of length 2
[["chr2"]] 5
[["chr1"]] 10

Now I want to subset based on the list names:

chrs<- c("chr1", "chr2")

IL[chrs]

CompressedIntegerList of length 2
[["chr1"]] 10
[["chr2"]] 5

This gives me the elements in the expected order.

However, if I now want to replace the values of both elements, using the
subsetting as before, the order of the list and the new element values is
"mixed":

IL[chrs]<- list(100, 50)

IL

CompressedNumericList of length 2
[["chr2"]] 100
[["chr1"]] 50

I would have expected the value 100 for element "chr1" and 50 for element
"chr2".

In this way at least it works with usual lists:

L<- list(chr2=5, chr1=10)
L

$chr2
[1] 5

$chr1
[1] 10

L[chrs]<- list(100, 50)
L

$chr2
[1] 50

$chr1
[1] 100

Hi Manuela -- I think this is consistent with R ?

x = list(chr2=5, chr1=10)
chrs=c("chr1", "chr2")
x[chrs] = list(100, 50)
x
$chr2
[1] 50

$chr1
[1] 100

Maybe I'm missing it too, but it doesn't look like this is what the
SimpleList is doing ... it seems like SimpleList is assigning by order
and not name:

R> IL <- IntegerList(chr2=5, chr1=10)
R> L <- list(chr2=5, chr1=10)
R> all(sapply(IL, identity) == sapply(L, identity))
[1] TRUE


R> chrs <- c('chr1', 'chr2')
R> IL[chrs] <- list(100, 200)
R> L[chrs] <- list(100, 200)
R> all(sapply(IL, identity) == sapply(L, identity))
[1] FALSE

R> IL[['chr2']]
[1] 100

R> L[['chr2']]
[1] 200

Right?
I mean ... wrong? .. right?

-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

_______________________________________________
Bioconductor mailing list
Bioconductor@r-project.org<mailto:Bioconductor@r-project.org>
https://stat.ethz.ch/mailman/listinfo/bioconductor
Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor


	[[alternative HTML version deleted]]

