Category

Sam/Bam Manipulation


Usage

samtools bedcov [INPUT BED] [INPUT BAM1] ... [INPUT BAMn] > [OUTPUT]


Manual

Reports the total read base count (i.e. the sum of per base read depths) for each genomic region specified in the supplied BED file. The regions are output as they appear in the BED file and are 0-based. Counts for each alignment file supplied are reported in separate columns. Compared to bedtools coverage, samtools bedcov returns the sum of per-base coverage in each region instead of the number of reads in each region.

Required arguments

  • in.bed: Input BED file.
  • in.bam: Input BAM file(s). Each bam file should have corresponding index ready (see samtools index)

Options

  • -Q, --min-MQ int: Mapping quality threshold [0].
  • -X: Use customized index files.
  • -g flags: Remove the specified flags from the set used to filter out reads.
  • -G flags: Add the specified flags to the set used to filter out reads. The default set is UNMAP, SECONDARY, QCFAIL, DUP, or 0x704.
  • -j: Do not include deletions (D) and ref skips (N) in bedcov computation.
  • -d int: Depth threshold. Number of reference bases with coverage above and including this value will be displayed in a separate column.
  • -c: Add an additional column showing read count.
  • --input-fmt-option OPT[=VAL]: Specify a single input file format option in the form of OPTION or OPTION=VALUE.
  • --reference FILE: Reference sequence FASTA FILE [null].
  • --verbosity INT: Set level of verbosity.

Examples

Here is a bed file with 6 columns:

$ head -n 5 C1_1_bidirectional_peaks.bed
chr1    605407    605585    Stringent(qval)    605571    605440
chr1    778535    778929    Stringent(qval)    778923    778637
chr1    826728    826910    Relaxed    826909    826732
chr1    827276    827351    Stringent(pval)    827301    827327
chr1    827415    827791    Stringent(qval)    827699    827505

We can use samtools bedcov to calculate the coverages in each input files. The coverages (in bold) for each bam file will be appended to the end of each row.

$ samtools bedcov C1_1_bidirectional_peaks.bed ENCFF112MXH.bam ENCFF244IZS.bam | head -n 5
chr1    605407    605585    Stringent(qval)    605571    605440    338    61
chr1    778535    778929    Stringent(qval)    778923    778637    81634    3276
chr1    826728    826910    Relaxed    826909    826732    443    135
chr1    827276    827351    Stringent(pval)    827301    827327    2834    69
chr1    827415    827791    Stringent(qval)    827699    827505    15242    1284

File formats this tool works with
BAM

Share your experience or ask a question