[Bioc-sig-seq] GenomicRanges endoapply Error

Valerie Obenchain vobencha at fhcrc.org
Tue Sep 21 01:43:06 CEST 2010


Hi Dario,
I believe this problem has been fixed in the devel branch. 
https://stat.ethz.ch/pipermail/bioc-sig-sequencing/2010-August/001494.html


Here is a run in R-2.12:

grlst1 <- GRangesList()
rs1  <-  GRanges(seqnames =
             Rle("chr1", 6),
             ranges = IRanges(1:6, width = 9),
             strand = Rle(strand("-"), 6)
)
rs2 <- GRanges(seqnames =
            Rle("chr1", 6),
            ranges = IRanges(10:15, width = 5),
            strand = Rle(strand("-"), 6)
)

# Build by element
grlst1[[1]] <- rs1
grlst1[[2]] <- rs2

seqLen <- 4
resize1 <- endoapply(grlst1, resize, seqLen)


> > resize1
>   
GRangesList of length 2
[[1]]
GRanges with 6 ranges and 0 elementMetadata values
    seqnames    ranges strand |
       <Rle> <IRanges>  <Rle> |
[1]     chr1  [ 6,  9]      - |
[2]     chr1  [ 7, 10]      - |
[3]     chr1  [ 8, 11]      - |
[4]     chr1  [ 9, 12]      - |
[5]     chr1  [10, 13]      - |
[6]     chr1  [11, 14]      - |

[[2]]
GRanges with 6 ranges and 0 elementMetadata values
    seqnames    ranges strand |
       <Rle> <IRanges>  <Rle> |
[1]     chr1  [11, 14]      - |
[2]     chr1  [12, 15]      - |
[3]     chr1  [13, 16]      - |
[4]     chr1  [14, 17]      - |
[5]     chr1  [15, 18]      - |
[6]     chr1  [16, 19]      - |


seqlengths
 chr1
   NA


# Build with constructor
grlst2 <- GRangesList("gr1"=rs1, "gr2"=rs2)
resize2 <- endoapply(grlst2, resize, seqLen)


> > resize2
>   
GRangesList of length 2
$gr1
GRanges with 6 ranges and 0 elementMetadata values
    seqnames    ranges strand |
       <Rle> <IRanges>  <Rle> |
[1]     chr1  [ 6,  9]      - |
[2]     chr1  [ 7, 10]      - |
[3]     chr1  [ 8, 11]      - |
[4]     chr1  [ 9, 12]      - |
[5]     chr1  [10, 13]      - |
[6]     chr1  [11, 14]      - |

$gr2
GRanges with 6 ranges and 0 elementMetadata values
    seqnames    ranges strand |
       <Rle> <IRanges>  <Rle> |
[1]     chr1  [11, 14]      - |
[2]     chr1  [12, 15]      - |
[3]     chr1  [13, 16]      - |
[4]     chr1  [14, 17]      - |
[5]     chr1  [15, 18]      - |
[6]     chr1  [16, 19]      - |


seqlengths
 chr1
   NA



Let me know if the devel version doesn't fix your problem.

Valerie






On 09/15/2010 12:00 AM, Dario Strbenac wrote:
> Hello,
>
> I get a problem when I build up my GRangesList element by element.
>
> e.g.
>
>   
>> gRangesList <- GRangesList()
>> load("C:/Users/dario/Documents/Garvan/rawData/seq/Ramaciotti/22-02-2010/s_8_1/PrEC_INPUT_1_GR.Rdata") #loads object called 'rs'
>> head(rs)
>>     
> GRanges with 6 ranges and 0 elementMetadata values
>     seqnames       ranges strand |
>        <Rle>    <IRanges>  <Rle> |
> [1]     chr1 [ 482,  482]      - |
> [2]     chr1 [ 637,  637]      - |
> [3]     chr1 [4818, 4818]      - |
> [4]     chr1 [6322, 6322]      - |
> [5]     chr1 [7375, 7375]      - |
> [6]     chr1 [9138, 9138]      - |
>
> seqlengths
>       chr1     chr10     chr11     chr12     chr13     chr14     chr15     chr16     chr17     chr18 ...      chr3      chr4      chr5      chr6      chr7      chr8      chr9      chrM      chrX      chrY
>  247249719 135374737 134452384 132349534 114142980 106368585 100338915  88827254  78774742  76117153 ... 199501827 191273063 180857866 170899992 158821424 146274826 140273252     16571 154913754  57772954
>   
>> gRangesList[[1]] <- rs
>> load("C:/Users/dario/Documents/Garvan/rawData/seq/Ramaciotti/25-03-2010/s_8_1/LNCaP_INPUT_1_GR.Rdata") # loads another object called 'rs'
>> head(rs)
>>     
> GRanges with 6 ranges and 0 elementMetadata values
>     seqnames         ranges strand |
>        <Rle>      <IRanges>  <Rle> |
> [1]     chr1 [  277,   277]      - |
> [2]     chr1 [ 6163,  6163]      - |
> [3]     chr1 [ 7357,  7357]      - |
> [4]     chr1 [45011, 45011]      - |
> [5]     chr1 [48676, 48676]      - |
> [6]     chr1 [48945, 48945]      - |
>
> seqlengths
>       chr1     chr10     chr11     chr12     chr13     chr14     chr15     chr16     chr17     chr18 ...      chr3      chr4      chr5      chr6      chr7      chr8      chr9      chrM      chrX      chrY
>  247249719 135374737 134452384 132349534 114142980 106368585 100338915  88827254  78774742  76117153 ... 199501827 191273063 180857866 170899992 158821424 146274826 140273252     16571 154913754  57772954
>   
>> gRangesList[[2]] <- rs
>>
>> endoapply(gRangesList, resize, seqLen)
>>     
> Error in validObject(.Object) : 
>   invalid class "GRangesList" object: number of rows in non-NULL 'elementMetadata(x)' must match length of 'x'
>
> Whereas, using the GRangesList constructor is problem free :
>
>   
>> gr1 <-
>>     
> + GRanges(seqnames = "chr2", ranges = IRanges(3, 6),
> + strand = "+", score = 5L, GC = 0.45)
>   
>> gr2 <-
>>     
> + GRanges(seqnames = c("chr1", "chr1"),
> + ranges = IRanges(c(7,13), width = 3),
> + strand = c("+", "-"), score = 3:4, GC = c(0.3, 0.5))
>   
>> gr3 <-
>>     
> + GRanges(seqnames = c("chr1", "chr2"),
> + ranges = IRanges(c(1, 4), c(3, 9)),
> + strand = c("-", "-"), score = c(6L, 2L), GC = c(0.4, 0.1))
>   
>> grl <- GRangesList("gr1" = gr1, "gr2" = gr2, "gr3" = gr3)
>> xtnd <- endoapply(grl, resize, seqLen)
>>     
>   
>> sessionInfo()
>>     
> R version 2.11.1 (2010-05-31) 
> x86_64-pc-mingw32 
>
> locale:
> [1] LC_COLLATE=English_Australia.1252  LC_CTYPE=English_Australia.1252    LC_MONETARY=English_Australia.1252 LC_NUMERIC=C                       LC_TIME=English_Australia.1252    
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base     
>
> other attached packages:
>  [1] BSgenome.Hsapiens.UCSC.hg18_1.3.16 DNAcopy_1.22.0                     chipseq_0.4.0                      ShortRead_1.6.2                    Rsamtools_1.0.0                   
>  [6] lattice_0.18-8                     BSgenome_1.16.0                    Biostrings_2.16.0                  GenomicRanges_1.0.9                IRanges_1.6.17                    
>
> loaded via a namespace (and not attached):
> [1] Biobase_2.8.0 grid_2.11.1   hwriter_1.2   tools_2.11.1 
>
> --------------------------------------
> Dario Strbenac
> Research Assistant
> Cancer Epigenetics
> Garvan Institute of Medical Research
> Darlinghurst NSW 2010
> Australia
>
> _______________________________________________
> Bioc-sig-sequencing mailing list
> Bioc-sig-sequencing at r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioc-sig-sequencing
>



More information about the Bioc-sig-sequencing mailing list