Sankey and alluvial plots show how entities flow or transition between categories. Sankey shows aggregate flows from source to sink (single step); alluvial tracks individual entity trajectories across multiple ordered axes (multi-step). CONSORT diagrams are the formal vertical-box trial-flow standard. ggalluvial (R) is the modern default for alluvial; networkD3 / plotly for Sankey; consort for CONSORT.
install.packages(c('ggalluvial', 'networkD3', 'consort'))
pip install plotly kaleido pySankey
Tell your AI agent what you want to do: - "Plot cell-state transitions across 3 timepoints as an alluvial diagram" - "Build a CONSORT diagram for the trial enrollment flow" - "Sankey of variants flowing through the QC filter stages" - "Color ribbons by starting cluster to show 'where this came from' story" - "Interactive Sankey of metabolic pathway flux"
"Alluvial of N=1000 cells across 3 timepoints (t1, t2, t3). Color by t1 cluster identity. Use ggalluvial. Order categories alphabetically within each axis."
"CONSORT 2010-compliant trial flow: 200 assessed, 50 excluded with reasons, 150 randomized 1:1, then per-arm allocation/loss/analyzed boxes."
"Sankey showing how N variants flow through QC stages (raw -> quality-filtered -> MAF-filtered -> annotated -> final). Counts at each transition."
"Interactive Sankey (networkD3 or plotly) showing pathway -> gene -> variant relationships."
"Alluvial of patient response class (CR/PR/SD/PD) across 3 assessments. Highlight responders -> non-responders."
Sankey vs alluvial are different - Sankey collapses to aggregate flows; alluvial tracks individual entity paths. Pick based on the scientific story.
Set explicit factor levels for categories within each axis (factor(x, levels = c('A','B','C'))). Default ordering shuffles position across axes, creating spaghetti ribbons.
Color by origin OR destination, not both. Common pattern: aes(fill = first_axis) for "where did these end-state cells come from?"
Max 5-7 categories per column for legibility. Above this, ribbons become unreadable; aggregate small categories into "Other."
Max 4-5 axes for alluvial. Above this, even with optimal ordering, crossings dominate.
CONSORT 2010 is required for randomized clinical trials. Use the consort R package to ensure all required boxes are present.
plotly Sankey static export requires kaleido. pip install kaleido; orca is EOL.
Flow conservation at internal nodes - in-flows must equal out-flows. Verify the input before plotting; misalignment renders silently with wrong node sizes.
Add count annotations to ribbons when the number of entities per transition is the key information.
For pipeline filtering (variants through QC, reads through trimming/alignment/dedup), CONSORT-style vertical flow is more readable than horizontal Sankey.