[Bioc-sig-seq] GRanges resize Behaviour

Patrick Aboyoun paboyoun at fhcrc.org
Fri Aug 6 08:31:22 CEST 2010


Dario,
Make sure you provide your sessionInfo() when reporting behavior. The 
answer to you second issue dealing with the lapply method is due to 
symbol masking. The GenomicRanges package uses the implicit generic for 
lapply created by the IRanges package. This implicit generic is not the 
one you selected when you ran your lapply command. Next time to be sure 
you grab the correct lapply function, you can use IRanges::lapply(grl, ...).

 > library("GenomicRanges")
 > find("lapply")
[1] "package:IRanges" "package:base"
 > sessionInfo()
R version 2.12.0 Under development (unstable) (2010-08-01 r52659)
Platform: i386-apple-darwin9.8.0/i386 (32-bit)

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] GenomicRanges_1.1.20 IRanges_1.7.15

The first issue you reported is intended. GRanges objects are only bound 
if the seqlengths are non-NAs. For example, to get behavior that you are 
expecting, set the seqlengths to positive integer values:

 > gr <- GRanges("chr2", IRanges(250, 285), strand="-", seqlengths = 
c(chr2=300))
 > gr
GRanges with 1 range and 0 elementMetadata values
     seqnames     ranges strand |
<Rle> <IRanges> <Rle> |
[1]     chr2 [250, 285]      - |

seqlengths
  chr2
   300
 > resize(gr, 300)
GRanges with 1 range and 0 elementMetadata values
     seqnames    ranges strand |
<Rle> <IRanges> <Rle> |
[1]     chr2  [1, 285]      - |

seqlengths
  chr2
   300
Warning message:
In `start<-`(`*tmp*`, value = -14L) : trimmed start values to be positive

I hope this helps.

Cheers,

Patrick


On 8/5/10 6:00 PM, Dario Strbenac wrote:
> Hi,
>
> I'd like to point out that resize extends beyond the start of a chromosome, for reads that are close to the start, and on the negative strand.
>
>    
>> gr
>>      
> GRanges with 1 range and 0 elementMetadata values
>      seqnames     ranges strand |
>         <Rle>   <IRanges>   <Rle>  |
> [1]     chr2 [250, 285]      - |
>
>    
>> resize(gr, 300)
>>      
> GRanges with 1 range and 0 elementMetadata values
>      seqnames     ranges strand |
>         <Rle>   <IRanges>   <Rle>  |
> [1]     chr2 [-14, 285]      - |
>
> seqlengths
>   chr2
>     NA
>
> Would the desirable behaviour be to only extend to base 1 ?
>
> One more question. In the user manual (page 12, bottom), it says lapply can be used on a GRangesList, but it's not working for me.
>
>    
>> grl
>>      
> GRangesList of length 3
> $gr1
> GRanges with 1 range and 2 elementMetadata values
>      seqnames    ranges strand |     score        GC
>         <Rle>  <IRanges>   <Rle>  |<integer>  <numeric>
> [1]     chr2    [3, 6]      + |         5      0.45
>
> $gr2
> GRanges with 2 ranges and 2 elementMetadata values
>      seqnames    ranges strand |     score        GC
>         <Rle>  <IRanges>   <Rle>  |<integer>  <numeric>
> [1]     chr1  [ 7,  9]      + |         3       0.3
> [2]     chr1  [13, 15]      - |         4       0.5
>
> $gr3
> GRanges with 2 ranges and 2 elementMetadata values
>      seqnames    ranges strand |     score        GC
>         <Rle>  <IRanges>   <Rle>  |<integer>  <numeric>
> [1]     chr1    [1, 3]      - |         6       0.4
> [2]     chr2    [4, 9]      - |         2       0.1
>
>
> seqlengths
>   chr2 chr1
>     NA   NA
>
>    
>> lapply(grl, cat, "Hello")
>>      
> Error in as.list.default(X) :
>    no method for coercing this S4 class to a vector
>
> --------------------------------------
> 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