Can I use rtracklayer to get the sequence surrounding a set of variants?
2
0
Entering edit mode
@stephanie-m-gogarten-5121
Last seen 8 weeks ago
University of Washington

I have a set of variants stored in a GRanges, and I'd like to get the surrounding reference sequence (+/- 100 bp) for each one. I can use rtracklayer to view the variants in UCSC, and I can then get the surrounding sequence by going to the table browser, selecting my custom track and "output format: sequence", then specifying the number of extra bases I want in the browser window. Is there a way to do this programmatically from within R?

rtracklayer sequencing reference genome • 824 views
1
Entering edit mode
@stephanie-m-gogarten-5121
Last seen 8 weeks ago
University of Washington

No reason, I just hadn't used it before. Turns out it's super easy. Solution for posterity:

> library(BSgenome.Hsapiens.UCSC.hg19)
> gr <- GRanges("chr1", IRanges(65500, 65500))
> start(gr) <- start(gr) - 100
> end(gr) <- end(gr) + 100
> getSeq(Hsapiens, gr, as.character=TRUE)
[1] "AAAGCTCAGACTGGCTATTCCCAGATCTCTTCAGGTACATCTAGTCCATTCATAAAGGGCTTTTAATTAACCAAGTGGTTTACTAAAAAGGACAATTCACTACATATTATTCTCTTACAGTTTTTATGCCTCATTCTGTGAAAATTGCTGTAGTCTCTTCCAGTTATGAAGAAGGTAGGTGGAAACAAAGACAAAACACAT"
0
Entering edit mode
@michael-lawrence-3846
Last seen 5 months ago
United States

Currently, no. There was some work on that, but it was abandoned, I think because BSgenome already offers the sequence for the important organisms. Is there some reason why you can't use a BSgenome package?