library(canvasXpress)
set.seed(8)
segments <- paste0("s", 1:80)
tracks <- c("Expression", "Methylation", "CopyNumber", "Density")
y <- matrix(round(rnorm(length(tracks) * length(segments)), 2),
nrow = length(tracks), dimnames = list(tracks, segments))
smpAnnot <- data.frame(Region = rep(paste0("chr", 1:4), each = 20), row.names = segments)
cols <- c("rgb(220,40,40)", "rgb(40,120,220)", "rgb(40,160,60)", "rgb(240,150,20)")
conns <- lapply(1:18, function(i)
list(sample(cols, 1), sample(segments, 1), sample(segments, 1)))Circular (Circos-style) multi-track plots in R with canvasXpress
A circular (Circos-style) plot wraps a genome — or any ordered set of segments — into a ring, stacks several data tracks around it, and draws ribbons for relationships between positions. In R the reference is circlize. Here we build an interactive one with canvasXpress, from a single portable spec.
The data shape
The matrix is tracks × segments (rows are the tracks you draw, columns are the positions around the ring). A sample annotation segments the ring (here into chromosomes), and circularConnections is a list of [colour, from, to] ribbons.
The plot
circularTrackGraphType picks a renderer per track (bar, heatmap, line, dot), circularTrackGraphWeight sets each track’s radial thickness, and segregateSamplesBy splits the ring by the annotation.
canvasXpress(
data = y, smpAnnot = smpAnnot,
graphType = "Circular",
circularConnections = conns,
circularTrackGraphType = list("bar", "heatmap", "line", "dot"),
circularTrackGraphWeight = list(30, 20, 25, 25),
circularTrackName = list(1, 2, 3, 4),
segregateSamplesBy = list("Region"),
title = "Circos-style multi-track plot with connections",
width = 560, height = 560
)Each ring is one track; the inner ribbons are the connections. Hover a segment to read its values; swap the matrix and ribbons for your own genomic tracks and interactions.
Why “reproducible”
The matrix, the connections and the config are the figure — one portable spec. The same spec renders the identical circular plot from Python or JavaScript, and can be validated and re-rendered later.