samtools-markdup(1) | Bioinformatics tools | samtools-markdup(1) |
samtools-markdup - mark duplicate alignments in a coordinate sorted file
samtools markdup [-l length] [-r] [-s] [-T] [-S] [-f file] [-d distance] [-c] [-t] [-m] [--mode] [--include-fails] [--no-PG] [-u] [--no-multi-dup] [--read-coords] [--coords-order] [--barcode-tag] [--barcode-name] [--barcode-rgx] in.algsort.bam out.bam
Mark duplicate alignments from a coordinate sorted file that has been run through samtools fixmate with the -m option. This program relies on the MC and ms tags that fixmate provides.
Entries are:
COMMAND: the command line.
READ: number of reads read in.
WRITTEN: reads written out.
EXCLUDED: reads ignored. See below.
EXAMINED: reads examined for duplication.
PAIRED: reads that are part of a pair.
SINGLE: reads that are not part of a pair.
DUPLICATE PAIR: reads in a duplicate pair.
DUPLICATE SINGLE: single read duplicates.
DUPLICATE PAIR OPTICAL: optical duplicate paired reads.
DUPLICATE SINGLE OPTICAL: optical duplicate single reads.
DUPLICATE NON PRIMARY: supplementary/secondary duplicate reads.
DUPLICATE NON PRIMARY OPTICAL: supplementary/secondary optical
duplicate reads.
DUPLICATE PRIMARY TOTAL: number of primary duplicate reads.
DUPLICATE TOTAL: total number of duplicate reads.
ESTIMATED LIBRARY SIZE: estimate of the number of unique fragments in
the sequencing library.
Estimated library size makes various assumptions e.g. the library consists of unique fragments that are randomly selected (with replacement) with equal probability. This is unlikely to be true in practice. However it can provide a useful guide into how many unique read pairs are likely to be available. In particular it can be used to determine how much more data might be obtained by further sequencing of the library.
Excluded reads are those marked as secondary, supplementary or unmapped. By default QC failed reads are also excluded but can be included as an option. Excluded reads are not used for calculating duplicates. They can optionally be marked as duplicates if they have a primary that is also a duplicate.
This first collate command can be omitted if the file is already name ordered or collated:
samtools collate -o namecollate.bam example.bam
Add ms and MC tags for markdup to use later:
samtools fixmate -m namecollate.bam fixmate.bam
Markdup needs position order:
samtools sort -o positionsort.bam fixmate.bam
Finally mark duplicates:
samtools markdup positionsort.bam markdup.bam
Typically the fixmate step would be applied immediately after sequence alignment and the markdup step after sorting by chromosome and position. Thus no additional sort steps are normally needed.
To use the regex to obtain coordinates from reads, two or three values have to be captured. To mimic the normal behaviour and match a read name of the format machine:run:flowcell:lane:tile:x:y use:
--read-coords '([!-9;-?A-~]+:[0-9]+:[0-9]+:[0-9]+:[0-9]+):([0-9]+):([0-9]+)' --coords-order txy
To match only the coordinates of x:y:randomstuff use:
--read-coords '^([[:digit:]]+):([[:digit:]]+)' --coords-order xy
It is possible that complex regular expressions may slow the running of the program. It would be best to keep them simple.
Written by Andrew Whitwham from the Sanger Institute.
samtools(1), samtools-sort(1), samtools-collate(1), samtools-fixmate(1)
Samtools website: <http://www.htslib.org/>
2 September 2022 | samtools-1.16.1 |