More posts like this
-
Bam file depth of coverage and statstics
written by daewowo •I am looking for a tool that can provide a high level summary of coverage statistics of genomes used in an alignment. I concatenated GCF_000002285.5_Dog10K_Boxer_Tasha_genomic.fna, …
-
Calculate coverage
written by daewowo •I realise this has been asked a lot, but I havent found a tool that fits my simple needs. I would like to calculate coverage …
-
Coverage of target genes
written by gubrinsGood afternoon, I'm working with target capture sequencing and I would like to know the coverage of my target genes, which I just have in …
-
To calculate the length of aligned genome
written by sambioinfo2018 •Dear All, I have a bam file aligned to a reference genome. I would like to know if there is a way to calculate the …
-
Is there an alignment program that allows you to sort results by coverage (amount of reference sequ…
written by CC •I am wanting to align reads to a database of reference sequences. This database contains thousands of reference sequences. I would like to only see …
-
How to get percent identity from bam file ?
written by DavidI have aligned raw 1D nanopore reads to a bacterial reference assembly using BWA –MEM and got the sam and bam file. Is there a …
-
How do we find the number of sequences with terminal mismatches?
written by MAPKI have created a bowtie aligned .sam file with this command: `bowtie -S -p 18 /media/owner/ref.fa test1.fastq test1.sam` which I then converted to .bam file …
-
Calculating the sequence similarity and percentage of matched sequences
written by ago1mutant •I have multiple aligned fasta files containing two sequences. I would like to know the sequence similarity and percentage of matched sequences. Are there any …
-
Extract the mapped contig sequences from SAM/BAM file
written by BDK_compbioI have a sam/bam file that contains the mapping of long reads with assembled contigs from short reads. Because of low coverage of long reads, …
-
how to convert .bam from unpadded to padded representation?
written by bw.I have an aligned .bam file and a reference .fasta file. I'd like to convert the .bam and .fasta from an unpadded representation to a …
what did you find so far ?
I tried
samtools mpileupbut it got aborted as I run without-r chr3:1,000-2,000and single BAM file. Also I runbamtools coverage -in in.BAM -out output_reads_coverage.txt, but not sure how can I calculate the percentage of coverage from output file.What do you mean by the 'percentage of coverage' exactly?
samtools flagstatwill show the percentage of your reads that have aligned to the reference genome. BEDTools, on the other hand, has numerous functions that allow you to determine depth of coverage and read depth of these reads that have aligned [to the reference].Hi Kevin, Thanks for the reply. I used
samtools flagstatfor other statistics. Suppose I have one contigs of length 100 and two reads of length 20 and 30 respectively. Let the first read is aligned from position 10 to 30 and the second read is aligned from position 20 to 50. So the percentage of coverage is 40% here as all bases from position 10 to 50 are aligned.Does BEDTools generate this percentage?
Yes, that's what I thought that you meant. It's not a traditional metric that 's observed but I have to admit that it's interesting and I think that I'll calculate it in my analyses in the future. Thanks!
Anyway, I have been able to do this just now indirectly using BEDTools and looking over the hg38 reference genome:
Bases at 0 read depth:
Bases at >0 read depth:
The
genomecovfunction ofBEDToolsnormally computes coverage in your BAM file for each position in your supplied reference genome. The output looks like this:I then use the awk commands to calculate total bases at 0 read depth and total bases >0 read depth. After that, the calculation for percentage can easily be done. For my sample (a small targeted sequence panel), I ended up with:
It took less than a minute to run with my commands above.
If you want to automate this in a pipeline, the following code would work (note that in BASH decimal points need to be handled specially with the
bccommand):Like I said, I think that this is a useful metric and you could perhaps turn this into a tutorial(?), if Pierre agreed too.
Thanks Kevin. It works really great. I have just one more question (could be a very basic question as I am new to this sort of analysis). Actually, I have a reference file that contains almost 60K sequences and only 50% of them are aligned with reads. I would like to find the coverage only for the sequences in reference that are aligned. The coverage percentage that I calculated is very low and it could be because of zero bases of all sequences.
Hi again friend,
If you just want the coverage of the aligned reads, then you just change the
-bgaparameter to-bg, and this will not then output the unaligned reads (with 0 read depth).There are other options here using
bedtools genomecov: http://bedtools.readthedocs.io/en/latest/content/tools/genomecov.htmlLet me know if this answers your question!