# Variant track

A variant track displays VCF records, one glyph per call, and a click opens a
per-sample genotype table. The track menu's **Display types** switches to a
multi-sample view (one row per sample), an LD heatmap, or a paired-arc view for
breakends. **Color by...** buckets variants by SnpEff/VEP consequence severity
or SV type with one click, or colors by any INFO field via a jexl expression
(e.g. minor allele frequency).

<Figure caption="Variant track marking an SNV beside the alignment track evidence." src="/img/variant_with_pileup.png" />

## Display types

In a linear genome view, the track menu's **Display types** switches between:

- **Variant display**, the default, covered on this page
- **Multi-sample variant display** draws one row per sample, each variant at its
  genomic position, or, with **Show... → Show as genotype matrix**, in
  equal-width columns so shared haplotypes and runs of homozygosity show
  whatever the spacing. See the
  [multi-sample variant guide](https://jbrowse.org/jb2/docs/user_guides/multivariant_track)
- **Marks** draws the variants as the marks you configure, and over an SV VCF
  joins each breakend to its mate with nothing configured. See
  [links](https://jbrowse.org/jb2/docs/config_guides/mark_display#links)

For an LD heatmap, run PLINK over the genotypes and load its pairwise r² output
as a separate track, as in the
[linkage disequilibrium tutorial](https://jbrowse.org/jb2/docs/tutorials/ld_human).

In a [circular view](https://jbrowse.org/jb2/docs/user_guides/circular_view) the same track gives a
chord display, drawing breakends as chords across the ring.

## Variant widget

Clicking a variant opens a widget with a per-sample genotype table.

<Figure caption="Feature details panel for an SNV (C→T), with a per-sample genotype table in the SAMPLES section." src="/img/variant_panel.png" />

The SAMPLES section lists every sample's genotype (GT) and other per-sample
fields, with a plain-text or regex filter box per column. Typing '1' in the
genotype filter keeps only samples with the first alternate allele (0|1 or 1|1).
The [1000 Genomes SV tutorial](https://jbrowse.org/jb2/docs/tutorials/sv_multisamples) filters a trio's
genotypes this way to check whether a call is inherited.

## Coloring variants

**Color by...** in the track menu:

- **Consequence impact** buckets each variant by the severity of its most severe
  predicted consequence, read from SnpEff `ANN` or VEP `CSQ` in the INFO field:
  HIGH red, MODERATE orange, LOW yellow, MODIFIER grey
- **SV type** colors by structural-variant class, with fixed colors per class
  and an ascending rainbow for copy-number alleles (`<CN0>`, `<CN1>`, ...)
- **Attribute...** takes a field name and colors by its value, one palette color
  per value, with a key: a record field such as `type` or `FILTER`, or a path
  into INFO such as `INFO.SVCLASS`

The presets draw a dismissable color key naming the classes present, and work on
the multi-sample displays too, where
[consequence impact](https://jbrowse.org/jb2/docs/user_guides/multivariant_track#coloring-by-consequence-impact-snpeffvep-annotations)
and [SV type](https://jbrowse.org/jb2/docs/user_guides/multivariant_track#coloring-by-sv-type) list the
terms in each tier and the color per class.

For anything else, set the display's `color` slot to a
[jexl](https://jbrowse.org/jb2/docs/config_guides/jexl) expression. The variants plugin registers
helpers for minor allele frequency, missingness and consequence impact; see
[helper functions for jexl color expressions](https://jbrowse.org/jb2/docs/config_guides/variant_track#helper-functions-for-jexl-color-expressions).

## See also

- **User guide:** [Multi-sample variant display](https://jbrowse.org/jb2/docs/user_guides/multivariant_track)
- **User guide:** [Structural variant visualization](https://jbrowse.org/jb2/docs/user_guides/sv_visualization)
- **User guide:** [Alignments track](https://jbrowse.org/jb2/docs/user_guides/alignments_track)
- **User guide:** [GWAS / Manhattan track](https://jbrowse.org/jb2/docs/user_guides/gwas_track)
- **Config guide:** [Variant track configuration](https://jbrowse.org/jb2/docs/config_guides/variant_track)
- **Config guide:** [Customizing feature colors](https://jbrowse.org/jb2/docs/config_guides/customizing_feature_colors)
