Test the broad cell-type names that the PBMC analysis gives the 12 Leiden clusters against the marker statistics of every gene, and refine the names where several markers agree. The data are the 3,948 human peripheral blood mononuclear cells (PBMCs) that pass quality control in the 10x Genomics 5k PBMC dataset from a healthy donor (tenx_5K_pbmc_rnaseq). Six of seven genes that encode flow cytometry lineage markers mark the expected clusters at the RNA level, while CD4 transcripts are detected more often in monocytes than in T cells. Each cluster’s leading markers and a dot plot of T-cell and NK genes then confirm the 25 CD16 monocytes and support five finer names: naive B cells (256 cells), memory-like B cells (239), naive-like CD8 T cells (166), CD56-bright NK cells (29), and plasmacytoid dendritic cells (pDCs, 15).
Open the prepared analysis¶
# Import NumPy and pandas for the cell-type arrays and tables, and CyteArc for the analysis and plots.
import numpy as np
import pandas as pd
import cytearc
from cytearc.plotting import CategoricalScale, CellField, NamedCellArtifact
# Keep routine logs and progress bars out of the outputs.
cytearc.configure_output(level="WARNING", progress=False)
# Download the prepared PBMC store, which holds the saved RNA analysis.
dataset = cytearc.datasets.connect("cytearc_docs").download_dataset(
"tenx_5K_pbmc_rnaseq", destination="cytearc_datasets", zarr=True
)Started: 2026-11-18T00:15:52.109499Z | Wall time: 5.031 s
A saved pipeline run keeps the cells, settings, and results of one analysis together. ds.pipeline.open(label="rna") reopens that analysis, and run["clusters"] refers to its clustering result. ds.markers.search compares each cluster with the other analyzed cells for every gene of the RNA assay, the 33,538 that run["feature_universe"] selects, and saves the statistics in the store as a marker table.
# Open the store and its saved RNA run.
ds = cytearc.DataStore(f"{dataset}/data.zarr")
run = ds.pipeline.open(label="rna")
clusters = run["clusters"]
# Test every gene of the RNA assay in each cluster.
markers = ds.markers.search(clusters, features=run["feature_universe"])
# Read each analyzed cell's cluster, in the run's cell order.
cluster_values = run.cells.fetch("clusters").astype(str)
dsDataStore has 3948 (5025) cells with 1 assays: RNA
Cell metadata:
'I', 'ids', 'names', 'RNA_G2M_score', 'RNA_S_score',
'RNA_UMAP1', 'RNA_UMAP2', 'RNA_cell_cycle_phase', 'RNA_clusters', 'RNA_doublet_score',
'RNA_leiden_cluster', 'RNA_nCounts', 'RNA_nFeatures', 'RNA_paris_cluster', 'RNA_percentMito',
'RNA_percentRibo'
RNA assay has 33538 features and following metadata:
'I', 'ids', 'names', 'dropOuts', 'feature_type',
'genome', 'nCells'Started: 2026-11-18T00:15:57.150505Z | Wall time: 23.422 s
The store holds 5,025 cells, and the run analyzed the 3,948 that passed quality control.
Read the marker evidence¶
ds.markers.load returns one row per gene and cluster. The columns that the next cell shows are:
| Column | Meaning |
|---|---|
score | Specificity from 0 to 1: the cluster’s mean expression rank as a share of the sum over all clusters. It ranks markers within one clustering and shrinks as the number of clusters grows, so no default filter uses it. |
frac_exp, frac_exp_rest | Fraction of cells with a nonzero count, in the cluster and in the other analyzed cells. |
fold_change | Mean library-size normalized expression in the cluster divided by the mean in the other cells, or inf when no other cell expresses the gene. Read it with frac_exp, because a few cells can drive a large ratio. |
auc | Area under the ROC curve: the probability that a cell of the cluster ranks above one of the other cells. 0.5 means no separation, and values below 0.5 mean lower expression in the cluster. |
neg_log10_p_value | Minus log10 of the two-sided Mann-Whitney U p-value, with cells as the units. CyteArc computes it in log space, so it stays finite where the p-value itself underflows to 0. The max_p_adj filter reads the p-values after Benjamini-Hochberg adjustment within the cluster. |
The default filters, written out in the next cell, keep genes detected in at least 20% of the cluster’s cells (min_frac_exp=0.2), with an AUC of at least 0.6 (min_auc=0.6) and an adjusted p-value of at most 0.05 (max_p_adj=0.05), sorted by score. Start with cluster 2:
# Load cluster 2's markers that pass the default filters, written out here.
group_markers = ds.markers.load(
marker=markers, group_id="2", min_frac_exp=0.2, min_auc=0.6, max_p_adj=0.05
)
# Show the ten highest-scoring markers with the statistics behind each.
marker_columns = [
"feature_name",
"score",
"frac_exp",
"frac_exp_rest",
"fold_change",
"auc",
"neg_log10_p_value",
]
group_markers[marker_columns].head(10).round(2)| feature_name | score | frac_exp | frac_exp_rest | fold_change | auc | neg_log10_p_value | |
|---|---|---|---|---|---|---|---|
| 0 | S100A12 | 0.95 | 0.96 | 0.01 | 832.51 | 0.98 | 766.65 |
| 1 | VCAN | 0.92 | 0.98 | 0.03 | 367.79 | 0.99 | 748.76 |
| 2 | CD14 | 0.92 | 0.97 | 0.02 | 427.90 | 0.98 | 766.04 |
| 3 | CLEC4E | 0.89 | 0.60 | 0.00 | 852.15 | 0.80 | 464.56 |
| 4 | ALDH1A1 | 0.89 | 0.53 | 0.00 | 659.79 | 0.76 | 404.44 |
| 5 | CD163 | 0.88 | 0.51 | 0.00 | 442.37 | 0.76 | 390.87 |
| 6 | STAB1 | 0.87 | 0.63 | 0.01 | 95.13 | 0.81 | 459.13 |
| 7 | QPCT | 0.87 | 0.48 | 0.00 | 377.88 | 0.74 | 359.74 |
| 8 | CYP27A1 | 0.87 | 0.47 | 0.00 | 370.97 | 0.74 | 356.24 |
| 9 | CREB5 | 0.86 | 0.53 | 0.00 | 170.24 | 0.76 | 394.90 |
Started: 2026-11-18T00:16:20.575386Z | Wall time: 0.118 s
Cluster 2 holds classical CD14 monocytes. Its three leading markers, S100A12, VCAN, and CD14, are each detected in 96% to 98% of its cells and in 1% to 3% of the other cells, with AUCs of 0.98 to 0.99. Their neg_log10_p_value of 749 to 767 reflects the hundreds of cells that the test counts as independent observations, so the AUC and the detected fractions, not the p-value, show how well a gene separates a cluster.
Check the broad names with lineage genes¶
Seven genes that encode the surface markers flow cytometry uses for the main lineages check the broad names on the UMAP: CD14 for classical monocytes, FCGR3A (CD16) for nonclassical monocytes and most NK cells, CD19 for B cells, CD8A and CD4 for T-cell subsets, NCAM1 (CD56) for NK cells, and IL3RA (CD123) for pDCs.
# Draw the clusters, numbered on the UMAP and titled for readers, beside seven lineage genes.
panel_genes = ["CD14", "FCGR3A", "CD19", "CD8A", "CD4", "NCAM1", "IL3RA"]
ds.plots.embedding(
layout=run["umap"],
color_by=[NamedCellArtifact("Leiden cluster", clusters), *panel_genes],
n_columns=4,
legend_loc="on_data",
figsize=(10, 5.4),
)
Started: 2026-11-18T00:16:20.696512Z | Wall time: 3.207 s
CD14 marks cluster 2 on the right but not its upper tip, cluster 10, where FCGR3A is brightest. FCGR3A also marks NK cluster 5 at the bottom, and NCAM1 marks clusters 5 and 9 there. CD19 marks clusters 6 and 7 at the top, CD8A cluster 8 at the left edge of the T-cell island and the lower part of cluster 3, and IL3RA only the small cluster 11. CD4 is patchy across the T-cell island and denser in the monocytes.
The default filters hide weak and negative evidence. Load every row of the marker table once with the filters turned off, and find the cluster where each panel gene scores highest:
# Load every gene of every cluster, including weak and negative evidence, for the checks below.
all_markers = ds.markers.load(
marker=markers, min_frac_exp=None, min_auc=None, max_p_adj=None
)
# Find the cluster where each panel gene scores highest.
panel_stats = all_markers[all_markers["feature_name"].isin(panel_genes)]
panel_best = (
panel_stats.sort_values("score", ascending=False)
.groupby("feature_name", sort=False)
.head(1)
.set_index("feature_name")
.reindex(panel_genes)
)
panel_best[["group_id", "score", "frac_exp", "frac_exp_rest", "auc"]].round(2)| group_id | score | frac_exp | frac_exp_rest | auc | |
|---|---|---|---|---|---|
| feature_name | |||||
| CD14 | 2 | 0.92 | 0.97 | 0.02 | 0.98 |
| FCGR3A | 10 | 0.49 | 1.00 | 0.14 | 0.99 |
| CD19 | 6 | 0.52 | 0.61 | 0.05 | 0.78 |
| CD8A | 8 | 0.46 | 0.79 | 0.08 | 0.85 |
| CD4 | 2 | 0.33 | 0.76 | 0.27 | 0.77 |
| NCAM1 | 9 | 0.52 | 0.66 | 0.03 | 0.81 |
| IL3RA | 11 | 0.79 | 1.00 | 0.02 | 1.00 |
Started: 2026-11-18T00:16:23.906510Z | Wall time: 0.782 s
The table confirms the UMAP panels of CD14, FCGR3A, CD19, CD8A, NCAM1, and IL3RA, with AUCs from 0.78 (CD19) to 1.00 (IL3RA). Every cell of cluster 10 detects FCGR3A, and every cell of cluster 11 detects IL3RA, against 14% and 2% of the other cells. CD4 instead scores highest in monocyte cluster 2, where 76% of cells detect it against 27% elsewhere (AUC 0.77). Human monocytes express CD4, and no T-cell cluster detects it in even half of its cells, as the table under the dot plot below shows, so CD4 RNA alone cannot mark CD4 T cells.
Apart from CD4, these patterns agree with the broad names of the PBMC analysis, whose own panel adds the T-cell genes CD3D and IL7R that name clusters 1 and 4 and the platelet genes PPBP and PF4 that name cluster 12. Several clusters share a broad name:
# Take each cluster's broad name from the PBMC analysis, and count its cells.
broad_names = {
"1": "T cells",
"2": "CD14 monocytes",
"3": "T cells",
"4": "T cells",
"5": "NK cells",
"6": "B cells",
"7": "B cells",
"8": "T cells",
"9": "NK cells",
"10": "CD16 monocytes",
"11": "pDC-like cells",
"12": "platelets",
}
broad_table = pd.Series(broad_names, name="broad_cell_type").to_frame()
broad_table["cells"] = pd.Series(cluster_values).value_counts()
broad_table| broad_cell_type | cells | |
|---|---|---|
| 1 | T cells | 1217 |
| 2 | CD14 monocytes | 704 |
| 3 | T cells | 528 |
| 4 | T cells | 474 |
| 5 | NK cells | 283 |
| 6 | B cells | 256 |
| 7 | B cells | 239 |
| 8 | T cells | 166 |
| 9 | NK cells | 29 |
| 10 | CD16 monocytes | 25 |
| 11 | pDC-like cells | 15 |
| 12 | platelets | 12 |
Started: 2026-11-18T00:16:24.694120Z | Wall time: 0.016 s
Check each name against its leading markers¶
A heatmap of each cluster’s three highest-scoring genes shows whether several genes support each name. Expression is standardized across clusters, and the columns follow marker similarity rather than cluster number.
# Plot the three highest-scoring genes of each cluster, standardized across clusters.
ds.plots.marker_heatmap(marker=markers, topn=3, figsize=(6, 6))
Started: 2026-11-18T00:16:24.734718Z | Wall time: 2.138 s
Monocytes: the 25-cell cluster 10 leads with CTSL, TCF7L2, and SMIM25 rather than the classical markers of cluster 2, detects FCGR3A (CD16) in every cell, and stays dark in the CD14 panel: the profile of nonclassical CD16 monocytes, which confirms the name that the PBMC analysis gave the cluster.
B cells: cluster 6 leads with IGHD, FCER2 (CD23), and TCL1A, the profile of naive B cells, and cluster 7 with the class-switched immunoglobulins IGHA1 and IGHG1 and with TNFRSF13B (TACI), the profile of memory B cells.
NK cells: FGFBP2, ADGRG1, and AKR1C3 lead cluster 5, which FCGR3A also marks: the profile of cytotoxic CD56-dim NK cells. XCL1, KLRC1, and XCL2 lead the 29-cell cluster 9, where NCAM1 (CD56) scores highest and FCGR3A stays dim: the profile of CD56-bright NK cells.
T cells: GZMK, TRGC2, and CD8A lead cluster 3, and LINC02446, CD8B, and NOG lead cluster 8. Clusters 1 and 4 lead with ADTRP, ANKRD55, and TCEA3, and with TNFRSF4, NPDC1, and AQP3. The next section reads all four T-cell clusters with canonical T-cell genes.
pDCs: SERPINF1, TPM2, and LILRA4 lead the 15-cell cluster 11. LILRA4 and IL3RA together mark pDCs, which settles the provisional name that the PBMC analysis gave the cluster from GZMB and JCHAIN.
Platelets: F13A1, ACRBP, and PTGS1 lead the 12-cell cluster 12, alongside the platelet genes PPBP and PF4 that name it in the PBMC analysis.
Separate T-cell states from NK cells¶
The four T-cell clusters differ in CD8 and naive-state genes, and NK cells share cytotoxic genes with some T cells. A dot plot compares T-cell, CD4 and CD8, naive-like, and cytotoxic genes across all 12 clusters. Dot size is the fraction of a cluster’s cells that detect the gene, and color is the gene’s mean expression standardized across clusters:
# Group the genes by the identity or state they mark.
t_nk_panel = {
"T cell": ["CD3D", "CD3E"],
"CD4 or CD8": ["CD4", "CD8A", "CD8B"],
"Naive-like": ["CCR7", "IL7R", "CD27"],
"Cytotoxic": ["GZMK", "NKG7", "GNLY"],
}
# Scale each gene's mean across clusters, so genes with low expression use the full color range.
t_nk_dots = ds.plots.dotplot(
features=t_nk_panel,
groups=clusters,
standardize="feature",
swap_axes=True,
show=False,
)
# Name the cluster axis, then display the figure.
t_nk_dots.axes["dotplot"].set_ylabel("Cluster")
t_nk_dots.show()
Started: 2026-11-18T00:16:26.876519Z | Wall time: 0.753 s
CD27 marks memory B cells as well as naive T cells, and its dot is large in B-cell cluster 7 and small in cluster 6, in line with the memory and naive names from their leading markers. The table lists the fractions behind the dots for the four T-cell and two NK clusters:
# Tabulate the detected fraction behind each dot for the T-cell and NK clusters.
t_nk_genes = [gene for genes in t_nk_panel.values() for gene in genes]
t_nk_detection = all_markers[all_markers["feature_name"].isin(t_nk_genes)].pivot(
index="group_id", columns="feature_name", values="frac_exp"
)
t_nk_detection.loc[["1", "3", "4", "8", "5", "9"], t_nk_genes].round(2)| feature_name | CD3D | CD3E | CD4 | CD8A | CD8B | CCR7 | IL7R | CD27 | GZMK | NKG7 | GNLY |
|---|---|---|---|---|---|---|---|---|---|---|---|
| group_id | |||||||||||
| 1 | 0.97 | 0.98 | 0.39 | 0.01 | 0.05 | 0.84 | 0.88 | 0.81 | 0.02 | 0.06 | 0.06 |
| 3 | 0.97 | 0.98 | 0.23 | 0.45 | 0.42 | 0.13 | 0.73 | 0.52 | 0.71 | 0.85 | 0.24 |
| 4 | 0.98 | 0.98 | 0.49 | 0.02 | 0.01 | 0.45 | 0.91 | 0.71 | 0.12 | 0.12 | 0.07 |
| 8 | 0.95 | 0.98 | 0.05 | 0.79 | 0.86 | 0.89 | 0.92 | 0.91 | 0.01 | 0.12 | 0.10 |
| 5 | 0.35 | 0.43 | 0.02 | 0.11 | 0.00 | 0.02 | 0.03 | 0.01 | 0.01 | 1.00 | 1.00 |
| 9 | 0.00 | 0.41 | 0.03 | 0.14 | 0.00 | 0.17 | 0.41 | 0.24 | 0.90 | 1.00 | 1.00 |
Started: 2026-11-18T00:16:27.632610Z | Wall time: 0.063 s
Cluster 8 holds naive-like CD8 T cells. CD8B and CD8A are detected in 86% and 79% of its cells, and the naive and central-memory genes CCR7, IL7R, and CD27 in 89% to 92%, against 1% for GZMK.
Cluster 3 keeps the broad T-cell name. CD3D is detected in 97% of its cells and the cytotoxic genes GZMK and NKG7 in 71% and 85%, but CD8A and CD8B in fewer than half (45% and 42%, against 79% and 86% in cluster 8), so the cluster mixes CD8 T cells with CD8-negative cytotoxic T cells.
Cluster 9 holds CD56-bright NK cells, and cluster 5 keeps the broad NK name. Both detect NKG7 and GNLY in nearly every cell (1.00 in the table) and CD8B, which T cells pair with CD8A, in fewer than 1%. Cluster 9 also detects GZMK in 90% of its cells, as CD56-bright NK cells do, and CD3D in none, although CD3E reaches 41%. Cluster 5 detects CD3D in 35% of its cells, against 95% to 98% in each T-cell cluster, so it may also hold some T cells.
Clusters 1 and 4 keep the broad T-cell name. CD3D and IL7R are detected in 88% to 98% of their cells and CD8A and CD8B in at most 5%, the pattern of CD4 T cells, and cluster 1 detects CCR7 more often than cluster 4 (84% against 45%), as naive cells do. CD4 itself is detected in only 39% and 49% of their cells, so a CD4 name would rest mainly on the missing CD8 transcripts; the CD4 surface protein that the CITE-seq tutorial measures settles such calls.
Save and compare the reviewed names¶
Refine the five clusters whose markers agree, and keep the broad names of the other seven:
# Refine the five clusters whose markers support a finer identity.
reviewed_names = broad_names | {
"6": "naive B cells",
"7": "memory-like B cells",
"8": "naive-like CD8 T cells",
"9": "CD56-bright NK cells",
"11": "pDCs",
}
# Show the names that the review changed.
name_review = pd.DataFrame({"broad": broad_names, "reviewed": reviewed_names})
name_review.loc[name_review["broad"] != name_review["reviewed"]]| broad | reviewed | |
|---|---|---|
| 6 | B cells | naive B cells |
| 7 | B cells | memory-like B cells |
| 8 | T cells | naive-like CD8 T cells |
| 9 | NK cells | CD56-bright NK cells |
| 11 | pDC-like cells | pDCs |
Started: 2026-11-18T00:16:27.698763Z | Wall time: 0.010 s
Map each analyzed cell’s cluster to its name, mark the cells outside the run Not analyzed, and write both name columns to the cell table. overwrite=True replaces the columns on a rerun and leaves the run’s clusters unchanged.
# Find the run's cells among all rows of the cell table.
analysis_cells = run.cells.fetch_all("I").astype(bool)
# Name each analyzed cell from its cluster, and mark every other row as not analyzed.
broad_cell_type = np.full(ds.cells.N, "Not analyzed", dtype=object)
reviewed_cell_type = np.full(ds.cells.N, "Not analyzed", dtype=object)
broad_cell_type[analysis_cells] = [broad_names[value] for value in cluster_values]
reviewed_cell_type[analysis_cells] = [reviewed_names[value] for value in cluster_values]
# Write the broad and reviewed cell types to the cell table, keyed by cell ID.
cell_ids = ds.cells.fetch_all("ids")
ds.cells.insert("broad_cell_type", pd.Series(broad_cell_type, index=cell_ids), overwrite=True)
ds.cells.insert(
"reviewed_cell_type", pd.Series(reviewed_cell_type, index=cell_ids), overwrite=True
)
# Count the analyzed cells in each reviewed population.
pd.Series(reviewed_cell_type[analysis_cells]).value_counts().rename("cells")T cells 2219
CD14 monocytes 704
NK cells 283
naive B cells 256
memory-like B cells 239
naive-like CD8 T cells 166
CD56-bright NK cells 29
CD16 monocytes 25
pDCs 15
platelets 12
Name: cells, dtype: int64Started: 2026-11-18T00:16:27.711889Z | Wall time: 0.075 s
# Give each name one color in both panels: muted if unchanged, strong if refined.
name_colors = {
"T cells": "#c7c7c7",
"naive-like CD8 T cells": "#e69f00",
"NK cells": "#98df8a",
"CD56-bright NK cells": "#009e73",
"B cells": "#9edae5",
"naive B cells": "#0072b2",
"memory-like B cells": "#d55e00",
"CD14 monocytes": "#ffbb78",
"CD16 monocytes": "#c49c94",
"pDC-like cells": "#c5b0d5",
"pDCs": "#cc79a7",
"platelets": "#f7b6d2",
}
# Compare the broad and reviewed names on the run's UMAP.
ds.plots.embedding(
layout=run["umap"],
color_by=[
CellField("broad_cell_type", label="Broad"),
CellField("reviewed_cell_type", label="Reviewed"),
],
categorical_scale=CategoricalScale(order=tuple(name_colors), palette=name_colors),
legend_loc="right",
figsize=(10, 4),
)
Started: 2026-11-18T00:16:27.789875Z | Wall time: 0.576 s
The B-cell island at the top splits into 256 naive and 239 memory-like B cells, and the 166 naive-like CD8 T cells separate at the left edge of the T-cell island, which keeps 2,219 cells under the broad name. The 29 CD56-bright NK cells sit beside the other NK cells at the bottom, and the 15 pDCs form a small group above the monocyte island. Both name columns stay in ds.cells beside the run’s clusters, so later plots and comparisons can group cells by either one.
Test the names further¶
The clustering tutorial compares partitions and measures each cell’s cluster membership strength, which shows whether neighboring T-cell clusters such as 1 and 4 are distinct types or one gradient of states. A cluster with markers of two lineages, such as NK cluster 5 with CD3D in 35% of its cells, may hold a second cell type, doublets, or ambient RNA; the quality control and ambient RNA removal tutorials check the last two. The reference mapping and label transfer tutorial transfers labels from an annotated reference instead of naming clusters by hand. Marker statistics treat cells as the units, so differences between conditions need a comparison across donors, as in the donor-level comparisons tutorial.
Find marker references for your tissue¶
These resources list published markers to compare with the measured ones:
Marker collections: CellMarker, PanglaoDB, and Human Protein Atlas.
Reference atlases and annotation tools: Azimuth, ScType, CellTypist, SingleR, and CyteType.
Protein-marker panels: BioLegend and the Optimized Multicolor Immunofluorescence Panels (OMIPs) published in Cytometry Part A.