On Thu, Nov 17, 2011 at 6:28 PM, Fahim Mohammad <fahim.md@gmail.com> wrote:

> Hi
> In the following example, I am trying to use 'reduce()' function to reduce
> the genomic intervals and find intervals corresponding to  'Gene'. It is
> behaving as it is desired. However the output of the reduce just give the
> intervals (I am losing the 'Gene' metadata).
> Is there a way to retain 'Gene' metadata.
>
>
> >       gr <- GRanges(+                     seqnames = Rle(c("chr1",
> "chr2", "chr2"), c(6, 2,2)), +                     ranges = IRanges(c(1:6,
> 1:2, 10:11) , end = c(7:12, 5,9, 18:19 )), +                     strand =
> Rle(strand(c("-", "+", "-", "*")),c(3, 3, 2,2)), +
> transcript  = head(letters, 10),+                     Gene =
> c(rep("xxx",3), rep("yyy",3), rep("zzz",2), rep("www",2)) +
>     )>       grGRanges with 10 ranges and 2 elementMetadata values:
>       seqnames    ranges strand |  transcript        Gene
>          <Rle> <IRanges>  <Rle> | <character> <character>
>   [1]     chr1  [ 1,  7]      - |           a         xxx
>   [2]     chr1  [ 2,  8]      - |           b         xxx
>   [3]     chr1  [ 3,  9]      - |           c         xxx
>   [4]     chr1  [ 4, 10]      + |           d         yyy
>   [5]     chr1  [ 5, 11]      + |           e         yyy
>   [6]     chr1  [ 6, 12]      + |           f         yyy
>   [7]     chr2  [ 1,  5]      - |           g         zzz
>   [8]     chr2  [ 2,  9]      - |           h         zzz
>   [9]     chr2  [10, 18]      * |           i         www
>  [10]     chr2  [11, 19]      * |           j         www
>  ---
>  seqlengths:
>   chr1 chr2
>     NA   NA>       x = reduce(gr)>       xGRanges with 4 ranges and 0
> elementMetadata values:
>      seqnames    ranges strand
>         <Rle> <IRanges>  <Rle>
>  [1]     chr1  [ 4, 12]      +
>  [2]     chr1  [ 1,  9]      -
>  [3]     chr2  [ 1,  9]      -
>  [4]     chr2  [10, 19]      *
>  ---
>  seqlengths:
>   chr1 chr2
>     NA   NA
>

This doesn't do exactly what you seek, but it gives a mangled names
attributed that you can unmangle
and reattach as metadata if you like

unlist(reduce(split(gr, elementMetadata(gr)$Gene)))


>
> >
>
>
> Thanks
>
>
> Fahim
>
> --
> -------------------------------
> Fahim Mohammad
> Bioinforformatics Lab
> University of Louisville
> Louisville, KY, USA
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor@r-project.org
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives:
> http://news.gmane.org/gmane.science.biology.informatics.conductor
>

	[[alternative HTML version deleted]]

