SyntenyPlot visualizes collinear blocks between genomic sequences as horizontal bars connected by ribbon polygons. Each sequence is represented as a labeled horizontal bar, with ribbons connecting homologous regions. Inverted blocks (structural inversions) are drawn as crossed ribbons.
When to Use
Synteny plots are ideal for:- Comparative genomics — chromosome rearrangements, conservation between species
- Structural variation — inversions, translocations, duplications
- Genome assembly validation — alignment between assemblies or scaffolds
- Evolutionary analysis — synteny conservation across lineages
- Ortholog mapping — visualizing conserved gene order between genomes
Basic Example
.with_shared_scale() for a shared coordinate ruler.
Forward and Inverted Blocks
Inverted blocks (structural inversions) are drawn as crossed (bowtie) ribbons:- Forward blocks (
.with_block()): Ribbons connect directly (parallel) - Inverted blocks (
.with_inv_block()): Ribbons cross (bowtie shape)
Three-Way Synteny
Visualize synteny across multiple sequences:Custom Colors
Set sequence bar colors and per-block colors:Shared Scale
By default, each sequence bar fills the full width (per-sequence scale). Enable shared scale for a common coordinate ruler:Key Methods
SyntenyPlot::new()
Create a synteny plot with default settings:
- Bar height: 18.0 pixels
- Block opacity: 0.65
- Shared scale: false (per-sequence scale)
.with_sequences<S, L>(seqs: impl IntoIterator<Item = (S, L)>)
Add sequences from (label, length) pairs. Sequences are indexed in the order added (0-indexed).
.with_sequence_colors<C: Into<String>>(colors: impl IntoIterator<Item = C>)
Override sequence bar colors. Provide one color per sequence in the same order.
.with_block(seq1: usize, start1: f64, end1: f64, seq2: usize, start2: f64, end2: f64)
Add a forward (parallel) collinear block between two sequences.
seq1,seq2: Sequence indices (0-indexed)start1,end1: Coordinates on sequence 1start2,end2: Coordinates on sequence 2
.with_inv_block(seq1: usize, start1: f64, end1: f64, seq2: usize, start2: f64, end2: f64)
Add an inverted (crossed) block, indicating a structural inversion.
.with_colored_block(seq1, start1, end1, seq2, start2, end2, color)
Add a forward block with an explicit color.
.with_colored_inv_block(seq1, start1, end1, seq2, start2, end2, color)
Add an inverted block with an explicit color.
.with_blocks(blocks: impl IntoIterator<Item = SyntenyBlock>)
Batch-add pre-built SyntenyBlock structures:
.with_bar_height(h: f64)
Set sequence bar height in pixels (default 18.0).
.with_opacity(opacity: f64)
Set ribbon fill opacity (default 0.65). Range: 0.0 (transparent) to 1.0 (opaque).
.with_shared_scale()
Enable shared coordinate ruler. By default, each sequence bar fills the full width (per-sequence scale). With shared scale, shorter sequences draw narrower bars.
.with_legend<S: Into<String>>(label: S)
Add a legend (useful when using colored blocks or sequence colors).
Data Structures
SyntenyPlot
SyntenySequence
SyntenyBlock
Strand
Tips
- Block direction: Use inverted blocks (
.with_inv_block()) to highlight structural inversions - Coordinate system: Start and end coordinates are in base pairs; use actual genomic coordinates
- Scale mode: Use per-sequence scale (default) when comparing sequences of similar length; use shared scale when length differences are important
- Color strategy: Use per-block colors to highlight functional regions (genes, repeats, conservation levels)
- Opacity: Reduce opacity if blocks overlap heavily
- Multiple sequences: Connect adjacent pairs (seq 0-1, 1-2, 2-3) for multi-way comparisons
- Gaps: Absence of ribbons indicates non-syntenic regions or assembly gaps
- Resolution: For whole-genome comparisons, use blocks > 10kb to avoid visual clutter
Parsing Synteny Data
Common formats for synteny data:MCScanX format
LASTZ/Chain format
Extract block coordinates from alignment chains.MUMmer/nucmer
Parse.delta or .coords files to extract collinear blocks.
Related Plots
- Manhattan plot — For genome-wide association signals
- Genome browser — For detailed annotation tracks
- Dot plot — For all-vs-all sequence similarity