svggosh
GOSH plot (all study subsets)
Does the pooled result depend on which studies are included, and do the subsets fall into clusters?
How to read it
- Read each point as one subset of the studies: x is its pooled estimate, y its I².
- A single compact cloud means the answer barely depends on which studies are in.
- Separate clouds, or a colour that sits apart, point to a study (or group) that differs from the rest.
- Callout 1: Marginal histogram of the subsets' estimates.
- Callout 2: Subsets without the flagged study.
- Callout 3: Subsets with it: shifted and more heterogeneous.
Watch out
- Clusters suggest where to look; they are not a test, and a flagged study is a reason to reread it, not to drop it.
- With few studies there are few subsets, and the cloud has little structure to read.
Defaults
- All-studies estimate
- 0
- The estimate from all studies, drawn as a solid vertical line.
- Range -1,000,000 to 1,000,000, step 0.01
- Null value
- 0
- Where 'no effect' sits on the analysis scale (dashed).
- Range -1,000,000 to 1,000,000, step 0.1
Pinned in the code
- Draws the meta-analysis engine's numbers as given (codesplash.stats.meta_lab in Python ≡ codesplashr in R); the chart computes nothing statistical.
- x is the subset's pooled estimate on the analysis scale (log for ratios), y its I² = (Q − df)/Q in percent; single-study subsets sit at I² = 0.
- When 2^k − 1 exceeds the method's limit the engine fits a seeded random sample of subsets; very large clouds are thinned evenly for drawing (the result says so).
- Colour marks the subsets that contain the study whose inclusion shifts the subsets' mean estimate most (engine column `group`).
# GOSH plot (all study subsets) — Codesplash Chart Lab (recipe "gosh")
# controls: center=0, reference=0
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
try:
import codesplash as cs # optional: the app's chart theme
except ImportError:
cs = None
if cs:
cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]
df = pd.read_csv("gosh-demo.csv", keep_default_na=False, na_values=[""]) # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["subset"] = pd.Categorical(df["subset"].astype("string"), categories=["with Study 7", "without Study 7"])
_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"]) # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"]) # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
EST = "log odds ratio"
I2 = "I² (%)"
GROUP = "subset"
CENTER, REFERENCE = 0, 0 # all-studies estimate; null value
d = df.dropna(subset=[EST, I2])
groups = sorted(d[GROUP].astype(str).unique(), key=lambda g: not g.startswith("with ")) if GROUP else [None]
fig = plt.figure(figsize=(7, 6))
grid = fig.add_gridspec(2, 2, width_ratios=(5, 1), height_ratios=(1, 5), hspace=0.05, wspace=0.05)
ax = fig.add_subplot(grid[1, 0])
top = fig.add_subplot(grid[0, 0], sharex=ax)
side = fig.add_subplot(grid[1, 1], sharey=ax)
for i, g in enumerate(groups):
s = d if g is None else d[d[GROUP].astype(str) == g]
ax.scatter(s[EST], s[I2], s=4, alpha=0.5, color=PALETTE[i], label=g or "subset", linewidths=0)
top.hist(s[EST], bins=40, color=PALETTE[i], alpha=0.45)
side.hist(s[I2], bins=40, range=(0, 100), orientation="horizontal", color=PALETTE[i], alpha=0.45)
ax.axvline(REFERENCE, color=REF, linestyle="--", linewidth=1)
ax.axvline(CENTER, color="black", linewidth=1.2, label="all studies")
ax.set_ylim(0, 100)
ax.set_xlabel(EST)
ax.set_ylabel(I2)
top.axis("off")
side.axis("off")
ax.legend(frameon=False, loc="upper left")
plt.show()Needs pandas, numpy, matplotlib · reads gosh-demo.csv · app theme from the optional codesplash helper
# GOSH plot (all study subsets) — Codesplash Chart Lab (recipe "gosh")
# controls: center=0, reference=0
import numpy as np
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
try:
import codesplash as cs # optional: the app's chart theme
except ImportError:
cs = None
if cs:
cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else px.colors.qualitative.Plotly
df = pd.read_csv("gosh-demo.csv", keep_default_na=False, na_values=[""]) # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV
df["subset"] = pd.Categorical(df["subset"].astype("string"), categories=["with Study 7", "without Study 7"])
_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"]) # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"]) # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
EST = "log odds ratio"
I2 = "I² (%)"
GROUP = "subset"
CENTER, REFERENCE = 0, 0 # all-studies estimate; null value
d = df.dropna(subset=[EST, I2])
groups = sorted(d[GROUP].astype(str).unique(), key=lambda g: not g.startswith("with ")) if GROUP else [None]
fig = go.Figure()
for i, g in enumerate(groups):
s = d if g is None else d[d[GROUP].astype(str) == g]
fig.add_scattergl(x=s[EST], y=s[I2], mode="markers", marker=dict(size=3, color=PALETTE[i], opacity=0.5), name=g or "subset")
fig.add_vline(x=REFERENCE, line_dash="dash", line_color=REF)
fig.add_vline(x=CENTER, line_color="black", annotation_text="all studies")
fig.update_layout(xaxis_title=EST, yaxis_title=I2, yaxis_range=[0, 100])
fig.show()Needs pandas, numpy, plotly · reads gosh-demo.csv · app theme from the optional codesplash helper
# GOSH plot (all study subsets) — Codesplash Chart Lab (recipe "gosh")
# controls: center=0, reference=0
library(ggplot2)
has_cs <- isTRUE(requireNamespace("codesplashr", quietly = TRUE)) # optional: the app's chart theme
theme_cs <- if (has_cs) codesplashr::theme_codesplash(dark = FALSE) else theme_minimal()
cs_cat <- if (has_cs) codesplashr::cs_palette(dark = FALSE)$categorical else grDevices::palette.colors(8, "Okabe-Ito")
if (has_cs) update_geom_defaults("text", list(colour = codesplashr::cs_palette(dark = FALSE)$foreground))
df <- read.csv("gosh-demo.csv", check.names = FALSE, stringsAsFactors = FALSE, na.strings = "") # empty cells are missing; Chart Lab → Code → Download demo CSV
df[["subset"]] <- factor(df[["subset"]], levels = c("with Study 7", "without Study 7"))
tok <- if (has_cs) codesplashr::cs_palette(dark = FALSE) else list()
seq_ramp <- if (is.null(tok$sequential)) c("#eff6fd", "#1a469d") else tok$sequential # low → high
div_ramp <- if (is.null(tok$diverging)) c("#c13e2e", "#f3f5f8", "#0859ac") else tok$diverging # −, 0, +
ref_col <- if (is.null(tok$reference)) "#4e5661" else tok$reference
grey_col <- if (is.null(tok$dim)) "#ced1d6" else tok$dim
est_col <- "log odds ratio"
i2_col <- "I² (%)"
group_col <- "subset"
center <- 0; reference <- 0 # all-studies estimate; null value
d <- df[!is.na(df[[est_col]]) & !is.na(df[[i2_col]]), ]
d$est <- d[[est_col]]; d$i2 <- d[[i2_col]]
d$group <- if (!is.null(group_col)) as.character(d[[group_col]]) else "subset"
lv <- unique(d$group); lv <- c(lv[startsWith(lv, "with ")], lv[!startsWith(lv, "with ")])
d$group <- factor(d$group, levels = lv)
p <- ggplot(d, aes(est, i2, colour = group)) +
geom_point(size = 0.6, alpha = 0.5, shape = 15) +
geom_vline(xintercept = reference, colour = ref_col, linetype = "dashed") +
geom_vline(xintercept = center, colour = "black") +
scale_colour_manual(values = cs_cat[seq_along(lv)], name = NULL) +
coord_cartesian(ylim = c(0, 100)) +
labs(x = est_col, y = i2_col) + theme_cs
print(p)Needs ggplot2 · reads gosh-demo.csv · app theme from the optional codesplashr helper