Get the longest transcript in GenomicRanges
I am trying to plot an specific region using ggbio. I am using the below code that produces my desire output, except that it contains several transcript. Is it possible to only plot the longest transcript for each gene? I've not been able to access the genomic ranges object within Homo.sapiens that I assume contains this information.
library(ggbio)
library(Homo.sapiens)
data(genesymbol, package = "biovizBase")
range <- GRanges("chr10" , IRanges(start = 78000000 , end = 79000000))
p.txdb <- autoplot(Homo.sapiens, which = range)
p.txdb
• 3,266 views
•
link
0 answers
No answers yet.
Log in to answer this question.
I tried this yesterday for quite some time and did not come up with a satisfying and simple solution, maybe some Twitter people have an idea: https://twitter.com/ATpoint90/status/1265946486602444800
Thanks for the help. I've checked which data can be retrieved from the
Homo.sapiensobject usingcolumns(Homo.sapiens), and there is actually information on the transcript start and transcript end. I think I will need to get the width first, and then modify theHomo.sapiensobject somehow?Looks like this is what you want to (once you get the ID of the longest transcript) : A: Plotting a single transcript with ggbio
I checked that, and a
TxDbobject does not contain gene names... I would like to show the name of the genes not the transcripts names.That definitely works but there must be an easier (in-built way, I hope). Anyway, getting the longest transcript is simple:
Great, thanks! So, then, within the
autoplotfunction, how do I select only those transcripts? I am trying to do that, but it keeps printing all transcripts.I just found out that I can
reducethe transcripts... which is not exactly what I want, as I think this is collapsing all the transcripts... i.e.p.txdb <- autoplot(Homo.sapiens, which = range, stat = "reduce")Yeah, that is unfortunately what I did not find out yet.