Synteny visualization (a polyploid against itself)
The tutorials target the JBrowse v5 beta, and the v4.3.0 release
on the download page 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.22. Desktop beta builds for Linux and
macOS are on the releases page;
the Windows build waits on code signing.
Hexaploid oat has three near-complete copies of its genome, one from each grass that hybridized to make it, so most of its genes exist three times. The copies of a gene across subgenomes are homoeologs. We:
- find the gene pairs between the copies with jcvi, and measure each pair's
divergence at silent sites (dS) and at protein-changing ones (dN) with
orthologs2jbrowse kaks - load the pair table as a synteny track
- draw oat against itself in a dotplot, coloring each pair by dS
Prerequisites
- a JBrowse to open the files in: Desktop takes a local file by path, Web through Add track
- jcvi
- DIAMOND
- orthologs2jbrowse, and python3 with biopython
wgetnode, for the JBrowse CLI
# Debian/Ubuntu
sudo apt install diamond-aligner nodejs python-is-python3
# or conda, which has every tool above
conda install -c bioconda -c conda-forge diamond nodejs python
# any platform
pip install jcvi biopython git+https://github.com/cmdcolin/orthologs2jbrowse
npm install -g @jbrowse/cli@nextThe data
Oat cultivar Williams (GCA_951802345.1), assembled and annotated by the PanOat consortium (Avni et al. 2025), from its release on GrainGenes.
You don't need these files to follow the session, which reads a hosted copy. The track configs name local files that the build script writes from these, about 3.3 GB of downloads, so run it first, or follow the same steps on the gene models, CDS and chromosome sizes of a genome of your own.
| What it is | File |
|---|---|
| The annotation the self-alignment runs on (GFF3 and proteins) | williams.tgz |
| The genome each CDS and the chromosome lengths are read from | 230404_williams_pseudomolecules_v1+unanchored_contigs.fasta.gz |
Produce the homoeolog table
Extract gene models, proteins and chromosome sizes
jcvi turns the GFF3 into the BED the adapter also reads, one primary transcript per gene:
python -m jcvi.formats.gff bed --type=mRNA --key=ID \
--primary_only oat.gff3.gz -o oat.all.bed
awk -F'\t' '$1 ~ /^[1-7][ACD]$/' oat.all.bed > oat.bedThe release has no CDS file, so the end-to-end script cuts each transcript's CDS out of the genome, then translates the proteome from it, keeping the transcript ids the BED uses.
The assembly needs no sequence, so we'll load it from the chromosome lengths the
script reads off the genome, written to oat.chrom.sizes (a name and a length
per line):
Goes in the assemblies array of config.json. See Assemblies.
{ "name": "oat", "uri": "oat.chrom.sizes" }Edits config.json in the current folder, creating it if there is none. See JBrowse CLI with Desktop.
jbrowse add-assembly oat.chrom.sizes \
--name oat \
--load copyIn JBrowse Desktop, Open your own genome on the start screen (or File → Open genome... in a session), then Open from a URL and paste:
oat.chrom.sizesJBrowse reads the format off the file name. Then fill in:
- Genome name:
oat
oat.chrom.sizes is relative to a config.json. Replace it with its URL or its path on this computer.
Find homoeolog pairs from a protein self-alignment
With the same prefix twice (oat oat), jcvi makes a self-comparison: it drops
the gene-against-itself diagonal, then chains the rest into syntenic blocks
(co-linear runs of pairs).
diamond makedb --in oat.pep -d oat.pep
diamond blastp --threads 14 --query oat.pep --db oat.pep --out oat.oat.last \
--max-target-seqs 20 --evalue 1e-10 --outfmt 6
python -m jcvi.compara.catalog ortholog --no_strip_names --dbtype prot \
--align_soft diamond_blastp --self_remove 100 --no_dotplot oat oatTwo flags matter here:
--self_removedefaults to 98 and discards every hit at or above that percent identity. Oat's A-D homoeologs sit above it, so this run sets 100--no_strip_nameskeeps the ids byte-identical to the BED the adapter joins on
The alignment is the long step: budget over an hour on every core, since the
whole proteome is aligned against itself. Run separately as above, DIAMOND uses
its default sensitivity, which finds homoeologs this recent, and jcvi picks up
oat.oat.last by name and skips its own alignment.
Three choices set which pairs are kept:
- jcvi chains the pairs and keeps a gene pair (an anchor) only where it is collinear with neighbouring pairs, which removes the off-diagonal noise of gene families' best hits.
- The script keeps the pairs whose chromosomes have different subgenome letters,
since a self-comparison also chains tandem and segmental duplicates within a
subgenome, and writes them, two transcript ids per line, to
oat.pairs.tsv. - The script reads
oat.oat.anchorsand skipsoat.oat.lifted.anchors, because jcvi's liftover step adds extra pairs near an established block, and their dS is far above that of the chained pairs, which marks them as paralogs.
On a genome of your own, the pair list comes from the two gene columns of the chained anchors, kept where the two genes' chromosomes end in different subgenome letters. Adapt that test to your own chromosome names:
# oat.bed maps each gene id (column 4) to its chromosome (column 1); the ###
# lines between anchor blocks are skipped, and so are genes off the chromosomes
awk 'NR == FNR {chrom[$4] = $1; next}
!/^#/ && ($1 in chrom) && ($2 in chrom) &&
substr(chrom[$1], length(chrom[$1])) != substr(chrom[$2], length(chrom[$2])) {
print $1 "\t" $2
}' oat.bed oat.oat.anchors > oat.pairs.tsvMeasure dN and dS on each homoeolog pair
orthologs2jbrowse kaks measures dN and dS on each pair from its two CDS:
orthologs2jbrowse kaks oat.pairs.tsv oat.cds.fa.gz \
--key record --min-syn-subs 3 -o oat.homoeologs.blocks--key record reads the CDS by transcript id, and --min-syn-subs drops pairs
with too few synonymous differences to trust a ratio.
Selection pressure explains the
method and the filters.
Load the homoeolog table as a dotplot track
Oat (Avena sativa) is an allohexaploid with 21 chromosomes, seven homoeologous groups of three, one per subgenome (A, C and D). A homoeolog table has oat on both sides, and the dotplot puts oat on both axes. A segment moved between groups lies off the diagonal.
oat.homoeologs.blocks lists gene pairs, then dN, dS, the synonymous
substitution count and a Fisher exact p, which is the .blocks layout
MCScanBlocksAdapter reads. The script
gzips it and oat.bed for the track. A self-comparison names one assembly
twice: in blockAssemblies, in the track's assemblyNames and in both entries
of bedLocations:
Goes in the tracks array of config.json. See Tracks.
{
"type": "SyntenyTrack",
"trackId": "oat_homoeologs",
"name": "Oat homoeologs (dN/dS)",
"assemblyNames": ["oat", "oat"],
"adapter": {
"type": "MCScanBlocksAdapter",
"uri": "oat.homoeologs.blocks.gz",
"blockAssemblies": ["oat", "oat"],
"bedLocations": ["oat.bed.gz", "oat.bed.gz"],
"attributeColumns": ["dn", "ds", "syn_subs", "fisher_p"]
}
}Edits config.json in the current folder. See JBrowse CLI with Desktop.
jbrowse add-track-json '{
"type": "SyntenyTrack",
"trackId": "oat_homoeologs",
"name": "Oat homoeologs (dN/dS)",
"assemblyNames": ["oat", "oat"],
"adapter": {
"type": "MCScanBlocksAdapter",
"uri": "oat.homoeologs.blocks.gz",
"blockAssemblies": ["oat", "oat"],
"bedLocations": ["oat.bed.gz", "oat.bed.gz"],
"attributeColumns": ["dn", "ds", "syn_subs", "fisher_p"]
}
}'In JBrowse Desktop, or in any running JBrowse Web session, open a view on this track’s assembly, then File → Open track..., choose Add track from pasted JSON, and paste:
{
"type": "SyntenyTrack",
"trackId": "oat_homoeologs",
"name": "Oat homoeologs (dN/dS)",
"assemblyNames": ["oat", "oat"],
"adapter": {
"type": "MCScanBlocksAdapter",
"uri": "oat.homoeologs.blocks.gz",
"blockAssemblies": ["oat", "oat"],
"bedLocations": ["oat.bed.gz", "oat.bed.gz"],
"attributeColumns": ["dn", "ds", "syn_subs", "fisher_p"]
}
}oat.homoeologs.blocks.gz, oat.bed.gz are relative to a config.json. Replace each with its URL or its path on this computer.
That shows it in the linear view. For the synteny view, open Add → Linear synteny view, pick the track under Quick start, and click Launch.
attributeColumns lists the columns after the two gene columns, and each
becomes a feature attribute in the detail panel. The palette button's dN/dS
uses dn and ds.
Add → Dotplot view with oat on both axes opens the track as a dotplot, and the session below does the same.
Color homoeolog pairs by dS
Color by value → ds on the palette button paints each pair by its dS. Oat's A and D subgenomes descend from closely related diploid Avena species and its C subgenome from a more distant one, so A-D pairs are the control: they diverged most recently.
In grammar-of-graphics terms, the dotplot's
encoding.color is a color scale, here the ds field mapped to a ramp. The
session pins the ramp's ends with scale.domainMin and scale.domainMax, so a
color means one dS wherever the view goes; the menu has no field for them:
Goes at the top level of config.json, replacing any defaultSession there. See Default session.
{
"defaultSession": {
"name": "Oat homoeologs by dS",
"views": [
{
"type": "DotplotView",
"views": [
{
"assembly": "oat",
"displayedRegionNames": [
"4A",
"4C",
"4D",
"5A",
"5C",
"5D",
"7A",
"7C",
"7D"
]
},
{
"assembly": "oat",
"displayedRegionNames": [
"4A",
"4C",
"4D",
"5A",
"5C",
"5D",
"7A",
"7C",
"7D"
]
}
],
"tracks": ["oat_homoeologs"],
"encoding": {
"color": {
"field": "ds",
"scale": { "domainMin": 0, "domainMax": 0.25 },
"legend": { "title": "dS" }
}
}
}
]
}
}Replaces any defaultSession in config.json in the current folder. See JBrowse CLI with Desktop.
jbrowse set-default-session --session - << 'EOF'
{
"name": "Oat homoeologs by dS",
"views": [
{
"type": "DotplotView",
"views": [
{
"assembly": "oat",
"displayedRegionNames": [
"4A",
"4C",
"4D",
"5A",
"5C",
"5D",
"7A",
"7C",
"7D"
]
},
{
"assembly": "oat",
"displayedRegionNames": [
"4A",
"4C",
"4D",
"5A",
"5C",
"5D",
"7A",
"7C",
"7D"
]
}
],
"tracks": ["oat_homoeologs"],
"encoding": {
"color": {
"field": "ds",
"scale": { "domainMin": 0, "domainMax": 0.25 },
"legend": { "title": "dS" }
}
}
}
]
}
EOFOpen this session in JBrowse Web ↗
Needs JBrowse Desktop 5.0 or newer. If nothing opens, copy the link and paste it into Desktop's Open JBrowse Web link..., on the start screen or under File → Session.
https://jbrowse.org/code/jb2/main/?config=https%3A%2F%2Fjbrowse.org%2Fdemos%2Foat_homoeologs%2Fconfig.json&session=json-%7B%22session%22%3A%7B%22name%22%3A%22Oat+homoeologs+by+dS%22%2C%22views%22%3A%5B%7B%22type%22%3A%22DotplotView%22%2C%22views%22%3A%5B%7B%22assembly%22%3A%22oat%22%2C%22displayedRegionNames%22%3A%5B%224A%22%2C%224C%22%2C%224D%22%2C%225A%22%2C%225C%22%2C%225D%22%2C%227A%22%2C%227C%22%2C%227D%22%5D%7D%2C%7B%22assembly%22%3A%22oat%22%2C%22displayedRegionNames%22%3A%5B%224A%22%2C%224C%22%2C%224D%22%2C%225A%22%2C%225C%22%2C%225D%22%2C%227A%22%2C%227C%22%2C%227D%22%5D%7D%5D%2C%22tracks%22%3A%5B%22oat_homoeologs%22%5D%2C%22encoding%22%3A%7B%22color%22%3A%7B%22field%22%3A%22ds%22%2C%22scale%22%3A%7B%22domainMin%22%3A0%2C%22domainMax%22%3A0.25%7D%2C%22legend%22%3A%7B%22title%22%3A%22dS%22%7D%7D%7D%7D%5D%7D%7D&sessionName=JBrowse+docs+exampledN/dS on the palette button colors each pair by the ratio instead.
Reproduce it end to end
build_oat_homoeologs.sh
runs everything above and writes a config.json with the assembly, the track
and a dotplot session:
- Cut each transcript's CDS out of the genome, turn the GFF3 into a BED of one primary transcript per gene on the 21 chromosomes, and translate the CDS into a proteome keyed on the same ids.
- Align the proteome against itself with DIAMOND and chain the hits with jcvi,
with
--self_remove 100so the A-D homoeologs are kept. - Keep the chained anchors whose two genes sit on different subgenomes, and measure dN and dS on each.
- Write the config, with oat on both axes of the dotplot session.
curl -fO https://raw.githubusercontent.com/GMOD/jbrowse-components/main/scripts/build_oat_homoeologs.sh
bash build_oat_homoeologs.sh
npx --yes serve oat_homoeologs_build/jbrowse2 # then open the printed URLSee also
- Tutorial: Synteny from MCScan anchors (grape, peach)
- Tutorial: Synteny from an ortholog table (grape, peach, cacao)
- Tutorial: Synteny visualization (OrthoFinder orthogroups)
- Tutorial: Comparing one genome's two haplotypes (T2T-HG002)
Citations
- Avni et al. (2025). A pangenome and pantranscriptome of hexaploid oat
- Nei and Gojobori (1986). Simple methods for estimating the numbers of synonymous and nonsynonymous nucleotide substitutions
- Tang et al. (2024). jcvi: A versatile toolkit for comparative genomics analysis
Feedback on this tutorial is welcome: contact us.