convert XStringViews into GRanges
1
1
Entering edit mode
@vinicius-henrique-da-silva-6713
Last seen 10 months ago
Brazil

I would like to produce a GRanges from a XStringViews object. However I am getting an error:

library(BSgenome.Hsapiens.UCSC.hg19)
hg19=BSgenome.Hsapiens.UCSC.hg19

tata <- DNAString("TATAAA")

ma <- matchPattern(tata,hg19$chr22)

gma <- as(ma, "GRanges")
Error in as(ma, "GRanges") : 
  no method or default for coercing “XStringViews” to “GRanges”


Some idea how to successfully make a conversion between this two classes?

GRanges XStringViews • 1.3k views
ADD COMMENT
3
Entering edit mode
@michael-lawrence-3846
Last seen 2.4 years ago
United States

What is your expected result? There is not enough information to construct a GRanges from an XStringViews. Note that any Views is composed of a subject and a set of ranges, and those ranges can be extracted via ranges().  So if you wanted a GRanges with those ranges on chr22, do: GRanges("chr22", ranges(ma)).

But perhaps you want to do this over the whole genome, in which case this is a lot easier:

gma <- vmatchPattern(tata, hg19)
ADD COMMENT

Login before adding your answer.

Traffic: 488 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6