[BioC] Augmenting metadata values in GRanges object

Martin Morgan mtmorgan at fhcrc.org
Wed Nov 16 02:31:09 CET 2011


On 11/15/2011 03:50 PM, Fahim Mohammad wrote:
> Hi
> Is there a function to augment metadata into an already built GRanges
> object?
>
> For example (ex from vignette)
>
>
>>        gr<- GRanges(seqnames = Rle(c("chr1", "chr2", "chr1",+  "chr3"), c(1, 3, 2, 4)), ranges = IRanges(1:10, end = 7:16,+  names = head(letters, 10)), strand = Rle(strand(c("-",+  "+", "*", "+", "-")), c(1, 2, 2, 3, 2)), score = 1:10,+  GC = seq(1, 0, length = 10))

>        grGRanges with 10 ranges and 2 elementMetadata values:
>      seqnames    ranges strand |     score                GC
>         <Rle>  <IRanges>   <Rle>  |<integer>          <numeric>
>    a     chr1  [ 1,  7]      - |         1                 1
>    b     chr2  [ 2,  8]      + |         2 0.888888888888889
>    c     chr2  [ 3,  9]      + |         3 0.777777777777778
>    d     chr2  [ 4, 10]      * |         4 0.666666666666667
>    e     chr1  [ 5, 11]      * |         5 0.555555555555556
>    f     chr1  [ 6, 12]      + |         6 0.444444444444444
>    g     chr3  [ 7, 13]      + |         7 0.333333333333333
>    h     chr3  [ 8, 14]      + |         8 0.222222222222222
>    i     chr3  [ 9, 15]      - |         9 0.111111111111111
>    j     chr3  [10, 16]      - |        10                 0
>    ---
>    seqlengths:
>     chr1 chr2 chr3
>       NA   NA   NA>        toAdd = c(1:10)>  toAdd [1]  1  2  3  4  5
> 6  7  8  9 10
>
>
> I want to append this ('toAdd') metadata to already built GRanges object
> ('gr').
> Is there any function to do that?

Hi Fahim -- Along the lines of

 > metadata(gr) = list("some thing")
 > metadata(gr) = c(metadata(gr), list("some other thing"))
 > metadata(gr)
[[1]]
[1] "some thing"

[[2]]
[1] "some other thing"

see ?"metadata<-".

Martin

> Thanks
>
> Thanks
> Fahim
> Bioinformatics Lab
> University of Louisville
> Louisville, KY USA
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> 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