Skip to content

Annotation

A VCF tells you where the sample differs from the reference. Annotation tells you what each difference does to the genes around it, whether it falls in an intron, changes an amino acid or sits between genes. Sarek ran SnpEff on the filtered HaplotypeCaller VCF. This page decodes one of its records by hand, then parses all of them in R and Python to ask which genes the region holds and which calls touch a protein.

SnpEff writes its version and command line into the VCF header, and a statistics file beside the VCF.

The HG002 inputs come from NIST and the Genome in a Bottle consortium. The preparation on October 29, 2026 selects the chromosome 20 interval, subsets the GIAB v4.2.1 benchmark, and produces fresh analysis outputs. The source and terms notice identifies the original sequencing and benchmark publications, the exact source files, and the changes. It also records the grants for the Broad reference bundle and Ensembl release 99 annotation.

Terminal window
ann_dir=/opt/data/annotation/haplotypecaller
vcf="$ann_dir/HG002.haplotypecaller.filtered_snpEff.ann.vcf.gz"
csv="$ann_dir/HG002.haplotypecaller.filtered_snpEff.csv"
bcftools view -h "$vcf" | grep '^##SnpEff'
grep -E '^(Genome |Number_of_(lines|variants|effects))' "$csv"
for section in 'Change rate by chromosome' 'Effects by impact'; do
echo "# $section"
awk -v title="# $section" \
'$0 ~ "^" title {show = 1; next} /^#/ {show = 0} show && NF' "$csv"
done
##SnpEffVersion="5.4c (build 2026-02-23 07:25), by Pablo Cingolani"
##SnpEffCmd="SnpEff GRCh38.99 -csvStats HG002.haplotypecaller.filtered_snpEff.csv HG002.haplotypecaller.filtered.vcf.gz "
Genome , GRCh38.99
Number_of_lines_in_input_file, 1807
Number_of_variants_before_filter, 1857
Number_of_variants_processed , 1846
Number_of_effects , 2842
# Change rate by chromosome
Chromosome , Length , Changes , Change_rate
20 , 64444167 , 1846 , 34910
# Effects by impact
Type , Count , Percent
LOW , 5 , 0.175932%
MODERATE , 1 , 0.035186%
MODIFIER , 2836 , 99.788881%

The database is GRCh38.99, built from Ensembl release 99. Ensembl names the chromosome 20 and the GATK reference names it chr20, and SnpEff matched the two: all 1,846 changes land on chromosome 20. A failed match fills the last subfield of each annotation with ERROR_CHROMOSOME_NOT_FOUND, an error the SnpEff documentation ties to chromosome names that differ between input and database. The parsing code below lists every message in the file, and none is an error.

The input had 1,807 lines and 1,857 ALT alleles, because 50 records carry two, and SnpEff processed 1,846 alleles. The 11 it skipped match the 11 spanning deletion alleles written as *, which mark a position covered by a deletion called upstream and carry no sequence of their own.

Terminal window
vcf=/opt/data/annotation/haplotypecaller/HG002.haplotypecaller.filtered_snpEff.ann.vcf.gz
multi=$(bcftools view -H -i 'N_ALT>1' "$vcf" | wc -l)
star=$(bcftools query -f '%ALT\n' "$vcf" | tr ',' '\n' | grep -c '^\*$')
echo "records with more than one ALT allele: $multi"
echo "spanning deletion alleles: $star"
records with more than one ALT allele: 50
spanning deletion alleles: 11

The impact table counts effects, 2,842 of them for 1,807 records, so it does not say how many of your variants change a protein. The R and Python tabs below answer that.

SnpEff adds one INFO key, ANN, and its header line names the 16 subfields in order. The block below pairs those names with the values of rs6077853, a heterozygous G to A change at 10,623,102.

Terminal window
vcf=/opt/data/annotation/haplotypecaller/HG002.haplotypecaller.filtered_snpEff.ann.vcf.gz
bcftools view -h "$vcf" \
| grep '^##INFO=<ID=ANN' \
| sed "s/.*annotations: '//; s/' *\">$//" \
| tr '|' '\n' \
| sed 's/^ *//; s/ *$//' > fields.txt
bcftools query -r chr20:10623102 -f '%INFO/ANN\n' "$vcf" \
| tr '|' '\n' > values.txt
bcftools query -r chr20:10623102 -f '%CHROM:%POS %ID %REF>%ALT [%GT]\n' "$vcf"
paste fields.txt values.txt | awk -F'\t' '{printf "%2d %-26s %s\n", NR, $1, $2}'
chr20:10623102 rs6077853 G>A 0/1
1 Allele A
2 Annotation missense_variant
3 Annotation_Impact MODERATE
4 Gene_Name SLX4IP
5 Gene_ID ENSG00000149346
6 Feature_Type transcript
7 Feature_ID ENST00000334534.10
8 Transcript_BioType protein_coding
9 Rank 8/8
10 HGVS.c c.950G>A
11 HGVS.p p.Arg317Gln
12 cDNA.pos / cDNA.length 1128/6056
13 CDS.pos / CDS.length 950/1227
14 AA.pos / AA.length 317/408
15 Distance
16 ERRORS / WARNINGS / INFO

The ALT allele A makes a missense_variant, rated MODERATE, in exon 8 of 8 of the SLX4IP transcript ENST00000334534.10. The two HGVS strings give the same change at two levels: base 950 of the coding sequence goes from G to A, and residue 317 of a 408 residue protein goes from arginine to glutamine. The last two subfields are empty, because a variant inside a transcript has no distance to report and SnpEff raised no message.

This record has one entry, and many have several, separated by commas. SnpEff writes an entry for each ALT allele and each feature the allele overlaps or lies within 5 kb of, which is where upstream and downstream entries come from. The subfields follow the ANN specification that the authors of SnpEff, Ensembl VEP and ANNOVAR wrote together in 2015. SnpEff sorts the entries by impact, then by how damaging the effect is, then canonical transcripts first, then by position, so the first entry should be the most severe. The parsing code checks that rather than trusting it.

The Annotation subfield holds a term from the Sequence Ontology, the controlled vocabulary of Eilbeck et al. 2005, so missense_variant means the same thing in SnpEff, in Ensembl VEP and in a ClinVar record. Two terms joined by & mean that both apply. The Annotation_Impact subfield sorts every term into one of four classes, and the SnpEff documentation defines them in these words.

The impact descriptions below are excerpts from Pablo Cingolani’s SnpEff documentation, copyright 2021 Pablo Cingolani under the MIT license. This table shortens the descriptions and selects example terms for the lesson. The linked notice preserves the complete permission conditions and disclaimer.

Impact SnpEff definition Example terms
HIGH assumed to have high (disruptive) impact in the protein stop_gained, frameshift_variant
MODERATE a non-disruptive variant that might change protein effectiveness missense_variant, inframe_deletion
LOW assumed to be mostly harmless or unlikely to change protein behavior synonymous_variant, splice_region_variant
MODIFIER usually non-coding variants or variants affecting non-coding genes intron_variant, upstream_gene_variant

The classes are a filter, not a verdict. The same documentation warns that they exist to simplify filtering, and that a HIGH or a LOW class says nothing certain about a phenotype.

Both tabs keep the PASS records, split every ANN entry on | into the 16 subfields the header names, and take the most severe entry of each record. In VariantAnnotation, info(vcf)$ANN returns a character vector of entries per record. In cyvcf2 the same key returns one string to split on commas.

suppressPackageStartupMessages({
library(VariantAnnotation)
library(dplyr)
})
ann_path <- file.path(
"/opt/data/annotation/haplotypecaller",
"HG002.haplotypecaller.filtered_snpEff.ann.vcf.gz"
)
impact_levels <- c("HIGH", "MODERATE", "LOW", "MODIFIER")
ann_vcf <- readVcf(
ann_path, "hg38",
param = ScanVcfParam(info = "ANN", geno = "GT")
)
print(table(filt(ann_vcf)))
ann_vcf <- ann_vcf[filt(ann_vcf) == "PASS"]
# The ANN header line names the subfields, separated by "|".
ann_description <- info(header(ann_vcf))["ANN", "Description"]
ann_fields <- sub("'.*$", "", sub("^[^']*'", "", ann_description))
ann_fields <- trimws(strsplit(ann_fields, "|", fixed = TRUE)[[1]])
ann_text <- info(ann_vcf)$ANN
n_entries <- lengths(ann_text)
entries <- read.delim(
text = unlist(ann_text), sep = "|", header = FALSE,
col.names = make.names(ann_fields), colClasses = "character",
quote = "", comment.char = ""
)
messages <- entries[[length(ann_fields)]]
entries$record <- rep(seq_along(n_entries), n_entries)
entries$entry <- sequence(n_entries)
entries$impact_rank <- match(entries$Annotation_Impact, impact_levels)
most_severe <- entries |>
arrange(record, impact_rank, entry) |>
distinct(record, .keep_all = TRUE)
cat("subfields:", length(ann_fields), "\n")
cat("PASS records:", length(n_entries), "\n")
cat("ANN entries:", nrow(entries), "\n")
cat("records whose most severe entry is not the first:",
sum(most_severe$entry != 1), "\n")
cat("messages in the last subfield:\n")
print(table(messages[messages != ""]))
cat("\n")
impact_counts <- most_severe |>
count(impact = factor(Annotation_Impact, impact_levels), .drop = FALSE)
print(as.data.frame(impact_counts), row.names = FALSE)
cat("\n")
effect_counts <- most_severe |>
count(effect = Annotation, sort = TRUE)
print(as.data.frame(effect_counts), row.names = FALSE)
CNN_1D_INDEL_Tranche_99.40_100.00 CNN_1D_SNP_Tranche_99.95_100.00
7 5
PASS
1795
subfields: 16
PASS records: 1795
ANN entries: 2822
records whose most severe entry is not the first: 0
messages in the last subfield:
INFO_REALIGN_3_PRIME
189
impact n
HIGH 0
MODERATE 1
LOW 5
MODIFIER 1789
effect n
intron_variant 798
intragenic_variant 481
upstream_gene_variant 219
downstream_gene_variant 214
intergenic_region 52
3_prime_UTR_variant 16
non_coding_transcript_exon_variant 6
synonymous_variant 4
5_prime_UTR_variant 3
missense_variant 1
splice_region_variant&non_coding_transcript_exon_variant 1

The two tabs print the same counts. Dropping the 12 records that FilterVariantTranches marked leaves 1,795 PASS records with 2,822 entries. No record had its most severe entry anywhere but first, so SnpEff’s sort order holds in this file.

Counted once per variant, 1,789 of the 1,795 records rise no higher than MODIFIER, the class for introns, flanks, untranslated regions and non-coding genes, and 6 reach LOW or MODERATE. The SnpEff statistics reported 2,836 MODIFIER effects for the same file. Both numbers are right, but only the per variant count belongs in a sentence that starts “we found N variants”.

For each gene named in an entry, the tabs count the PASS records with at least one entry on that gene. A variant inside one gene and upstream of another counts once for each. The intergenic_region entries name the two flanking genes and are left out.

gene_table <- entries |>
filter(Feature_Type != "intergenic_region") |>
group_by(gene = Gene_Name) |>
summarise(
biotype = first(Transcript_BioType[Feature_Type == "transcript"]),
transcripts = n_distinct(Feature_ID[Feature_Type == "transcript"]),
variants = n_distinct(record),
top_impact = impact_levels[min(impact_rank)],
.groups = "drop"
) |>
mutate(biotype = coalesce(biotype, "none")) |>
arrange(desc(variants), gene)
cat("genes:", nrow(gene_table), "\n")
print(as.data.frame(gene_table), row.names = FALSE)
genes: 25
gene biotype transcripts variants top_impact
SNAP25-AS1 pseudogene 1 688 MODIFIER
AL050403.2 pseudogene 1 466 MODIFIER
SLX4IP protein_coding 1 458 MODERATE
ANKEF1 protein_coding 1 193 LOW
SNAP25 protein_coding 1 77 MODIFIER
AL050403.1 pseudogene 1 72 MODIFIER
LINC01752 pseudogene 1 72 LOW
AL135937.1 pseudogene 1 71 MODIFIER
AL354824.1 pseudogene 1 69 MODIFIER
AL109754.1 misc_RNA 1 68 MODIFIER
JAG1 protein_coding 1 56 LOW
SDAD1P2 processed_pseudogene 1 50 MODIFIER
AL354824.2 pseudogene 1 38 MODIFIER
MKKS protein_coding 1 27 MODIFIER
PARAL1 pseudogene 1 26 MODIFIER
AL034430.1 protein_coding 1 21 MODIFIER
C20orf187 pseudogene 1 21 MODIFIER
HIGD1AP15 processed_pseudogene 1 18 MODIFIER
AL035456.1 processed_pseudogene 1 15 MODIFIER
AL158042.1 pseudogene 1 14 MODIFIER
FAT1P1 processed_pseudogene 1 14 MODIFIER
AL023913.1 pseudogene 1 13 MODIFIER
RPL23AP6 processed_pseudogene 1 13 MODIFIER
AL034430.2 protein_coding 1 4 MODIFIER
MIR6870 miRNA 1 3 MODIFIER

The region holds 25 genes. Seven carry the label protein_coding: SLX4IP, ANKEF1, SNAP25, JAG1, MKKS and two Ensembl genes without a symbol, AL034430.1 and AL034430.2. SNAP25-AS1 tops the table with 688 records, against 458 for SLX4IP, the protein coding gene with the most.

Two columns deserve a second look. The transcripts column reads 1 for every gene, because sarek runs SnpEff with -canon, which keeps one canonical transcript per gene, as its module configuration shows. SnpEff writes intragenic_variant when a variant falls inside a gene but outside the transcript it kept, which is the most severe term for 481 records. The biotype column is the database’s label, not a fact about the gene. LINC01752 has an HGNC symbol for a long intergenic non-coding RNA and carries the label pseudogene here, so check a gene in Ensembl before an argument rests on its biotype.

The variants that touch a protein are the entries SnpEff did not class as MODIFIER.

coding <- entries |>
filter(Annotation_Impact != "MODIFIER") |>
mutate(
pos = start(ann_vcf)[record],
id = names(ann_vcf)[record],
gt = geno(ann_vcf)$GT[record, 1]
) |>
select(
pos, id, gt, gene = Gene_Name, impact = Annotation_Impact,
hgvs_c = HGVS.c, hgvs_p = HGVS.p, effect = Annotation
)
# A wider console keeps the table on one line per row.
options(width = 130)
cat("HIGH entries:", sum(entries$Annotation_Impact == "HIGH"), "\n")
print(as.data.frame(coding), row.names = FALSE)
# The gate compares these counts with the Python tab.
parity_metrics <- c(
pass_records = length(n_entries),
ann_entries = nrow(entries),
not_first = sum(most_severe$entry != 1),
setNames(impact_counts$n, paste0("impact_", impact_counts$impact)),
setNames(effect_counts$n, paste0("effect_", effect_counts$effect)),
genes = nrow(gene_table),
gene_records = sum(gene_table$variants),
coding_entries = nrow(coding)
)
dir.create("outputs", showWarnings = FALSE)
jsonlite::write_json(
as.list(parity_metrics), "outputs/annotation_counts_r.json",
auto_unbox = TRUE
)
HIGH entries: 0
pos id gt gene impact hgvs_c hgvs_p effect
10038445 rs575534 1/1 ANKEF1 LOW c.144A>G p.Gly48Gly synonymous_variant
10623102 rs6077853 0/1 SLX4IP MODERATE c.950G>A p.Arg317Gln missense_variant
10639627 rs1051421 0/1 JAG1 LOW c.3528C>T p.Tyr1176Tyr synonymous_variant
10639738 rs1051419 0/1 JAG1 LOW c.3417T>C p.Tyr1139Tyr synonymous_variant
10652589 rs1131695 1/1 JAG1 LOW c.765C>T p.Tyr255Tyr synonymous_variant
10754025 rs8125313 0/1 LINC01752 LOW n.853C>T splice_region_variant&non_coding_transcript_exon_variant

No entry in the region is HIGH. The single missense change is the SLX4IP record decoded above, and four entries are synonymous, three in JAG1 and one in ANKEF1. SnpEff writes those as p.Tyr255Tyr where HGVS prefers p.(=), because the ANN specification treats = as illegal in a VCF. The sixth is a splice region change in the LINC01752 transcript, which codes for no protein, so its HGVS.p is empty. All six carry a dbSNP ID, which HaplotypeCaller copied from the --dbsnp file.

SnpEff predicts what a change does to a transcript model, not whether it matters for a person. The MODERATE class on the SLX4IP change is a statement about one codon, and it would be the same if half the population carried the allele. Clinical laboratories classify variants with the ACMG and AMP guidelines of Richards et al. 2015, which weigh population frequency, computational predictions, functional studies and segregation together.

A dbSNP ID only says that someone has reported the variant before. gnomAD, described in Karczewski et al. 2020, gives allele frequencies across large population samples, and a variant common in gnomAD is unlikely to cause a rare disease. ClinVar, described by Landrum et al., holds the clinical assertions that laboratories submit.

Sarek can add these layers, and this section does not run them. --tools vep runs Ensembl VEP, and --tools merge runs VEP after SnpEff on the same VCF. The VEP plugins for dbNSFP scores, SpliceAI and LOFTEE have their own switches, --vep_dbnsfp, --vep_spliceai and --vep_loftee, and --tools snpsift copies INFO fields from VCF databases such as gnomAD or ClinVar through --snpsift_databases. The parameter list gives the files each one needs.

  • The VCF and the database disagree on the build or the chromosome names. SnpEff flags part of the damage with ERROR_CHROMOSOME_NOT_FOUND, ERROR_OUT_OF_CHROMOSOME_RANGE for a position past a chromosome end, and WARNING_REF_DOES_NOT_MATCH_GENOME, so count the messages as the tabs above do.
  • The most severe entry sits on a transcript that no report would quote. The MANE Select set names one agreed transcript per protein coding gene. SnpEff’s -canon option, which this run used, and its -canonList option restrict the annotation to one transcript per gene.
  • An indel moves. The 189 INFO_REALIGN_3_PRIME messages in the PASS records mark indels that SnpEff shifted to their most 3 prime position, as HGVS requires, so the HGVS.c position can differ from the VCF POS.
  • The database version goes unrecorded. The same VCF annotated against a later Ensembl release can gain or lose genes, transcripts and consequences, so keep the ##SnpEffCmd line with the results.

The code for this page is in guides/dnaseq/annotation/ of the companion repository. The next page, Visualization, turns the four call sets into the figures a results section expects.

Danecek and colleagues, 2021 describe the development and the current features of SAMtools and BCFtools.

Obenchain and colleagues, 2014 describe VariantAnnotation, the Bioconductor package for the exploration and annotation of genetic variants.

The SnpEff input and output reference defines ANN subfields, multiple effects, and impact classes. It separates predicted transcript consequences from clinical interpretation.

The Sarek 3.11.0 annotation configuration records the SnpEff options selected by the pipeline. These options matter when comparing reported transcript consequences.