File size: 4,790 Bytes
141bacd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
"""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,
    })