# Pangenome (cattle)

:::caution JBrowse v5 beta

The tutorials target the JBrowse v5 beta, and the v4.3.0 release
on the [download page](https://jbrowse.org/jb2/download/) lacks some of what they show. To install the
beta of JBrowse Web, run `npm install -g @jbrowse/cli@next`, then
`jbrowse create jbrowse2 --branch v5.0.0-beta.21`. Desktop beta builds for Linux and
macOS are on the [releases page](https://github.com/GMOD/jbrowse-components/releases);
the Windows build waits on code signing.

:::

The bovine super-pangenome is one graph of a set of assemblies on the ARS-UCD1.2
cattle reference, a Hereford that is itself one of them: taurine and indicine
breeds, yak, bison and gaur. Each assembly is a named path through the graph,
and `vg deconstruct` turns those paths into a VCF, so JBrowse can show one locus
both as a graph of where sequence is present and absent and as a callset listing
which assemblies have it. We:

- load the graph as a graph track, and open a whole chromosome with small
  variants folded
- at _HSPA1A_, load the deconstructed callset as a variant track with one row
  per assembly, over the graph track
- add OMIA's curated variants as a track, and read three published breed and
  species variants in the callset

Every step starts from the graph's page on
[genomes.jbrowse.org](https://genomes.jbrowse.org/pangenomes/bovine), which
launches the JBrowse 5 development build until JBrowse 5 ships.

:::caution Experimental

The graph view is a beta plugin. We welcome your [feedback](https://jbrowse.org/jb2/contact).

:::

## Prerequisites

- the GraphGenomeView plugin, for the `GraphTrack` below. In your own JBrowse,
  [install it from the plugin store](https://jbrowse.org/jb2/docs/user_guides/plugin_store); the
  [portal page](https://genomes.jbrowse.org/pangenomes/bovine) already loads it
- `python3` and htslib (`bgzip`, `tabix`), to build the
  [OMIA track](#the-celtic-polled-allele)
- [`vg`](https://github.com/vgteam/vg), to
  [deconstruct](#hspa1a-in-the-graph-and-the-callset) the graph into a callset

<!-- BEGIN GENERATED TUTORIAL_INSTALL htslib,vg -->

```bash
# Debian/Ubuntu
sudo apt install tabix
# or conda, which has every tool above
conda install -c bioconda -c conda-forge htslib vg
```

<!-- END GENERATED TUTORIAL_INSTALL htslib,vg -->

## The data

The graph tracks read the hosted files by URL, and the OMIA track reads a file
you build from OMIA's dump with
[the script under The Celtic polled allele](#the-celtic-polled-allele). For a
graph of your own, swap the prefix in `uri` for your `gfa-to-tabix build`, as
[Load the genome and the graph](#load-the-genome-and-the-graph) shows.

| What it is                                                    | File                                               |
| ------------------------------------------------------------- | -------------------------------------------------- |
| OMIA's database dump, the source of the curated variant track | [omia.sql.gz](https://omia.org/static/omia.sql.gz) |

<details>
<summary>Read by URL (no download needed)</summary>

| What it is                                                                                   | File                                                                                                                                            |
| -------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| The segment and link index                                                                   | [bovine-arsucd12-minigraph.graph.bed.gz](https://jbrowse.org/demos/bovine_pangenome/bovine-arsucd12-minigraph.graph.bed.gz)                     |
| The bubble index, where assemblies' paths split and rejoin                                   | [bovine-arsucd12-minigraph.bubbles.bed.gz](https://jbrowse.org/demos/bovine_pangenome/bovine-arsucd12-minigraph.bubbles.bed.gz)                 |
| The overview used for whole chromosomes, with variants under 10 kb folded into the reference | [bovine-arsucd12-minigraph.fold10000.graph.bed.gz](https://jbrowse.org/demos/bovine_pangenome/bovine-arsucd12-minigraph.fold10000.graph.bed.gz) |

</details>

## Load the genome and the graph

We'll load the reference the graph is anchored to, then the graph track. Swap
the prefix in `uri` for your own `gfa-to-tabix build`, which writes the
tabix-indexed segments and links and the overview.

```json
{
  "name": "bosTau9",
  "aliases": ["ARS-UCD1.2"],
  "uri": "https://hgdownload.soe.ucsc.edu/goldenPath/bosTau9/bigZips/bosTau9.2bit",
  "refNameAliases": {
    "uri": "https://jbrowse.org/ucsc/bosTau9/bosTau9.chromAlias.txt"
  }
}
```

CLI:

```bash
jbrowse add-assembly https://hgdownload.soe.ucsc.edu/goldenPath/bosTau9/bigZips/bosTau9.2bit \
  --name bosTau9 \
  --alias ARS-UCD1.2 \
  --refNameAliases https://jbrowse.org/ucsc/bosTau9/bosTau9.chromAlias.txt
```

```json
{
  "type": "GraphTrack",
  "trackId": "bovine_minigraph_segments",
  "name": "Bovine super-pangenome (rGFA segments)",
  "assemblyNames": ["bosTau9"],
  "adapter": {
    "type": "RgfaTabixAdapter",
    "uri": "https://jbrowse.org/demos/bovine_pangenome/bovine-arsucd12-minigraph",
    "format": 2,
    "coarse": {
      "uri": "https://jbrowse.org/demos/bovine_pangenome/bovine-arsucd12-minigraph.fold10000",
      "format": 2,
      "aboveBpPerPx": 1000
    }
  },
  "displays": [
    { "type": "LinearGraphDisplay" },
    { "type": "LinearBasicDisplay" }
  ]
}
```

CLI:

```bash
jbrowse add-track-json '{
  "type": "GraphTrack",
  "trackId": "bovine_minigraph_segments",
  "name": "Bovine super-pangenome (rGFA segments)",
  "assemblyNames": ["bosTau9"],
  "adapter": {
    "type": "RgfaTabixAdapter",
    "uri": "https://jbrowse.org/demos/bovine_pangenome/bovine-arsucd12-minigraph",
    "format": 2,
    "coarse": {
      "uri": "https://jbrowse.org/demos/bovine_pangenome/bovine-arsucd12-minigraph.fold10000",
      "format": 2,
      "aboveBpPerPx": 1000
    }
  },
  "displays": [
    { "type": "LinearGraphDisplay" },
    { "type": "LinearBasicDisplay" }
  ]
}'
```

## Overview of chr23 with small variants folded {#overview-of-chr23-with-one-node-per-variant-region}

Open
[chr23 on the portal page](https://genomes.jbrowse.org/pangenomes/bovine/?region=chr23)
and press **Open in JBrowse**. The whole chromosome opens with the graph's
coarse tier, which folds every variant under 10 kb into the reference.

<Figure caption="Chromosome 23 with RefSeq genes, segments per bubble as a curve, and the graph with variants under 10 kb folded into the reference." src="/img/pangenome/bovine_whole_chromosome.png" />

Session spec, on config <https://jbrowse.org/code/jb2/main/test_data/graphgenomeview/pangenome_nonhuman.json>:

```json
{
  "views": [
    {
      "type": "LinearGenomeView",
      "id": "bovine-chr23-lgv",
      "assembly": "bosTau9",
      "loc": "chr23",
      "tracks": [
        "bosTau9_ncbiRefSeq_ucsc",
        "bovine_bubble_score",
        {
          "trackId": "bovine_minigraph_tier",
          "type": "LinearBasicDisplay",
          "labels": {
            "name": {
              "show": false
            },
            "description": {
              "show": false
            }
          },
          "height": 60
        }
      ]
    }
  ]
}
```

BoLA, the cattle major histocompatibility complex (immune genes that vary a lot
between breeds), contains the heat shock gene _HSPA1A_, the subject of the next
section.

## HSPA1A in the graph and the callset

ARS-UCD1.2 lacks an 11 kb segment beside the heat shock gene _HSPA1A_, which
contains _HSPA1B_, its near-identical copy. Leonard et al. (2022) recovered it
in every assembly they built. The **graph** draws that segment as a loop off the
reference.

The **callset** gives a genotype per assembly. We ran `vg deconstruct` once per
chromosome over the same graph:

<!-- from: scripts/build_bovine_pangenome.sh -->

```bash
# rename the reference path (HER, Hereford) to the assembly's refName, so
# deconstruct writes CHROM as chr1
awk -F'\t' -v OFS='\t' '$1 == "P" && $2 == "HER" { $2 = "chr1" } { print }' \
  1.gfa > chr1.gfa
# -p: vg's PackedGraph format, which deconstruct reads
vg convert -g chr1.gfa -p > chr1.vg
# -p: the reference path to decompose against
# -a: nested snarls too, so a bubble inside a bubble gets a record
vg deconstruct -p chr1 -a -t 8 chr1.vg > chr1.vcf
```

The VCF's CHROM column is the `-p` path name, which has to equal the assembly's
refName. Its sample names are the three-letter codes on each assembly's path,
and the sample table's first column has to match them. A mismatch leaves the row
unlabelled and raises no error:

```text
name	breed	lineage
ANG	Angus	taurine
BIS	Bison	bison
```

In [grammar-of-graphics](https://jbrowse.org/jb2/docs/config_guides/mark_display) terms, `rows.color`
in the track config is a color scale on each row's label bar, mapping the sample
table's `lineage` column through `domain` to `range`. The config also sets:

- `rows.sort` lists the cattle breeds above the wild species, and `rows.labels`
  writes each breed beside its row
- `rows.field: "haplotype"` draws one row per assembly, each being one
  haplotype, with a second alternate allele in a separate color. `rows.sort` and
  `rows.labels` use each assembly's sample name, which covers all of that
  assembly's rows

```json
{
  "type": "VariantTrack",
  "trackId": "bovine_pangenome_vcf",
  "name": "Bovine super-pangenome variants (12 assemblies)",
  "assemblyNames": ["bosTau9"],
  "adapter": {
    "type": "VcfTabixAdapter",
    "uri": "https://jbrowse.org/demos/bovine_pangenome/bovine-arsucd12-minigraph.vcf.gz",
    "csi": true,
    "samplesTsvLocation": {
      "uri": "https://jbrowse.org/demos/bovine_pangenome/bovine-arsucd12-minigraph.samples.tsv"
    }
  },
  "displays": [
    {
      "type": "LinearVariantDisplay",
      "rows": {
        "field": "haplotype",
        "sort": [
          "ANG",
          "BSW",
          "HIG",
          "OBV",
          "PIE",
          "SIM",
          "BRA",
          "NEL",
          "GAU",
          "BIS",
          "YAK"
        ],
        "labels": {
          "ANG": "Angus",
          "BSW": "Brown Swiss",
          "HIG": "Highland",
          "OBV": "Original Braunvieh",
          "PIE": "Piedmontese",
          "SIM": "Simmental",
          "BRA": "Brahman",
          "NEL": "Nellore",
          "GAU": "Gaur",
          "BIS": "Bison",
          "YAK": "Yak"
        },
        "color": {
          "field": "lineage",
          "scale": {
            "domain": ["taurine", "indicine", "gaur", "bison", "yak"],
            "range": ["#0072B2", "#E69F00", "#009E73", "#CC79A7", "#D55E00"]
          }
        }
      }
    }
  ]
}
```

CLI:

```bash
jbrowse add-track-json '{
  "type": "VariantTrack",
  "trackId": "bovine_pangenome_vcf",
  "name": "Bovine super-pangenome variants (12 assemblies)",
  "assemblyNames": ["bosTau9"],
  "adapter": {
    "type": "VcfTabixAdapter",
    "uri": "https://jbrowse.org/demos/bovine_pangenome/bovine-arsucd12-minigraph.vcf.gz",
    "csi": true,
    "samplesTsvLocation": {
      "uri": "https://jbrowse.org/demos/bovine_pangenome/bovine-arsucd12-minigraph.samples.tsv"
    }
  },
  "displays": [
    {
      "type": "LinearVariantDisplay",
      "rows": {
        "field": "haplotype",
        "sort": [
          "ANG",
          "BSW",
          "HIG",
          "OBV",
          "PIE",
          "SIM",
          "BRA",
          "NEL",
          "GAU",
          "BIS",
          "YAK"
        ],
        "labels": {
          "ANG": "Angus",
          "BSW": "Brown Swiss",
          "HIG": "Highland",
          "OBV": "Original Braunvieh",
          "PIE": "Piedmontese",
          "SIM": "Simmental",
          "BRA": "Brahman",
          "NEL": "Nellore",
          "GAU": "Gaur",
          "BIS": "Bison",
          "YAK": "Yak"
        },
        "color": {
          "field": "lineage",
          "scale": {
            "domain": ["taurine", "indicine", "gaur", "bison", "yak"],
            "range": ["#0072B2", "#E69F00", "#009E73", "#CC79A7", "#D55E00"]
          }
        }
      }
    }
  ]
}'
```

Opens on config <https://jbrowse.org/ucsc/bosTau9/config.json> at `chr23:27,508,000-27,536,000`

In the chr23 view the portal opened, type `chr23:27,508,000-27,536,000` to draw
the graph around _HSPA1A_. Then:

- Turn on the callset in the track selector.
- Open **Graph settings...** in the graph track's menu and set **Bubble spread**
  to **Compress lengths**, which pulls the longest and shortest nodes towards
  the mean so a cut spanning kb and bp nodes fits one pane.

<Figure caption="HSPA1A with the deconstructed callset, one row per assembly, over the graph track. The graph draws the insertion as the charcoal loop." src="/img/pangenome/bovine_bola.png" />

Session spec, on config <https://jbrowse.org/code/jb2/main/test_data/graphgenomeview/pangenome_nonhuman.json>:

```json
{
  "views": [
    {
      "type": "LinearGenomeView",
      "id": "pangenome-bovine_bola-lgv",
      "assembly": "bosTau9",
      "loc": "chr23:27,508,000-27,536,000",
      "tracks": [
        {
          "trackId": "bosTau9_ncbiRefSeq_ucsc",
          "height": 90
        },
        {
          "trackId": "bovine_pangenome_vcf",
          "height": 300
        },
        {
          "trackId": "bovine_minigraph_segments",
          "type": "LinearGraphDisplay",
          "layoutMode": "force",
          "bubbleSpread": "compress",
          "color": {
            "field": "position"
          },
          "maxRegionBp": 30801,
          "height": 420
        }
      ]
    }
  ]
}
```

## Published variants in the callset

Each locus below is a structural variant a paper reported in one of these breeds
or species. The rows of assemblies without it are the control.

### The Celtic polled allele

Angus cattle are born without horns. Medugorac et al. (2012) traced the Celtic
form of polledness to a 202 bp duplication and insertion on chromosome 1, which
OMIA, the Online Mendelian Inheritance in Animals database, curates as OMIA
000483-9913.[^friesian]

The portal page's **POLLED** example names the Celtic polled allele above the
map, and each launch opens a **Known alleles** row and OMIA's records under the
genes. Every launch up to 150 kb wide on the portal includes the OMIA row.

To add OMIA to your own JBrowse,
[`build_omia_cattle_variants.sh`](https://github.com/GMOD/jbrowse-components/blob/main/scripts/build_omia_cattle_variants.sh)
writes `omia_cattle_variants.gff3.gz` from OMIA's nightly database dump. It
keeps the cattle records published on ARS-UCD1.2 or ARS-UCD1.3, which share
every chromosome's coordinates:

```bash
curl -fO https://raw.githubusercontent.com/GMOD/jbrowse-components/main/scripts/build_omia_cattle_variants.sh
# .: write the file and its index here, beside your config, instead of omia_cattle_build/
bash build_omia_cattle_variants.sh .
```

Add the records as a track:

```json
{
  "trackId": "omia_cattle_variants",
  "name": "OMIA causal variants (cattle)",
  "uri": "omia_cattle_variants.gff3.gz",
  "csi": true,
  "assemblyNames": ["bosTau9"],
  "displayDefaults": {
    "labels": {
      "description": "jexl:feature.inheritance"
    }
  }
}
```

CLI:

```bash
jbrowse add-track omia_cattle_variants.gff3.gz \
  --trackId omia_cattle_variants \
  --name "OMIA causal variants (cattle)" \
  --assemblyNames bosTau9 \
  --indexFile omia_cattle_variants.gff3.gz.csi \
  --displayDefaults '{"labels":{"description":"jexl:feature.inheritance"}}' \
  --load copy
```

Then open `chr1:2,428,800-2,429,800`. The figure shades
`chr1:2,429,109-2,429,320`, the stretch OMIA records as duplicated by the
allele.

<Figure caption="The POLLED locus with OMIA's record of the Celtic polled allele above the callset." src="/img/pangenome/bovine_polled.png" />

Session spec, on config <https://jbrowse.org/code/jb2/main/test_data/graphgenomeview/pangenome_nonhuman.json>:

```json
{
  "views": [
    {
      "type": "LinearGenomeView",
      "id": "pangenome-bovine_polled-lgv",
      "assembly": "bosTau9",
      "loc": "chr1:2,428,800-2,429,800",
      "tracks": [
        {
          "trackId": "omia_cattle_variants",
          "height": 60
        },
        {
          "trackId": "bovine_pangenome_vcf",
          "height": 260
        }
      ],
      "highlight": [
        {
          "refName": "chr1",
          "start": 2429108,
          "end": 2429320,
          "label": "Duplicated in Celtic polled",
          "color": "rgba(255,193,7,0.30)"
        }
      ]
    }
  ]
}
```

### A repeat upstream of KIT in white-headed cattle

Simmental and Hereford cattle have white heads. Milia et al. (2025) tied the
trait to a 14.3 kb segment repeated in tandem upstream of _KIT_: white-headed
breeds have extra copies, color-headed breeds a deletion. The Hereford reference
holds one collapsed copy. Open `chr6:70,080,000-70,180,000`.

<Figure caption="Upstream of KIT with the callset and the graph track, which draws the deletion as a dashed arc." src="/img/pangenome/bovine_kit.png" />

Session spec, on config <https://jbrowse.org/code/jb2/main/test_data/graphgenomeview/pangenome_nonhuman.json>:

```json
{
  "views": [
    {
      "type": "LinearGenomeView",
      "id": "pangenome-bovine_kit-lgv",
      "assembly": "bosTau9",
      "loc": "chr6:70,080,000-70,180,000",
      "tracks": [
        {
          "trackId": "bosTau9_ncbiRefSeq_ucsc",
          "height": 90
        },
        {
          "trackId": "bovine_pangenome_vcf",
          "height": 300
        },
        {
          "trackId": "bovine_minigraph_segments",
          "type": "LinearGraphDisplay",
          "layoutMode": "force",
          "color": {
            "field": "position"
          },
          "bubbleSpread": "compress",
          "maxRegionBp": 110001,
          "height": 240
        }
      ]
    }
  ]
}
```

Every other assembly has the record's deletion, in blue. Simmental's row is red
for the record's second allele, which is longer than the Hereford reference's,
so Simmental has more copies of the repeat than the reference.

### A deletion of TAS2R46 in gaur

_TAS2R46_ encodes a bitter taste receptor. Leonard et al. (2022) found a 17 kb
deletion in gaur that removes it. Open `chr5:98,575,000-98,615,000`.

<Figure caption="TAS2R46 with the callset and the graph track, which draws the deletion as a dashed arc." src="/img/pangenome/bovine_tas2r46.png" />

Session spec, on config <https://jbrowse.org/code/jb2/main/test_data/graphgenomeview/pangenome_nonhuman.json>:

```json
{
  "views": [
    {
      "type": "LinearGenomeView",
      "id": "pangenome-bovine_tas2r46-lgv",
      "assembly": "bosTau9",
      "loc": "chr5:98,575,000-98,615,000",
      "tracks": [
        {
          "trackId": "bosTau9_ncbiRefSeq_ucsc",
          "height": 90
        },
        {
          "trackId": "bovine_pangenome_vcf",
          "height": 300
        },
        {
          "trackId": "bovine_minigraph_segments",
          "type": "LinearGraphDisplay",
          "layoutMode": "force",
          "color": {
            "field": "position"
          },
          "bubbleSpread": "compress",
          "maxRegionBp": 44000,
          "height": 240
        }
      ]
    }
  ]
}
```

Angus, Piedmontese, Brahman and Nellore, two taurine and two indicine breeds,
have an allele slightly longer than the reference's, in blue. The gaur's allele,
in red, lacks the span.

## Building the bovine graph files

[Pangenome (hosting your own graph)](https://jbrowse.org/jb2/docs/tutorials/pangenome_prepare_graph) turns a graph into the files above
with one command, `gfa-to-tabix build`. The published bovine graphs need three
steps beyond it, which
[`build_bovine_pangenome.sh`](https://github.com/GMOD/jbrowse-components/blob/main/scripts/build_bovine_pangenome.sh)
runs:

- Join the autosomes: the archive holds one graph per autosome, each numbering
  its segments from 1, so the script renumbers and concatenates them.
- Recover rGFA tags: the graphs record their coordinates in P lines, and
  [`gfa_paths_to_rgfa.py`](https://github.com/GMOD/jbrowse-components/blob/main/scripts/gfa_paths_to_rgfa.py)
  converts them back into `SN`/`SO`/`SR` tags (each segment's contig, offset and
  rank).
- Deconstruct the callset with the `vg deconstruct` call above.

The script runs on Linux, since it needs GNU tools, and downloads the 12 GB
Zenodo archive. It stops if the reference path does not reproduce bosTau9's
chromosome lengths, and a
[README.txt](https://jbrowse.org/demos/bovine_pangenome/README.txt) beside the
hosted files records the source and every modification.

Leonard et al. also built pggb and Minigraph-Cactus graphs of the same twelve
assemblies, base-level GFAs with path lines. From one of those,
`gfa-to-tabix build` records the assemblies that pass through each segment,
which
[a haplotypes-per-segment track](https://jbrowse.org/jb2/docs/tutorials/pangenome_prepare_graph#which-haplotypes-walk-each-segment)
colors by count.

## See also

- **Tutorial:** [Pangenome (mouse)](https://jbrowse.org/jb2/docs/tutorials/pangenome_mouse)
- **Tutorial:** [](https://jbrowse.org/jb2/docs/tutorials/pangenome_hprc)
- **Tutorial:** [Pangenome (hosting your own graph)](https://jbrowse.org/jb2/docs/tutorials/pangenome_prepare_graph)

## Citations

- Leonard et al. (2022).
  [Structural variant-based pangenome construction has low sensitivity to variability of haplotype-resolved bovine assemblies](https://doi.org/10.1038/s41467-022-30680-2)
- Leonard et al. (2023).
  [Graph construction method impacts variation representation and analyses in a bovine super-pangenome](https://doi.org/10.1186/s13059-023-02969-y)
- Li et al. (2020).
  [The design and construction of reference pangenome graphs with minigraph](https://doi.org/10.1186/s13059-020-02168-z)
- Medugorac et al. (2012).
  [Bovine polledness: an autosomal dominant trait with allelic heterogeneity](https://doi.org/10.1371/journal.pone.0039477)
- Milia et al. (2025).
  [Taurine pangenome uncovers a segmental duplication upstream of KIT associated with depigmentation in white-headed cattle](https://doi.org/10.1101/gr.279064.124)

[^friesian]:
    OMIA also records the Friesian polled allele, a larger duplication further
    along, which Holstein cattle have. The panel has no Holstein.

