> 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).

# 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.

![Apollo GLnexus](https://3410363935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS1s2UHuAFgrsxnijuHMc%2Fuploads%2Fgit-blob-30495acb8d56811daa26d8cca9182e40a20bb942%2Fapollo-glnexus.png?alt=media)

### 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.

![Annotation flow](https://3410363935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FS1s2UHuAFgrsxnijuHMc%2Fuploads%2Fgit-blob-ea9cc03ee6adf2cc84f78bed3d31c36227bace51%2Fapollo-annotation-flows.png?alt=media)

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.
