> For the complete documentation index, see [llms.txt](https://documentation.dnanexus.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documentation.dnanexus.com/user/spark/vcf-preprocessing.md). Agents can also search and read this documentation through its [MCP server](https://documentation.dnanexus.com/~gitbook/mcp).

# VCF Preprocessing

Learn about preprocessing VCF data before using it in an analysis.

## Overview

It may be necessary to preprocess, or harmonize, the data before you load them.

## Harmonizing Data

* The raw data is expected to be a set of gVCF files -- one file per sample in the cohort.
* [GLnexus](https://github.com/dnanexus-rnd/GLnexus) is used to harmonize sites across all gVCFs and generate a single pVCF file containing all harmonized sites and all genotypes for all samples.

```mermaid
flowchart LR
    gvcf@{ shape: docs, label: "gVCF" }
    glx@{ shape: rounded, label: "GLnexus" }
    pvcf@{ shape: doc, label: "pVCF" }
    gvcf --> glx --> pvcf

    %% Styling
    classDef fileNode fill:#F6F7FA,stroke:#121249,stroke-width:2px,color:#121249
    classDef stageNode fill:#18ADF1,stroke:#121249,stroke-width:2px,color:#121249

    class gvcf,pvcf fileNode
    class glx stageNode
```

### Basic Run

```shell
dx run app-glnexus \
    -i common.gvcf_manifest=<manifest_file_id> \
    -i common.config=gatk_unfiltered \
    -i common.targets_bed=<bed_target_ranges>
```

### Advanced Run

```shell
dx run workflow-glnexus \
    -i common.gvcf_manifest=<manifest_file_id> \
    -i common.config=gatk_unfiltered \
    -i common.targets_bed=<bed_target_ranges> \
    -i unify.shards_bed=<bed_genomic_partition_ranges> \
    -i etl.shards=<num_sample_partitions>
```

{% hint style="success" %}
To learn more about GLnexus, see [GLnexus](https://github.com/dnanexus-rnd/GLnexus) or [Getting started with GLnexus](https://github.com/dnanexus-rnd/GLnexus/wiki/Getting-Started).
{% endhint %}

## Annotating Variants

VCF files can include variant annotations. SnpEff annotations provided as `INFO/ANN` tags are loaded into the database. You can annotate the harmonized pVCF yourself by running any standard SnpEff annotator before loading it. For large pVCFs, use the internal annotation step in the VCF Loader instead of generating an annotated intermediate file. The VCF Loader performs annotation in a distributed, massively parallel process.

The VCF Loader does not persist the intermediate, annotated pVCF as a file. If you want to have access to the annotated file up front, annotate it yourself.

```mermaid
flowchart LR
    in@{ shape: doc, label: "pVCF" }
    subgraph ext["<i>External Annotation Step</i>"]
        direction TB
        snpeff@{ shape: rounded, label: "snpeff" }
        identity@{ shape: rounded, label: "identity" }
    end
    mid@{ shape: doc, label: "pVCF" }
    subgraph int["<i>Internal Annotation Step</i>"]
        direction TB
        vla@{ shape: rounded, label: "vcf-loader + annotation" }
        vl@{ shape: rounded, label: "vcf-loader" }
    end
    db@{ shape: cyl, label: "db" }
    in -->|a| snpeff -->|a| mid
    in -.->|b| identity -.->|b| mid
    mid -.->|b| vla -.->|b| db
    mid -->|a| vl -->|a| db

    %% Styling
    classDef fileNode fill:#F6F7FA,stroke:#121249,stroke-width:2px,color:#121249
    classDef stageNode fill:#18ADF1,stroke:#121249,stroke-width:2px,color:#121249
    classDef pathBNode fill:#61BA00,stroke:#121249,stroke-width:2px,color:#121249
    classDef storeNode fill:#121249,stroke:#18ADF1,stroke-width:2px,color:#FFFFFF
    classDef workflowGroup fill:#F6F7FA,stroke:#121249,stroke-width:2px,color:#121249

    class in,mid fileNode
    class snpeff,vl stageNode
    class identity,vla pathBNode
    class db storeNode
    class ext,int workflowGroup
```

VCF annotation flows. In (a) the annotation step is external to the VCF Loader, whereas in (b) the annotation step is internal. In any case, SnpEff annotations present as `INFO/ANN` tags are loaded into the database by the VCF Loader.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://documentation.dnanexus.com/user/spark/vcf-preprocessing.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
