This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to compute average depth of coverage for expression matrix

So I am trying to find the average depth of coverage of 100 genes from a given reference genome in a given time interval 1 - 10.

I have 10 sorted, indexed bam files, and using samtools depth I was able to find each corresponding avg coverage for coverage base and the total base coverage, but how would I be able to find each gene's avg coverage from this data?

alignment rna-seq sequence genome

1 answer

  1. To sort bam file:

    samtools sort file.bam file.sorted
    
  2. Install and run bedtools to get coverage:

    coverageBed -d -abam file.sorted.bam -b /path/to/.bed/file/ref.bed > output.cov
    
  3. This will include names to the columns of the output: (reference, start position, end position, base, coverage at the position)

    sed -i 1i" ref\tstart\tend\tbase\tcov " file.cov
    

You can use the output to calculate average coverages.

Log in to answer this question.