Gene-Expression Signatures¶
TCRsift defines gene-expression signatures across two modules:
tcrsift.signatures(T_CELL_SIGNATURES): compact unsigned marker panels for per-cell and per-clone state scoring, plus cell-type registries forannotate_cells.tcrsift.signature_methods(SIGNATURESandNEOANTIGEN_SIGNATURES): signed z-score panels and published neoantigen-reactivity gene sets used bytcrsift prioritizeandscore_by_name.
Signature scores quantify transcriptional state rather than epitope
specificity, and depend on tissue context: AIM and AcuteActivation reflect
recent stimulation in culture, whereas TumorReactive and exhaustion panels
reflect chronic antigen exposure in fresh TIL.
Compact functional programs (T_CELL_SIGNATURES)¶
Human signatures follow HGNC nomenclature (T_CELL_SIGNATURES); mouse
counterparts (MOUSE_T_CELL_SIGNATURES, retrieved via
t_cell_signatures_for_species("mouse")) use MGI orthologs (dropping GNLY and
CXCL13, which lack 1:1 murine T-cell orthologs).
| Name | Genes | Intended readout |
|---|---|---|
effector |
IFNG, GZMB, PRF1, GNLY, NKG7 |
Cytotoxic effector differentiation |
activation |
Deprecated alias of effector |
Retained for backward compatibility |
naive_stem |
TCF7, LEF1, CCR7, SELL, IL7R, CD27, CD28 |
Naive and stem-like memory state |
antigen_response |
TNFRSF9, MKI67 |
Recent activation and proliferation |
aim |
TNFRSF9, TNFRSF4, IL2RA, MKI67 |
Activation-induced-marker response in stimulated culture |
cytolytic |
PRF1, GZMB |
Minimal perforin/granzyme B readout |
exhaustion |
PDCD1, TOX, LAG3, HAVCR2, TIGIT |
Chronic stimulation / exhaustion in TIL |
tumor_reactive |
CXCL13, ENTPD1 |
Minimal two-gene tumor-reactive TIL readout |
expansion_core |
MKI67, TNFRSF9, EGR2, IFNG, CXCL13, HAVCR2 |
Cross-compartment expansion-associated markers |
MARKER_PANEL_HGNC is the combined gene extraction list used by til-select
rather than a standalone biological signature.
Signatures scored by tcrsift prioritize (SIGNATURES)¶
tcrsift prioritize selects panels by these names (--signatures,
--context), scoring each cell as the mean of within-sample z-scored positive
genes minus negative genes:
| Name | Up genes | Down genes | Provenance |
|---|---|---|---|
Differentiated |
IFNG, GZMB, PRF1, GNLY, NKG7 |
TCF7, LEF1, CCR7, SELL |
Canonical effector minus naive/stem markers, fixed on the two-donor MART-1 pilot (reproducibility map) |
AntigenExperienced |
IFNG, GZMB, PRF1, GNLY, NKG7 |
— | Positive arm of Differentiated |
Cytolytic |
PRF1, GZMB |
— | Perforin and granzyme B (Caushi 2021, Krishna 2020, Hanada 2022) |
AcuteActivation |
TNFRSF9, MKI67 |
— | 4-1BB and Ki-67, separated from AntigenExperienced after the MART-1 pilot |
Proliferation |
MKI67 |
— | Ki-67 alone |
AIM |
TNFRSF9, TNFRSF4 |
— | 4-1BB and OX40 mRNAs corresponding to surface AIM sorting |
TumorReactive |
CXCL13, ENTPD1, PDCD1, LAG3, HAVCR2, TIGIT, TOX, CTLA4, ITGAE |
— | CD39 and CD103 (Simoni 2018, Duhen 2018) plus CXCL13 and six TIL exhaustion markers |
Broad variants and CirculatingMemory are also registered in SIGNATURES.
Note that nine-gene TumorReactive above is broader than the two-gene
tumor_reactive entry in T_CELL_SIGNATURES. Empirical AUROCs across five
public tumor datasets are reported in Benchmark on public TIL
data.
Published neoantigen-reactivity registry (NEOANTIGEN_SIGNATURES)¶
score_by_name dispatches each signature using its registered scoring method:
| Name | Reference | TCRsift scoring rule |
|---|---|---|
MANAscore |
Zeng et al., Nat Commun 2025 (PMID 39900903) | Unweighted three-gene signed-z proxy: (z(CXCL13) + z(ENTPD1) - z(IL7R)) / sqrt(3). Does not run the paper's fitted random-forest/linear ensemble. |
NeoTCR8 |
Lowery et al., Science 2022 (PMID 35113651) | Published 243-gene CD8 set via Scanpy score_genes |
NeoTCR4 |
Lowery et al., Science 2022 (PMID 35113651) | Published 40-gene CD4 set via Scanpy score_genes |
NeoTCR_PBL |
Yossef et al., Cancer Cell 2023 (PMID 38039963) | Published 151-gene circulating CD8 set via Scanpy score_genes (blood-tumor preset) |
Scoring notes for NeoTCR4, NeoTCR8, and NeoTCR_PBL:
- AnnData inputs: pass an
AnnDatawhose.Xcontains the fulllog1p(CP10K)-normalized transcriptome withlog1p=False(score_by_namealways reads.Xrather than.raw, and does not apply a second logarithm). Scores are Scanpyscore_genesmodule scores (signature mean minus expression-matched control-gene mean), not single-cell GSEA; numeric scGSEA cutoffs from the original papers do not transfer. - DataFrame inputs: because a subset
DataFramelacks the full gene universe needed for expression-matched control bins,score_by_namewarns and falls back to mean per-gene z-scores (applyinglog1pfirst by default; passlog1p=Falseif values are already log-normalized).
Usage¶
Compact unsigned panels:
from tcrsift import compute_signature_scores_per_cell
compute_signature_scores_per_cell(adata)
print([col for col in adata.obs if col.startswith("signature_")])
Signed and published signatures:
import scanpy as sc
from tcrsift import score_by_name
sc.pp.normalize_total(adata, target_sum=10_000)
sc.pp.log1p(adata)
for name in ("MANAscore", "NeoTCR8", "NeoTCR4"):
score_by_name(adata, name, log1p=False, key_added=f"signature_{name}")
In multi-sample cohorts, normalize and score within each sample before aggregating clonotypes so sample-wide baseline shifts do not dominate rankings; see Clone Prioritization.
Cell-type and state registries¶
Used by tcrsift.annotate_cells:
| Registry constant | Contents |
|---|---|
CELL_TYPE_SIGNATURES / PBMC_CELL_TYPE_SIGNATURES |
Default blood/PBMC immune and basic stromal cell-type markers |
SOLID_TUMOR_CELL_TYPE_SIGNATURES |
PBMC lineages plus solid-tissue stromal, neural, muscle, mesothelial, and osteoclast markers |
T_STATE_SIGNATURES, B_STATE_SIGNATURES |
T-cell and B-cell functional sub-state markers |
PBMC_CULTURE_TYPES |
Cell-type allow-list for Ficoll-isolated PBMC cultures |
Malignant clusters are typed with tumor_override / MarkerCountOverride
rather than a fixed signature in these registries.
signatures ¶
Canonical T-cell and single-cell lineage gene-set signatures (human & mouse).
Single source of truth for the gene sets used across clone prioritization, TIL selection, per-sample scatter plots, and single-cell cluster annotation.
Gene symbols are stored uppercase to match :func:tcrsift.genes.adata_symbol_array
uniformly across human HGNC (GZMB, CD8B) and mouse MGI (Gzmb → GZMB,
Cd8b1 → CD8B1). Species-specific registries handle genes that lack 1:1
orthologs across species (for example, human GNLY, GZMH, FGFBP2,
KLRF1, NCR3, FCN1, CD1C, LILRA4, FCGR3B have no mouse
ortholog, and mouse NK cells express Ncr1/Klrb1c/Itga2/Klra*
rather than NCAM1/KIR*).
EFFECTOR_GENES_HGNC
module-attribute
¶
ACTIVATION_GENES_HGNC
module-attribute
¶
NAIVE_STEM_GENES_HGNC
module-attribute
¶
ANTIGEN_RESPONSE_GENES_HGNC
module-attribute
¶
AIM_GENES_HGNC
module-attribute
¶
EXHAUSTION_GENES_HGNC
module-attribute
¶
TUMOR_REACTIVE_GENES_HGNC
module-attribute
¶
EXPANSION_CORE_GENES_HGNC
module-attribute
¶
EXPANSION_CORE_GENES_HGNC: tuple[str, ...] = ('MKI67', 'TNFRSF9', 'EGR2', 'IFNG', 'CXCL13', 'HAVCR2')
MARKER_PANEL_HGNC
module-attribute
¶
MARKER_PANEL_HGNC: tuple[str, ...] = ('CD4', 'CD8A', 'CD8B', 'MKI67', 'TNFRSF9', 'TNFRSF4', 'IL2RA', 'TNFRSF18', 'NR4A1', 'NR4A2', 'EGR2', 'CTLA4', 'PRF1', 'GZMB', 'GZMK', 'NKG7', 'GNLY', 'IFNG', 'PDCD1', 'TOX', 'LAG3', 'HAVCR2', 'TIGIT', 'ENTPD1', 'CXCL13', 'ITGAE')
T_CELL_SIGNATURES
module-attribute
¶
T_CELL_SIGNATURES: dict[str, tuple[str, ...]] = {'effector': EFFECTOR_GENES_HGNC, 'activation': ACTIVATION_GENES_HGNC, 'naive_stem': NAIVE_STEM_GENES_HGNC, 'antigen_response': ANTIGEN_RESPONSE_GENES_HGNC, 'aim': AIM_GENES_HGNC, 'cytolytic': CYTOLYTIC_GENES_HGNC, 'exhaustion': EXHAUSTION_GENES_HGNC, 'tumor_reactive': TUMOR_REACTIVE_GENES_HGNC, 'expansion_core': EXPANSION_CORE_GENES_HGNC}
signature_methods ¶
Gene-expression signatures as synthetic selection methods.
The selection language (:mod:tcrsift.selection) is method-agnostic — a
"method" is just a value in the per-(clone, sample) table carrying a
tier + frequency. A method need not be a physical sort: this module scores
cells on a gene set, calls signature-positive cells, and emits them as a
synthetic method so the rules can use a signature like a sort.
Signatures are signed (genes_up − genes_down, so loss-of-naive
axes work). Canonical scoring (defaults): per gene, the z-score across
cells of log(1 + TPM), then the mean of those z-scores across the
signature (combine="mean" instead averages the values directly).
Small "focal" and larger "broad" panels are offered per axis.
NOTE: a signature's meaning still depends on the sample source — e.g.
TumorReactive (CD39/CD103/TOX) only reads "chronic in-situ antigen
exposure" in fresh tissue TILs, not in PBMC culture. That caveat lives in
each signature's description; it is documentation, not an enforced
guard, so you can still score any signature on any data (and should, when
exploring). Gene memberships are literature-backed defaults for tuning.
SIGNATURES
module-attribute
¶
SIGNATURES: dict[str, Signature] = {s.name: s for s in _INVARIANT_SIGNATURES + _COMPOSITE_SIGNATURES}
NEOANTIGEN_SIGNATURES
module-attribute
¶
NEOANTIGEN_SIGNATURES: dict[str, Signature] = {'MANAscore': Signature('MANAscore', MANASCORE_UP_HGNC, MANASCORE_DOWN_HGNC, panel='focal', units='log1p', method='weighted_z', citation='Zeng/Smith, Nat Commun 2025 (PMID 39900903)', description='Transparent signed-z proxy for MANAscore: (z(CXCL13)+z(ENTPD1)-z(IL7R))/sqrt(3) on log1p CP10K. The published model is a trained RF+linear ensemble with NO closed-form per-gene weights; only the gene directions (+CXCL13,+ENTPD1,-IL7R) and input units (log-normalized) are reproducible, and that is what this scores. The faithful pickled ensemble is deliberately NOT shipped (deserializing a third-party pickle is an arbitrary-code-execution risk).'), 'NeoTCR8': Signature('NeoTCR8', NEOTCR8_GENES_HGNC, panel='broad', units='log1p', method='geneset_enrichment', citation='Lowery/Rosenberg, Science 2022 (PMID 35113651)', description="243-gene CD8 neoantigen-reactive set (Table S10). An unweighted gene set scored here with Scanpy's expression-matched control subtraction. This is not the paper's scGSEA implementation and does not inherit its thresholds."), 'NeoTCR4': Signature('NeoTCR4', NEOTCR4_GENES_HGNC, panel='broad', units='log1p', method='geneset_enrichment', citation='Lowery/Rosenberg, Science 2022 (PMID 35113651)', description="40-gene CD4 neoantigen-reactive set (Table S10). An unweighted gene set scored here with Scanpy's expression-matched control subtraction, not the paper's scGSEA implementation."), 'NeoTCR_PBL': Signature('NeoTCR_PBL', NEOTCRPBL_GENES_HGNC, panel='broad', units='log1p', method='geneset_enrichment', citation='Yossef/Rosenberg, Cancer Cell 2023 (PMID 38039963)', description="151-gene signature of circulating (peripheral-blood) neoantigen-reactive CD8 T cells (cluster C9, avg_log2FC>=0.5; Table S2D). An unweighted gene set scored here with Scanpy's expression-matched control subtraction. Distinct from Lowery's TIL-derived NeoTCR8/4 — a separate blood-derived signature.")}
Signature
dataclass
¶
A named, optionally-signed gene signature.
genes_down subtracts (loss-of-naive etc.). panel is a
"focal"/"broad" label for the small-vs-large variants. description
carries the biological caveat (e.g. which sample source it's meaningful
in) as prose.
units, method and citation (#309) record how a published
signature is meant to be scored, so heterogeneous signatures
(MANAscore-style signed-z proxies vs. unweighted control-subtracted gene
sets) can live in one registry and be dispatched correctly by
:func:score_by_name rather than all being treated as weighted sums:
units— the input space the score is defined on:"log1p"(log1p CP10K, the default),"cp10k","scaled"or"ranks".method— the scoring rule:"zscore"(mean of per-gene z-scores, the default and what :func:score_signaturecomputes),"weighted_z"(signed-sum of per-gene z-scores /sqrt(n)— the transparent MANAscore proxy), or"geneset_enrichment"(Scanpy control-subtracted module score for published sets like NeoTCR4/8).citation— the source paper (free text, incl. PMID).
Defaults keep every pre-existing signature a plain zscore /
log1p signature, so this is backward compatible.
Source code in tcrsift/signature_methods.py
score_by_name ¶
score_by_name(data, name, *, registry: dict[str, Signature] | None = None, log1p: bool | None = None, background: DataFrame | None = None, groups: Series | None = None, on_missing: str = 'warn', layer: str | None = None, key_added: str | None = None, species: str | None = None) -> pd.Series
Score a registered signature on cells, dispatched by its method (#309).
data is either an AnnData (per-cell scores from .X / layer,
symbol resolution via the shared resolver) or a cells × genes symbol-keyed
DataFrame. name is a registry key (case-insensitive) or a
:class:Signature. Routing:
weighted_z→ :func:score_weighted_z(MANAscore-style signed-z),zscore/mean→ :func:score_signature,geneset_enrichment→ scanpyscore_geneson an AnnData (control-subtracted module score), or a mean-z proxy on a bare frame.
log1p defaults from the signature's units (applied for
log1p/cp10k inputs, skipped for scaled/ranks); pass a bool
to override. key_added (AnnData only) writes the score to
adata.obs[key_added] in addition to returning it.
Source code in tcrsift/signature_methods.py
1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 | |