Exon density in uniform bins across bam files
1
0
Entering edit mode
4.1 years ago

I'd like to calculate the percent of bases that overlap exons in uniformly sized (n mB) windows across several bam files. Could anyone help me determine this preferably using bedtools or R?

alignment sequencing • 726 views
ADD COMMENT
0
Entering edit mode
4.1 years ago

using R GenomicRanges and given two granges objects exonic_bed and bins

hits <- GenomicRanges::findOverlaps(query = exonic_bed, 
subject = bins, ignore.strand = TRUE)
overlaps <- pintersect(bins[subjectHits(hits)], 
exonic_bed[queryHits(hits)],  ignore.strand = TRUE)

subjecthits <- bins[subjectHits(hits)]
subjecthits$n_overlap <- width(overlaps)

subjecthits <- 
  subjecthits %>% 
  as_tibble() %>% 
  dplyr::group_by(seqnames, start, end, width) %>% 
  dplyr::summarize(overlap = sum(n_overlap)) %>% 
  dplyr::mutate(percent_overlap = overlap/width)
ADD COMMENT
0
Entering edit mode
ADD REPLY

Login before adding your answer.

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