Publication-Ready Figures
Most analysis ends in a figure, and a small set of figures does most of the work in a biology methods section. A box plot with a p-value. A survival curve. A clustered heatmap. This section builds each one twice, in R and in Python, from the same tidy data, with the right statistical test wired into the plot rather than bolted on after.
The approach is the one a bench scientist recognizes from GraphPad Prism: pick the test the data supports, draw the comparison, and put the result on the figure where a reviewer will see it. The difference is that here the figure, its code, and its numbers are all reproducible. Every figure on these pages is produced by a real run in a pinned container, the same one for both languages.
The catalog
Section titled “The catalog”| Figure | What it compares | Test on the plot |
|---|---|---|
| Two-group comparison | one outcome, two groups | t-test or Mann-Whitney, chosen from the data |
| Multi-group comparison | one outcome, three or more groups | one-way ANOVA + Tukey HSD |
| Factorial ANOVA | one outcome, two crossed factors | Type II ANOVA with interaction |
| Kaplan-Meier survival | time to event, two arms | log-rank |
| Cox forest plot | adjusted hazard per covariate | Cox proportional hazards |
| Clustered heatmap | expression, features by samples | hierarchical clustering |
The two toolchains
Section titled “The two toolchains”Each page shows the same figure in both languages, in synced tabs, so you can read whichever you know and see its twin.
- R uses
ggpubrandrstatixfor the comparison plots,survminerfor survival, andComplexHeatmapfor the heatmap. All build onggplot2. - Python uses
seabornwithstatannotationsandpingouinfor the comparison plots,lifelinesfor survival, andseaborn.clustermapfor the heatmap.
Where both languages compute the same statistic, they agree: the two-group t-test
matches to nine significant figures, the ANOVA and the log-rank agree to the digit. The
figures themselves are drawn each library’s idiomatic way, so they look alike without
being pixel-identical. The runnable code and fixtures for every page live in the
companion code repo under guides/figures/.