Build Sankey, alluvial, river, and CONSORT-style flow diagrams to visualize cohort transitions, cell-state changes, or pipeline filtering using ggalluvial, networkD3, plotly, and consort. Use when showing how entities move between categories across timepoints (cell states, drug response classes, patient flow through a trial) or filtering pipelines (variants filtered through QC stages).
Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.
Quelldateien prüfen
Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
Build Sankey, alluvial, river, and CONSORT-style flow diagrams to visualize cohort transitions, cell-state changes, or pipeline filtering using ggalluvial, networkD3, plotly, and consort. Use when showing how entities move between categories across timepoints (cell states, drug response classes, patient flow through a trial) or filtering pipelines (variants filtered through QC stages).
Before using code patterns, verify installed versions match. If versions differ:
R: packageVersion('<pkg>') then ?function_name
Python: pip show <package> then help(module.function)
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
Flow and Transition Plots
"Show how things flow between categories" -> Render entities as ribbons whose width encodes count, flowing between ordered columns of categories. Sankey emphasizes total flow magnitude; alluvial emphasizes per-entity continuity (each row's path is traceable); CONSORT formalizes the trial-filtering convention. The decision space: which method (Sankey vs alluvial vs CONSORT), how to order categories within each column, and whether to highlight specific entity trajectories.
The Single Most Important Modern Insight -- Sankey vs Alluvial Are Different
Sankey plots show flow from sources to sinks; each ribbon represents an aggregate count. The horizontal direction is "flow." Use for energy flows, web-traffic funnels, cohort dropouts.
Alluvial plots track individual entities through multiple ordered category columns (axes). Each row of input data becomes a continuous ribbon; intersections at each axis show counts in each category. Use for cell-state transitions across timepoints, drug-response trajectories, longitudinal class changes.
A Sankey shows "100 cells became neuron, 50 became glia"; an alluvial shows "of the 100 that became neurons at t2, 80 came from the proliferating pool at t1." Different encoding, different scientific story.
Decision Tree by Use Case
Use case
Recommended
Tool
Single timepoint, source-to-sink flow
Sankey
networkD3, plotly
Multi-timepoint entity trajectories
Alluvial
ggalluvial
Clinical trial patient flow
CONSORT (formal vertical box-and-arrow)
consort R package
Variant filtering pipeline
CONSORT-style flow
consort or manual diagrammeR
Cell-state transitions (scRNA timepoints)
Alluvial OR Sankey if 2 timepoints
ggalluvial
Drug response class changes
Alluvial
ggalluvial
Gene-set membership across conditions
UpSet (alternative)
data-visualization/upset-plots
ggalluvial -- Modern R Default for Alluvial
Goal: Visualize entity (e.g., cell, patient) trajectories across multiple ordered axes with ribbon-width = count.
Approach: Reshape to "lodes" (long) format with one row per entity-stratum, or "alluvia" (wide) format with one row per entity; use geom_alluvium for ribbons and geom_stratum for column boxes.
CONSORT Diagrams -- The Formal Trial-Flow Standard
CONSORT 2010 (Schulz 2010 BMJ 340:c332) is the canonical clinical-trial flow diagram. The consort R package implements the structure:
library(consort)# Trial enrollment flow
g <- add_box(txt =c('Assessed for eligibility (n=200)'))
g <- add_side_box(g, txt =c('Excluded (n=50)\n - Not meeting criteria (n=30)\n - Declined (n=15)\n - Other (n=5)'))
g <- add_box(g, txt =c('Randomized (n=150)'))
g <- add_split(g, txt =c('Allocated to intervention (n=75)\n - Received as allocated (n=70)\n - Did not receive (n=5)','Allocated to control (n=75)\n - Received as allocated (n=73)\n - Did not receive (n=2)'))
g <- add_box(g, txt =c('Lost to follow-up (n=2)\nDiscontinued (n=3)','Lost to follow-up (n=1)\nDiscontinued (n=2)'))
g <- add_box(g, txt =c('Analysed (n=75)\nExcluded from analysis (n=0)','Analysed (n=75)\nExcluded from analysis (n=0)'))
plot(g)
CONSORT is a required element in randomized trial publication (CONSORT 2010 statement, item 13a).
Per-Method Failure Modes
Sankey used when alluvial is appropriate
Trigger: Multi-timepoint cell-state data plotted as Sankey instead of alluvial.
Mechanism: Sankey collapses to source-sink summary; loses entity-trajectory continuity.
Symptom: Reader sees "cluster A -> 50% to B, 50% to C" but cannot trace individual trajectories.
Fix: Use ggalluvial for multi-axis trajectories; Sankey for single-step source-to-sink.
Category ordering within column not specified
Trigger: Default ggalluvial ordering by frequency.
Mechanism: Categories shuffle position across columns; ribbons cross excessively.
Symptom: Visual spaghetti; hard to follow.
Fix: Set explicit factor levels (factor(t1, levels = c('A', 'B', 'C'))) AND consider ggalluvial's lode.guidance to minimize crossings.
Ribbon coloring by destination instead of origin
Trigger:geom_alluvium(aes(fill = t3)) for a "where did these come from" story.
Mechanism: Color encodes the wrong axis; readers misinterpret.
Symptom: Story is "where did final cluster Z come from" but ribbons are colored by Z — every ribbon to Z is the same color.
Fix:aes(fill = t1) if origin matters; aes(fill = t3) if destination matters.
CONSORT diagram missing required boxes
Trigger: Skipping "Lost to follow-up" or "Excluded from analysis" boxes.
Mechanism: CONSORT 2010 requires reporting at each stage.
Symptom: Submission flagged for non-compliance with CONSORT 2010 item 13a.
Fix: Use consort package which scaffolds the required structure; cross-check against CONSORT 2010 statement.
plotly Sankey value sum mismatch
Trigger: Source-to-target sums don't balance.
Mechanism: plotly Sankey requires conservation: sum of in-flows = sum of out-flows at each non-terminal node.