I'm performing genic annotations with my data using annotatr, and I have a question.
How can I know the proportion of genic annotations (exon, intron, intergenic and so on) of whole hg38 genome determined in annotatr?
What exactly do you mean by 'proportion of genic annotations'? One possibility would be to see what proportion of all the exons are covered by the regions you are annotating. If so, you end up with a GRanges object from annotatr, and you presumably have a GRanges object for the genomic sites you were annotating against. Let's say your object from annotatr is called 'annot' and the regions GRanges object is called 'exons'.
We don't want to count the width of exons or annotations that are duplicated, so we want to use reduce first. Then we get the widths, of those regions, and then sum it up.
## total width of annotated regions
totannot <- sum(width(reduce(annot)))
## total width of exons
totexon <- sum(width(reduce(exons)))