Entering edit mode
Michael Muratet
▴
420
@michael-muratet-3076
Last seen 10.3 years ago
Greetings
I would like to select elements from a GRanges object by testing
values in the metadata columns. This seems to work OK:
x.gr[whichelementMetadatax.gr)$fdr<0.05)]
So does this, although there's nothing in the documentation about the
[] operator accepting logical values:
fosl2.th17.gr[elementMetadatafosl2.th17.gr)$fdr<0.05]
The problem arises when I try to select from a GRanges object where
the metadata columns have NAs:
> tss.annot.gr[na.omitelementMetadatatss.annot.gr)$GENE>0),"GENE"]
GRanges with 4028 ranges and 1 elementMetadata col:
seqnames ranges strand | GENE
<rle> <iranges> <rle> | <numeric>
[1] chr1 [ 3659579, 3662079] - | <na>
[2] chr1 [ 4847394, 4849894] + | 0
[3] chr1 [10025979, 10028479] - | <na>
[4] chr1 [17085879, 17088379] - | <na>
[5] chr1 [21067298, 21069798] - | <na>
[6] chr1 [21949662, 21952162] - | 0
[7] chr1 [23388014, 23390514] - | <na>
[8] chr1 [23768264, 23770764] + | <na>
[9] chr1 [23927128, 23929628] - | <na>
... ... ... ... ... ...
[4020] chr2 [126607180, 126609680] - | 0
[4021] chr2 [127345106, 127347606] - | 0
[4022] chr2 [129195132, 129197632] + | -1.223140339
[4023] chr2 [129194856, 129197356] - | -1.628782357
[4024] chr2 [129360338, 129362838] - | -1.475535653
[4025] chr2 [129837609, 129840109] + | 0
[4026] chr2 [129948520, 129951020] + | 0
[4027] chr2 [140213446, 140215946] - | 0
[4028] chr2 [148267271, 148269771] - | -1.564551101
The values returned violate the condition. It won't work at all
without na.omit.
I can coerce the GRanges object to a data.frame, do the selection and
create a new GRanges object, but I'm hoping there is a way to do it
directly.
Am I using the syntax correctly? Is there something peculiar about a
DataFrame vs a data.frame that's getting in the way?
Thanks
Mike
Michael Muratet, Ph.D.
Senior Scientist
HudsonAlpha Institute for Biotechnology
mmuratet at hudsonalpha.org
(256) 327-0473 (p)
(256) 327-0966 (f)
Room 4005
601 Genome Way
Huntsville, Alabama 35806