I am working on the TxDb.Hsapiens.UCSC.hg19.knownGene
data. I found that the length of the largest exon is 205012. How can I proceed to find the genomic coordinate of that exon?
Asked
Active
Viewed 106 times
-1

Vincent Guillemot
- 3,394
- 14
- 21

Chris7
- 11
- 1
-
2Welcome to stackoverflow. What have you tried so far? – TarJae Mar 14 '21 at 18:19
-
If you found the maximum range with the function `max`, you might want to consider using the function `which.max` to know which one is the max. – Vincent Guillemot Mar 14 '21 at 18:41
1 Answers
1
You can use which.max()
on the Granges, something like below:
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
txdb = TxDb.Hsapiens.UCSC.hg19.knownGene
ex = exons(txdb)
ex$len = width(ex)
ex[which.max(ex$len)]
GRanges object with 1 range and 2 metadata columns:
seqnames ranges strand | exon_id len
<Rle> <IRanges> <Rle> | <integer> <integer>
[1] chr12 102591363-102796374 + | 164764 205012
-------
seqinfo: 93 sequences (1 circular) from hg19 genome

StupidWolf
- 45,075
- 17
- 40
- 72
-
-
Hi @Chris7, if it indeeds solves the problem, you can consider accepting it so that others know it works – StupidWolf Mar 14 '21 at 20:03
-
https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work – StupidWolf Mar 14 '21 at 20:03