PANDA / scripts /figures /palette.py
bryan7264's picture
Correction pass: gate-matched Dahlin, retracted unsupported claims, complete HF-placode DEG set, restyled figures
141bacd verified
Raw
History Blame Contribute Delete
4.79 kB
"""canonical class -> color mapping shared across every panda figure.
related classes share hue families (fibroblasts red, keratinocytes orange,
melanocyte lineage purple, endothelial teal, immune yellow, etc.). every
figure imports CLASS_COLORS[cls] so class X gets the same color everywhere.
"""
# skin (13 classes)
_SKIN = {
"basal-IFE": "#e07b39", # keratinocyte orange
"spinous": "#c94f21",
"granular": "#a53818",
"HF-placode": "#8b4513", # hair follicle brown
"HF-ORS": "#c68e4b",
"sebaceous": "#bfa970",
"fibroblast-papillary": "#d94848", # fibroblast reds
"fibroblast-reticular": "#8f1e1e",
"endothelial": "#2e8b8b", # vascular teal
"immune": "#d1c02b", # immune yellow
"melanoblast": "#6a5acd", # melanocyte purples
"melanocyte-precursor": "#9370db",
"melanocyte": "#4b3ca3",
}
# hematopoiesis (15 classes)
_HSC = {
"LT-HSC": "#1a3d78", # stem dark blue
"MPP": "#7d5fc9", # progenitor purple (was teal → indistinguishable from lymphoid/endothelial)
"erythroid": "#c1272d", # red lineage
"megakaryocyte": "#a1204b",
"basophil-mast": "#e07b39",
"myeloid": "#8a5822", # myeloid browns (dark)
"monocyte": "#d4a373", # tan — distinct from myeloid brown & macrophage
"macrophage": "#6b4321",
"lymphoid": "#1e7a4f", # lymph greens (was #2e8b8b → exact duplicate of endothelial)
"T-cell": "#3aa17f",
"naive-B": "#5cbf88",
"pro-B": "#7fd39d",
"endothelial": "#2e8b8b", # shared with skin
"fibroblast": "#8f1e1e",
"stromal": "#6b4a3b",
}
# pancreas (20 classes)
_PANC = {
"alpha": "#a3123a", # alpha reds
"adult-alpha": "#7a0e2b",
"alpha_progenitor": "#d94360",
"beta": "#1f4e9e", # beta blues
"adult-beta": "#123469",
"beta_progenitor": "#4d78c4",
"delta": "#7d3c98", # delta purple
"gamma": "#af7ac5",
"epsilon": "#f39c12", # epsilon orange
"Fev-EP": "#e67e22", # endocrine progenitor oranges
"endocrine-progenitor": "#c68e4b",
"endocrine-progenitor-primed": "#a86b28",
"pancreatic-progenitor": "#16a085", # progenitor greens
"proliferating": "#48c9b0",
"acinar": "#8a5822", # exocrine browns
"exocrine": "#5d3a11",
"ductal": "#7b6b57",
"endothelial": "#2e8b8b", # shared
"immune": "#d1c02b",
"mesenchyme": "#6b4a3b",
}
# every class from every system, plus a safe fallback
CLASS_COLORS = {**_SKIN, **_HSC, **_PANC}
# canonical genotype / condition colors
GENOTYPE_COLORS = {
"WT": "#1f77b4",
"En1-cKO": "#d62728",
"Kit_W41": "#d62728",
"control": "#1f77b4",
"other": "#bbbbbb",
}
# stage colors (viridis-ish for ordinal)
STAGE_COLORS = {
"3": "#440154",
"4": "#3b528b",
"5": "#21918c",
"6": "#fde725",
}
# shared font-size constants (style spec): small titles, larger body text.
SUPTITLE_FS = 15 # figure suptitles
TITLE_FS = 14 # panel / axes titles
LABEL_FS = 13 # axis labels
TICK_FS = 12 # tick labels
LEGEND_FS = 11 # legend text
ANNOT_FS = 11 # in-plot annotations
CBAR_FS = 12 # colorbar labels
def color_for(cls, fallback="#888888"):
"""look up a class name; return fallback if missing."""
if cls in CLASS_COLORS:
return CLASS_COLORS[cls]
# simple aliases
s = str(cls).strip()
return CLASS_COLORS.get(s, fallback)
def apply_style():
"""shared rcparams; call at top of every figure script."""
import matplotlib.pyplot as plt
plt.rcParams.update({
"font.family": "DejaVu Sans",
"font.size": 12,
"axes.titlesize": TITLE_FS,
"axes.labelsize": LABEL_FS,
"xtick.labelsize": TICK_FS,
"ytick.labelsize": TICK_FS,
"legend.fontsize": LEGEND_FS,
"legend.title_fontsize": LEGEND_FS + 1,
"figure.titlesize": SUPTITLE_FS,
"pdf.fonttype": 42,
"ps.fonttype": 42,
"axes.spines.top": False,
"axes.spines.right": False,
"axes.linewidth": 1.2,
"xtick.major.width": 1.2,
"ytick.major.width": 1.2,
})