Hi all,
I am trying to analyze the Zebrafish genome and especially I want to get the proportion of the genome that is overlapped by genes.
For that purpose, I load the gtf annotation of Ensembl into "features" and then I select for genes as follows and convert to a pyrange object:
genes_=features[features['Feature']=='gene']
genes=pr.PyRanges(genes_)
Then I want to compute the length of genome overlapped by genes, as follows:
genes_lengths=genes.merge(strand).length
where strand=False when I consider both strands of the genome together (=it merges genes regardless of if they overlap on the same or opposite strand) [case1] and in [case2] I set strand to True in order to only merge genes if they overlap on the same strand.
In case1, I set genome_length to 1373471384 bp (according to Ensembl) and in case2 I set genome_length=2*1373471384 bp as I consider separately the strands.
Then I simply proceed with:
intergenic_length=genome_length-genes_lengths
percent_genic=round(get_percentage(genes_lengths,genome_length),2)
percent_intergenic=round(get_percentage(intergenic_length,genome_length),2)
In case1 I get that 55% of the genome is overlapped by genes, while in case2 I get that 28% of genome is overlapped by genes.
In both cases, it is way higher than what Ensembl reports (according to AI because I don't find it on Ensembl directly: 5 to 10% only of gene coverage).
So my question is: why am I getting such higher gene coverage and what do you think is actually correct?
Let me add that I created those two cases scenarios because I want to compare to the proportion of the genome covered by a given binding site and in case1 I would consider that when the protein binds on one strand it modify the opposite strand at the same time, while in case2 the protein can only modify the binding site on the strand on which it's bound.
Thank you deeply for any appreciated insight!
0 answers
No answers yet.
Log in to answer this question.
initial thought: perhaps Ensembl is NOT counting the intronic regions neither (which you do include in the current approach)? so they only take the actual exons (&UTRs?) into account?
also this feels off:
also in your case1 you count genes from both strands?
To confirm, are you looking to a number of bases that are assigned to genes (coding/non-coding) from the whole genome?
In any case Calculate the fraction of genome that is feature X likely has the answer for your question.
agreed; this would have been my first instinct
I am considering the positions of the genes, rather than comparing a number of bases. Namely, I compute the genome proportion overlapped by genes by considering the intervals of genes positions, and merge them if they're on same strand or not according to case1 or case2. But I guess it is somehow similar to looking at bases, and I feel like it's what is done in the code suggested by GenoMax .
lieven.sterck you might be right, in my case as I consider the positions of the genes (which are the outermost boundaries of the transcripts variants of gene), it includes the introns which might explain why I get higher proportions. Thanks for the insight!!
In case1, I consider genes from both strands but I merge their positions regardless of strand (=if they're on same strand or not), while in case2 I merge genes only if they're on the same strand.
Thanks !