[BioC] subsetting IntegerList by list names

Martin Morgan mtmorgan at fhcrc.org
Wed Nov 16 18:09:39 CET 2011


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

Martin

>
>
> 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
>
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives: http://news.gmane.org/gmane.science.biology.informatics.conductor


-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793



More information about the Bioconductor mailing list