[BioC] subsetting IntegerList by list names

Manuela Hummel Manuela.Hummel at crg.eu
Wed Nov 16 12:47:41 CET 2011


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


Thanks a lot for your comments
Manuela



> sessionInfo()

R version 2.14.0 (2011-10-31)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Spanish_Spain.1252  LC_CTYPE=Spanish_Spain.1252   
[3] LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C                  
[5] LC_TIME=Spanish_Spain.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] IRanges_1.12.1

loaded via a namespace (and not attached):
[1] tools_2.14.0




Manuela Hummel
Core Facilities - Microarrays Unit
Center for Genomic Regulation (CRG)
Dr. Aiguader 88, 4th floor, Office 439.01
08003 Barcelona
Phone: +34 93 316 0373
e-mail: manuela.hummel at crg.eu
  



More information about the Bioconductor mailing list