[Bioc-sig-seq] adding columns to values of GenomicRange objects

Jiang, Lichun (NIH/NIDDK) [F] jianglichun at niddk.nih.gov
Mon Aug 23 23:03:52 CEST 2010

Hi Steve,
     Thanks, it works!


From: Steve Lianoglou [mailinglist.honeypot at gmail.com]
Sent: Monday, August 23, 2010 5:00 PM
To: Jiang, Lichun (NIH/NIDDK) [F]
Cc: bioc-sig-sequencing at r-project.org
Subject: Re: [Bioc-sig-seq] adding columns to values of GenomicRange objects

Hi Lichun,

On Mon, Aug 23, 2010 at 4:14 PM, Jiang, Lichun (NIH/NIDDK) [F]
<jianglichun at niddk.nih.gov> wrote:
> Hi Dear all,
>    I am a newbie using GRanges and related packages. Try to figure out how can I add an column of values to the GenomicRanges.
> For example I get a object named as TF_peaks:
> GRanges with 2000 ranges and 3 elementMetadata values
>    seqnames                 ranges strand | elementMetadata.polIIsignal elementMetadata.inputSignal elementMetadata.enrichment
>       <Rle>              <IRanges>  <Rle> |                   <integer>                   <integer>                  <numeric>
> [1]     chr1 [205566106, 205576720]      * |                        1504                           4                   382.2567
> [2]     chr1 [ 11890546,  11892791]      * |                        1140                           4                   347.6909
> ....
> I tried to add another value to describe whether this features are overlapping with promoters(I already has this value as inpromoteres for example ).
> But I can't add this value to the TF_peaks object by standard function for dataframe manipulation. I guess I am not fully understand the S4 methods.  Anyone can help me out?

How did you try to do it?

You have to "get" the DataFrame associated with your GRanges object
using the `values` or `elementMetadata` function, which you could then
manipulate as you (probably) are expecting to. So, you simply have to:

R> values(TF_peas)$overlaps <- inpromoteres

or variation above, given the column name you want to store this
under, and the variable name you have your 'overlapping' info in.

Hope that helps,

Steve Lianoglou
Graduate Student: Computational Systems Biology
 | Memorial Sloan-Kettering Cancer Center
 | Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

More information about the Bioc-sig-sequencing mailing list