Get internal exons using GenomicFeatures
1
1
Entering edit mode
geparada88 ▴ 10
@geparada88-9603
Last seen 5.9 years ago

Hi

I'm trying to make a Granges objet with all the internal exons of the genes annotated in a GTF file. I using this code:

txdb <- makeTxDbFromGFF("./gencode.vM9.chr_patch_hapl_scaff.annotation.gtf.sed", format="gtf")
exons <- exonsBy(txdb, by="tx")
internal_exons <- lapply(exons,
       function(x) if (length(x)>=3){x[3:length(x)-1] })

But it running really slow, is there any way to make it more efficient?
 

 

 

genomicfeatures granges • 726 views
ADD COMMENT
3
Entering edit mode
@michael-lawrence-3846
Last seen 13 months ago
United States

The more important problem is that internal_exons is not a convenient data structure. It will contain NULL values where the condition failed, instead of an empty set of ranges, and the list is semantically poor. Also, the looping obscures the code.

This is faster and cleaner:

internal_exons <- phead(ptail(exons, -2L), -1L)

 

ADD COMMENT
0
Entering edit mode

You are totally right! I was having problems to use internal_exons as a list. Thanks a lot.

ADD REPLY

Login before adding your answer.

Traffic: 414 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