Entering edit mode
                    Tim Yates
        
    
        ▴
    
    250
        @tim-yates-4040
        Last seen 11.2 years ago
        
    Hi all,
I'm trying to move to using GRanges objects for storing my genomic
features
rather than IRanges objects that I use currently.
However, I cannot seem to subscript the Genomic Ranges object to
extract a
single column from the meta-data of the object.
Hopefully this code explains what I am trying to do, and someone can
point
me in the right direction?
Cheers,
Tim
> library(GenomicRanges)
Loading required package: IRanges
Attaching package: 'IRanges'
    The following object(s) are masked from package:base :
     cbind,
     Map,
     mapply,
     order,
     paste,
     pmax,
     pmax.int,
     pmin,
     pmin.int,
     rbind,
     rep.int,
     table
> library(GenomicRanges)
> my.starts  = c(     10,    100,   1000 )
> my.ends    = c(     20,    200,   2000 )
> my.spaces  = c(    '1',    '2',    '3' )
> my.strands = c(    '+',    '+',    '-' )
> my.names   = c( 'seq1', 'seq2', 'seq3' )
> my.delta   = c(   1.23,   2.34,   3.45 )
>
> my.df = data.frame( start=my.starts, end=my.ends, space=my.spaces,
strand=my.strands, name=my.names, delta=my.delta )
> my.rd = as( my.df, 'RangedData' )
> my.gr = as( my.rd, 'GRanges' )
>
# Extract the name field from each of these objects using [[
> print( my.df[[ 'name' ]] )
[1] seq1 seq2 seq3
Levels: seq1 seq2 seq3
> print( my.rd[[ 'name' ]] )
[1] seq1 seq2 seq3
Levels: seq1 seq2 seq3
> print( my.gr[[ 'name' ]] )
Error in my.gr[["name"]] : missing '[[' method for Sequence class
GRanges
>
# Extract the name field from each of these objects using $
> print( my.df$'name' )
[1] seq1 seq2 seq3
Levels: seq1 seq2 seq3
> print( my.rd$'name' )
[1] seq1 seq2 seq3
Levels: seq1 seq2 seq3
> print( my.gr$'name' )
Error in x[[name, exact = FALSE]] :
  missing '[[' method for Sequence class GRanges
>
> sessionInfo()
R version 2.10.1 (2009-12-14)
x86_64-apple-darwin9.8.0
locale:
[1] en_GB.UTF-8/en_GB.UTF-8/C/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
other attached packages:
[1] GenomicRanges_1.0.8 IRanges_1.6.15
--------------------------------------------------------
This email is confidential and intended solely for the
u...{{dropped:15}}
                    
                
                