Annotate Variants with Google Genomics

The properly rendered version of this document can be found at Read The Docs.

If you are reading this on github, you should instead click here.

Variant annotation is a mechanism for finding and filtering interesting variants in a given variant set.

An annotated variant set might be used to identify variants which affect a gene of interest, or to highlight potential rare variants in an individual.

A Google Cloud Dataflow implementation is available.

Setup Dataflow

To launch the job from your local machine: Show/Hide Instructions

Most users launch Dataflow jobs from their local machine. This is unrelated to where the job itself actually runs (which is controlled by the --runner parameter). Either way, Java 8 is needed to run the Jar that kicks off the job.

  1. If you have not already done so, follow the Genomics Quickstart.
  2. If you have not already done so, follow the Dataflow Quickstart including installing gcloud and running gcloud init.
To launch the job from Google Cloud Shell: Show/Hide Instructions

If you do not have Java on your local machine, the following setup instructions will allow you to launch Dataflow jobs using the Google Cloud Shell:

  1. If you have not already done so, follow the Genomics Quickstart.
  2. If you have not already done so, follow the Dataflow Quickstart.
  3. Use the Cloud Console to activate the Google Cloud Shell.
  4. Run the following commands in the Cloud Shell to install Java 8.
sudo apt-get update
sudo apt-get install --assume-yes openjdk-8-jdk maven
sudo update-alternatives --config java
sudo update-alternatives --config javac


Depending on the pipeline, Cloud Shell may not not have sufficient memory to run the pipeline locally (e.g., without the --runner command line flag). If you get error java.lang.OutOfMemoryError: Java heap space, follow the instructions to run the pipeline using Compute Engine Dataflow workers instead of locally (e.g. use --runner=DataflowPipelineRunner).

If you want to run a small pipeline on your machine before running it in parallel on Compute Engine, you will need ALPN since many of these pipelines require it. When running locally, this must be provided on the boot classpath but when running on Compute Engine Dataflow workers this is already configured for you. You can download it from here. For example:

wget -O alpn-boot.jar \

Download the latest GoogleGenomics dataflow runnable jar from the Maven Central Repository. For example:

wget -O google-genomics-dataflow-runnable.jar \

Run the pipeline

The following command will use ClinVar to annotate variants on a portion of chromosome 17 within the Illumina Platinum Genomes dataset for individual NA12877.

Disclaimer: This program is currently intended to be a sample, and provides only a small subset of functionality found in most variant annotation programs. Pull requests are welcome!

java -Xbootclasspath/p:alpn-boot.jar \
  -cp google-genomics-dataflow-runnable.jar \ \
  --variantSetId=3049512673186936334 \
  --references=chr17:40700000:40800000 \
  --transcriptSetIds=CIjfoPXj9LqPlAEQ5vnql4KewYuSAQ \
  --variantAnnotationSetIds=CILSqfjtlY6tHxC0nNH-4cu-xlQ \
  --callSetIds=3049512673186936334-0 \

You can check your results by ensuring that the following three results are contained in the output files:

chr17:40714803:A:CI7s77ro84KpKhIFY2hyMTcYs4S1EyDwuoPB1PDR19AB: [{alternateBases=A, effect=NONSYNONYMOUS_SNP, geneId=ChYIiN-g9eP0uo-UARDi_aPt7qzv9twBEgIxNxjr_rQTIJrU8My-4_2UdA, transcriptIds=[ChYIiN-g9eP0uo-UARDm-eqXgp7Bi5IBEgIxNxjr_rQTII_53bW3_PSh6AE], type=SNP}]
chr17:40722028:G:CI7s77ro84KpKhIFY2hyMTcY7Ly1EyDvqeCryb2xrQw: [{alternateBases=G, effect=NONSYNONYMOUS_SNP, geneId=ChYIiN-g9eP0uo-UARDi_aPt7qzv9twBEgIxNxjlpbUTIL3v58KG8MzFJw, transcriptIds=[ChYIiN-g9eP0uo-UARDm-eqXgp7Bi5IBEgIxNxjlpbUTIMvX96zMvJyV0gE], type=SNP}]
chr17:40706905:A:CI7s77ro84KpKhIFY2hyMTcY2ca0EyCw4NnN8qzS8S0: [{alternateBases=A, effect=NONSYNONYMOUS_SNP, geneId=ChYIiN-g9eP0uo-UARDi_aPt7qzv9twBEgIxNxjvr7QTIITZ6M7yo8CnbA, transcriptIds=[ChYIiN-g9eP0uo-UARDm-eqXgp7Bi5IBEgIxNxjvr7QTINX5koLhyJHYkwE], type=SNP}]

The above command line runs the pipeline locally over a small portion of the genome, only taking a few minutes. If modified to run over a larger portion of the genome or the entire genome, it may take a few hours depending upon how many virtual machines are configured to run concurrently via --numWorkers. Add the following additional command line parameters to run the pipeline on Google Cloud instead of locally:

--runner=DataflowPipelineRunner \
--stagingLocation=gs://YOUR-BUCKET/dataflow-staging \

Use a comma-separated list to run over multiple disjoint regions. For example to run over BRCA1 and BRCA2 --references=chr13:32889610:32973808,chr17:41196311:41277499.

To run this pipeline over the entire genome, use --allReferences instead of --references=chr17:41196311:41277499.

Note that this program accepts VariantSets and AnnotationSets as input. The analogous inputs to traditional variant annotation programs are VCF and .csv files, respectively. To run the pipeline on a different VariantSet change the --variantSetId id parameter and:

  • update the --callSetIds parameter accordingly
  • see ClinVar Annotations if the variants were aligned to GRCh38 instead of GRCh37/hg19 and update --variantAnnotationSetIds
  • see UCSC Annotations if the variants were aligned to GRCh38 instead of GRCh37/hg19 and update --transcriptSetIds

Gather the results into a single file

gsutil cat gs://YOUR-BUCKET/output/platinum-genomes-brca1-clinvar-annotation.tsv* \
  | sort > platinum-genomes-brca1-clinvar-annotation.tsv

Additional details

If the Application Default Credentials are not sufficient, use --client-secrets PATH/TO/YOUR/client_secrets.json. If you do not already have this file, see the authentication instructions to obtain it.

Use --help to get more information about the command line options. Change the pipeline class name below to match the one you would like to run.

java -cp google-genomics-dataflow*runnable.jar \ --help

See the source code for implementation details:

Have feedback or corrections? All improvements to these docs are welcome! You can click on the “Edit on GitHub” link at the top right corner of this page or file an issue.

Need more help? Please see