> This page is for version v4.8.0 (default).
> For other versions, use one of these documentation indexes:
> - v4.8.0 (default): https://docs.nvidia.com/clara/parabricks/v4.8.0/llms.txt
> - v4.7.1: https://docs.nvidia.com/clara/parabricks/v4.7.1/llms.txt

> 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](/clara/parabricks/v4.8.0/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.8.0-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

| Type        | Name                                                                  | Required? | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| ----------- | --------------------------------------------------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| I/O         | `--in-bam IN_BAM`                                                     | Yes       | Path of BAM/CRAM for marking duplicate. Need to be sorted by queryname already. This option is required.                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| I/O         | `--out-bam OUT_BAM`                                                   | Yes       | Path of BAM/CRAM file after marking duplicate.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| I/O         | `--ref REF`                                                           | Yes       | Path to the reference file.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| I/O         | `--out-duplicate-metrics OUT_DUPLICATE_METRICS`                       | No        | Path of duplicate metrics file after marking duplicates.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| Tool        | `--markdups-assume-sortorder-queryname`                               | No        | Assume the reads are sorted by queryname for marking duplicates. This will mark secondary, supplementary, and unmapped reads as duplicates as well. This flag will not impact variant calling while increasing processing times.                                                                                                                                                                                                                                                                                                                            |
| Tool        | `--optical-duplicate-pixel-distance OPTICAL_DUPLICATE_PIXEL_DISTANCE` | No        | The maximum offset between two duplicate clusters in order to consider them optical duplicates.                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| Tool        | `--markdups-single-ended-start-end`                                   | No        | Mark duplicate on single-ended reads by 5' and 3' end.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| Tool        | `--ignore-rg-markdups-single-ended`                                   | No        | Ignore read group info in marking duplicates on single-ended reads. This option must be used with `--markdups-single-ended-start-end`.                                                                                                                                                                                                                                                                                                                                                                                                                      |
| Performance | `--num-zip-threads NUM_ZIP_THREADS`                                   | No        | Number of CPUs to use for zipping BAM/CRAM files in a run (default 10).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| Performance | `--num-worker-threads NUM_WORKER_THREADS`                             | No        | Number of CPUs to use for markdup in a run (default 10).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| Performance | `--mem-limit MEM_LIMIT`                                               | No        | Memory limit in GBs during sorting and postsorting. By default, the limit is 70% of the total system memory.                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| Performance | `--gpuwrite`                                                          | No        | Use one GPU to accelerate writing final BAM/CRAM.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| Performance | `--gpuwrite-deflate-algo GPUWRITE_DEFLATE_ALGO`                       | No        | Choose the nvCOMP DEFLATE algorithm to use with --gpuwrite. Note these options do not correspond to CPU DEFLATE options. Valid options are 1, 2, and 4. Option 1 is fastest, while options 2 and 4 have progressively lower throughput but higher compression ratios. The default value is 1 when the user does not provide an input (i.e., None)                                                                                                                                                                                                           |
| Performance | `--gpusort`                                                           | No        | Use GPUs to accelerate sorting and marking.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| Runtime     | `--verbose`                                                           | No        | Enable verbose output.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| Runtime     | `--x3`                                                                | No        | Show full command line arguments.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| Runtime     | `--dry-run`                                                           | No        | Check if the current command is valid.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| Runtime     | `--logfile LOGFILE`                                                   | No        | Path to the log file. If not specified, messages will only be written to the standard error output.                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| Runtime     | `--tmp-dir TMP_DIR`                                                   | No        | Full path to the directory where temporary files will be stored. (default: .)                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| Runtime     | `--with-petagene-dir WITH_PETAGENE_DIR`                               | No        | Full path to the PetaGene installation directory. By default, this should have been installed at /opt/petagene. Use of this option also requires that the PetaLink library has been preloaded by setting the LD_PRELOAD environment variable. Optionally set the PETASUITE_REFPATH and PGCLOUD_CREDPATH environment variables that are used for data and credentials. Optionally set the PetaLinkMode environment variable that is used to further configure PetaLink, notably setting it to "+write" to enable outputting compressed BAM and .fastq files. |
| Runtime     | `--keep-tmp`                                                          | No        | Do not delete the directory storing temporary files after completion.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| Runtime     | `--no-seccomp-override`                                               | No        | Do not override seccomp options for docker.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| Runtime     | `--version`                                                           | No        | View compatible software versions.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| Runtime     | `--preserve-file-symlinks`                                            | No        | Override default behavior to keep file symlinks intact and *not* resolve the symlink.                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| Runtime     | `--help-json`                                                         | No        | Print out help message in JSON format.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |