Entering edit mode
Fahim Md
▴
250
@fahim-md-4018
Last seen 10.2 years ago
Hi
I generated a data frame from GRanges object by performing
data = as.data.frame (grObj, row.names =NULL); #grObject is GRanges
object
having 'seqnames' as one of its field.
save (data, file = ..)
Now I want to read this data file again as GRanges object.
Is there any built-in method to do that? ( 'as' method in GRanges is
currently is not able to do it.)
Alternatively, I tried to convert the data frame into RangedData first
and
then into GRanges. But the conversion into RangedData assumed the
'seqnames' as metadata and by default inserted 'space' with value '1'
in
IRanges. This conversion cast a problem for GRanges coersion as
'seqnames'
are now in the metadata field which is reserved keyword and thus
producing
error.
> library(IRanges)> library(GenomicRanges)>
load('/home/fahim/hg19/GeneName.RData')> head(data) seqnames start
end width strand name
1 Chr1 10954 11507 554 + LOC100506145
2 Chr1 12190 13639 1450 + LOC100652771
3 Chr1 14362 29370 15009 - WASH7P
4 Chr1 30366 30503 138 + MIR1302-2
5 Chr1 34611 36081 1471 - FAM138A
6 Chr1 52453 53396 944 + OR4G4P> rd1 = as(data,
"RangedData")> rd1RangedData with 36590 rows and 3 value columns
across 1 space
space ranges | seqnames strand name
<factor> <iranges> | <factor> <factor> <factor>
1 1 [ 10954, 11507] | Chr1 + LOC100506145
2 1 [ 12190, 13639] | Chr1 + LOC100652771
3 1 [ 14362, 29370] | Chr1 - WASH7P
4 1 [ 30366, 30503] | Chr1 + MIR1302-2
5 1 [ 34611, 36081] | Chr1 - FAM138A
6 1 [ 52453, 53396] | Chr1 + OR4G4P
7 1 [ 63016, 63885] | Chr1 + OR4G11P
8 1 [ 69091, 70008] | Chr1 + OR4F5
9 1 [131125, 135677] | Chr1 + LOC100420257
... ... ... ... ... ... ...
36582 1 [59100457, 59115123] | ChrY + SPRY3
36583 1 [59160762, 59162330] | ChrY - AMDP1
36584 1 [59213949, 59276439] | ChrY + VAMP7
36585 1 [59311663, 59311996] | ChrY - TCEB1P24
36586 1 [59318017, 59318918] | ChrY - TRPC6P
36587 1 [59330252, 59343488] | ChrY + IL9R
36588 1 [59354329, 59358343] | ChrY + WASH6P
36589 1 [59358332, 59360854] | ChrY - DDX11L16
36590 1 [59361222, 59361778] | ChrY -
LOC100507426> rd2 = as(rd1, "GRanges")Error in validObject(.Object) :
invalid class "GRanges" object: slot 'elementMetadata' cannot use
"seqnames", "ranges", "strand", "seqlevels", "seqlengths",
"isCircular", "genome", "start", "end", "width", "element" as column
names
>
[[alternative HTML version deleted]]