> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/clara/parabricks/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/clara/parabricks/_mcp/server.

# markdup

Mark duplicated reads in a BAM/CRAM file.

This tool locates and tags duplicate reads in a BAM or CRAM file, where duplicate
reads are defined as originating from a single fragment of DNA.

The input BAM/CRAM must be sorted by queryname. If it is not, run
Parabricks [bamsort](/tool-reference/tools/bamsort) with `--sort-order queryname` to preprocess the input file.
Input BAM/CRAMs must also have at least one read group line.

The behavior of GATK MarkDuplicates differs slightly based on whether its input
was coordinate or queryname sorted. By default, **markdup** matches the output
of GATK MarkDuplicates as if it were run with a coordinate-sorted BAM. When
using `--markdups-assume-sortorder-queryname`, **markdup** matches the
output of GATK MarkDuplicates as if it were run with a queryname-sorted BAM.

The Fasta reference input `--ref` is required for CRAM file support and BAM/CRAM header verification.

Refer to the [markdup Reference](#options) section for a detailed listing of all available options.

## Quick Start

```sh
# This command assumes all the inputs are in the current working directory and all the outputs go to the same place.
docker run --rm --gpus all --volume $(pwd):/workdir --volume $(pwd):/outputdir \
    --workdir /workdir \
    nvcr.io/nvidia/clara/clara-parabricks:4.7.1-1 \
    pbrun markdup \
    --ref /workdir/${REFERENCE_FILE} \
    --in-bam /workdir/${INPUT_BAM} \
    --out-bam /outputdir/${OUTPUT_BAM}
```

## Compatible Baseline Command

The commands below are the GATK counterparts of the Parabricks command above.
By default, **markdup** matches the coordinate sort order baseline;
however, note that Parabricks **markdup** requires a queryname sorted input.
Use the queryname sort order baseline if running with
`--markdups-assume-sortorder-queryname`. The `gatk SortSam` commands
are included to guarantee the input sort order for MarkDuplicates; they can be
skipped if your file is already in the correct order.

`Coordinate Sort Order`

```sh
gatk SortSam \
    -R <INPUT_DIR>/${REFERENCE_FILE} \
    -I <INPUT_DIR>/${INPUT_BAM} \
    -O <INPUT_DIR>/${SORTED_BAM} \
    -SO coordinate

gatk MarkDuplicates \
    -I <INPUT_DIR>/${SORTED_BAM} \
    -O <OUTPUT_DIR>/${MARKED_BAM} \
    -M <OUTPUT_DIR>/${METRICS_FILE} \
    -ASO coordinate
```

`Queryname Sort Order`

```sh
gatk SortSam \
    -R <INPUT_DIR>/${REFERENCE_FILE} \
    -I <INPUT_DIR>/${INPUT_BAM} \
    -O <INPUT_DIR>/${SORTED_BAM} \
    -SO queryname

gatk MarkDuplicates \
    -I <INPUT_DIR>/${SORTED_BAM} \
    -O <OUTPUT_DIR>/${MARKED_BAM} \
    -M <OUTPUT_DIR>/${METRICS_FILE} \
    -ASO queryname

gatk SortSam \
    -R <INPUT_DIR>/${REFERENCE_FILE} \
    -I <OUTPUT_DIR>/${MARKED_BAM} \
    -O <OUTPUT_DIR>/${FINAL_BAM} \
    -SO coordinate
```

## Options