Plot a saved RNA analysis of 100,000 human cells sampled across the tissues of the Tabula Sapiens atlas The Tabula Sapiens Consortium & Quake, 2024, then run the same RNA recipe on your own counts. The cells come from 24 donors, and the authors annotated them with 172 cell types. The analysis grouped the cells into 52 clusters without using those labels. In eight of the ten largest clusters, one published cell type makes up most of the cells, from 56% endothelial cells in cluster 7 to 96% neutrophils in cluster 5; each of the other two holds several related types, such as monocytes and classical monocytes.
Install CyteArc with its extra dependencies first.
Download and plot the saved analysis¶
The code below downloads a CyteArc store, a Zarr directory that holds the 100,000 cells with their counts for 60,606 genes, the authors’ annotations and the saved analysis. The cells were sampled in proportion to the atlas’s cells from each donor in each tissue. The download is about 1.5 GB, and running the cell again reuses the downloaded store, with anything saved in it. For a smaller download, start with the PBMC analysis, and to explore every cell of the atlas without downloading it, open the full atlas remotely.
import pandas as pd
import cytearc
from cytearc.plotting import CellField
# Keep download progress and routine logs out of the page.
cytearc.configure_output(level="WARNING", progress=False)
# Download the store with its counts and saved RNA analysis.
dataset = cytearc.datasets.connect("cytearc_docs").download_dataset(
"tabula_sapiens_100k", destination="cytearc_datasets", zarr=True
)Started: 2026-11-14T15:42:40.911794Z | Wall time: 25.932 s
Open the store with cytearc.DataStore and its saved analysis, labeled rna, with ds.pipeline.open(label="rna"). The result is a pipeline run, the record of one call to the RNA recipe ds.pipeline.rna: the settings of that call and the results it saved, from normalized counts to clusters and marker genes. ds.pipeline.open only reads these results, while ds.pipeline.rna computes a new run. Passing run=run to ds.plots.embedding draws the run’s UMAP. Each CellField names a column to color by and the title of its panel, here the clusters that the run saved and the cell types that the authors published:
# Open the store and its saved RNA pipeline run.
ds = cytearc.DataStore(f"{dataset}/data.zarr")
run = ds.pipeline.open(label="rna")
# Color the run's UMAP by its clusters and by the published cell types, labeling the ten largest of each.
ds.plots.embedding(
run=run,
color_by=[
CellField("clusters", label="Saved Leiden clusters"),
CellField("cell_type", label="Published cell types"),
],
legend_loc="on_data",
max_on_data_labels=10,
point_size=0.5,
figsize=(12, 6),
)
Started: 2026-11-14T15:43:06.847849Z | Wall time: 6.368 s
Both panels place each cell at the same position, and eight of the ten numbered clusters lie under one of the ten named types. The central island holds cluster 4 under the CD8-positive T-cell label, cluster 2 under the CD4-positive label and cluster 1 under B cell. Clusters 3, 5, 6, 7 and 10 lie under fibroblast, neutrophil, macrophage, endothelial cell and stromal cell of ovary. No label falls on clusters 8 and 9. Many of the 172 cell types share similar colors on the right, so read that panel by its labels.
Inspect the store and its run¶
ds lists what the store holds:
# List the store's assays and the columns of its cell and feature tables.
dsDataStore has 100000 (100000) cells with 1 assays: RNA
Cell metadata:
'I', 'ids', 'names', '10X_run', 'RNA_nCounts',
'RNA_nFeatures', 'RNA_percentMito', 'RNA_percentRibo', '_scvi_batch', '_scvi_labels',
'ambient_removal', 'anatomical_position', 'assay', 'assay_ontology_term_id', 'broad_cell_class',
'cdna_plate', 'cdna_well', 'cell_type', 'cell_type_ontology_term_id', 'compartment',
'development_stage', 'development_stage_ontology_term_id', 'disease', 'disease_ontology_term_id', 'donor_assay',
'donor_id', 'donor_method', 'donor_tissue', 'donor_tissue_assay', 'ethnicity_original',
'free_annotation', 'is_primary_data', 'library_plate', 'manually_annotated', 'method',
'n_genes_by_counts', 'notes', 'observation_joinid', 'pct_counts_ercc', 'pct_counts_mt',
'published_2022', 'replicate', 'sample_id', 'sample_number', 'scvi_leiden_donorassay_full',
'self_reported_ethnicity', 'self_reported_ethnicity_ontology_term_id', 'sex', 'sex_ontology_term_id', 'suspension_type',
'tissue', 'tissue_in_publication', 'tissue_ontology_term_id', 'tissue_type', 'total_counts',
'total_counts_ercc', 'total_counts_mt'
RNA assay has 60606 features and following metadata:
'I', 'ids', 'names', '_index', 'dropOuts',
'ercc', 'feature_biotype', 'feature_length', 'feature_reference', 'feature_type',
'genome', 'mean', 'mean_counts', 'mt', 'nCells',
'n_cells_by_counts', 'pct_dropout_by_counts', 'std', 'total_counts'Started: 2026-11-14T15:43:13.219235Z | Wall time: 0.080 s
The first line counts the active cells, which analyses use by default, and in parentheses every cell of the store: all 100,000 are active. The store has one RNA assay with 60,606 genes. Its cell table, ds.cells, holds the authors’ metadata, such as cell_type, tissue and donor_id. The run saved copies of the cell columns passed to ds.pipeline.rna as snapshot_columns, cell_type and donor_id among them, so its plots and tables keep the labels it ran with even if ds.cells changes later. run.cells reads these copies beside the run’s results, and run.report() returns the settings that the run recorded. Count the donors, cell types and clusters, and read the main settings:
# Read the run's clusters beside its copies of the authors' labels for the same cells.
cells = run.cells.to_pandas_dataframe(["clusters", "cell_type", "donor_id"])
# Read the settings that the run recorded for each stage.
settings = run.report()["run"]["config"]["stages"]
# Count the cells, donors, cell types and clusters beside the main settings.
{
"analyzed cells": len(cells),
"donors": cells["donor_id"].nunique(),
"published cell types": cells["cell_type"].nunique(),
"variable genes": settings["hvg"]["top_n"],
"principal components": settings["pca"]["dims"],
"neighbors per cell": settings["neighbors"]["k"],
"Leiden resolution": settings["leiden"]["selected"],
"saved clusters": cells["clusters"].nunique(),
}{'analyzed cells': 100000,
'donors': 24,
'published cell types': 172,
'variable genes': 2000,
'principal components': 30,
'neighbors per cell': 21,
'Leiden resolution': 1.0,
'saved clusters': 52}Started: 2026-11-14T15:43:13.302423Z | Wall time: 0.113 s
The run analyzed all 100,000 cells with 2,000 variable genes, 30 principal components and 21 neighbors per cell, and saved the Leiden clustering at resolution 1.0, which has 52 clusters. These are the run’s own settings; the example in the last section runs the recipe with its defaults, which differ from them.
Compare the clusters with the published cell types¶
For each of the ten largest clusters, the table gives its most common published cell type and that type’s share of the cluster’s cells, and the lines below it break down the two clusters where that share is lowest:
# Count each cluster's cells by published cell type.
composition = pd.crosstab(cells["clusters"], cells["cell_type"])
sizes = composition.sum(axis=1)
# Find each cluster's most common cell type and its share of the cluster.
clusters = pd.DataFrame(
{
"cells": sizes,
"most common cell type": composition.idxmax(axis=1),
"share of cluster": (composition.max(axis=1) / sizes).round(2),
}
)
# Show the ten largest clusters, which the figure labels.
clusters.nlargest(10, "cells")| cells | most common cell type | share of cluster | |
|---|---|---|---|
| clusters | |||
| 1 | 9463 | B cell | 0.80 |
| 2 | 8561 | CD4-positive, alpha-beta T cell | 0.61 |
| 3 | 7914 | fibroblast | 0.66 |
| 4 | 5098 | CD8-positive, alpha-beta T cell | 0.65 |
| 5 | 5024 | neutrophil | 0.96 |
| 6 | 4448 | macrophage | 0.74 |
| 7 | 4438 | endothelial cell | 0.56 |
| 8 | 3726 | monocyte | 0.42 |
| 9 | 3565 | smooth muscle cell | 0.42 |
| 10 | 3391 | stromal cell of ovary | 0.89 |
Started: 2026-11-14T15:43:13.417441Z | Wall time: 0.055 s
# Break down the two least uniform of the ten largest clusters into their three most common cell types.
for cluster in clusters.nlargest(10, "cells").nsmallest(2, "share of cluster").index:
shares = composition.loc[cluster].nlargest(3) / sizes[cluster]
print(f"Cluster {cluster}:", ", ".join(f"{share:.0%} {kind}" for kind, share in shares.items()))Cluster 8: 42% monocyte, 37% classical monocyte, 9% macrophage
Cluster 9: 42% smooth muscle cell, 20% pericyte, 13% blood vessel smooth muscle cell
Started: 2026-11-14T15:43:13.475060Z | Wall time: 0.011 s
Cluster 5 is 96% neutrophils, cluster 10 is 89% ovarian stromal cells and cluster 1 is 80% B cells. Cluster 2 is 61% CD4-positive and cluster 4 is 65% CD8-positive alpha-beta T cells, so the two clusters follow the CD4 and CD8 split of the annotation. Clusters 8 and 9 have no majority type because the annotation splits their cells among related labels: cluster 8 is 42% monocytes and 37% classical monocytes, and cluster 9 is 42% smooth muscle cells, 20% pericytes and 13% blood vessel smooth muscle cells.
Analyze your own RNA-seq data¶
To analyze a filtered Cell Ranger HDF5 file, convert it to a CyteArc store, open the store and run the RNA recipe:
import cytearc
# Convert the filtered Cell Ranger counts into a new store.
reader = cytearc.CrH5Reader("filtered_feature_bc_matrix.h5")
cytearc.CrToZarr(reader, zarr_loc="analysis.zarr").dump()
# Run the RNA recipe with its default settings and plot the clusters it saves.
ds = cytearc.DataStore("analysis.zarr")
run = ds.pipeline.rna(label="baseline")
ds.plots.embedding(run=run, color_by="clusters")CrToZarr raises FileExistsError if analysis.zarr already holds data. Pass overwrite=True to replace a conversion that no DataStore has opened yet; once a store has been opened, convert into a new path or delete the old store yourself.
With its default settings, the recipe filters cells on their quality-control metrics, scores the cell cycle, selects highly variable genes, normalizes their counts by library size and log-transforms them, reduces the normalized values with PCA, builds a neighbor graph, embeds it with UMAP, clusters it with Leiden at several resolutions and saves the resolution with the best silhouette score, scores doublets and ranks the marker genes of each cluster. Pass a stage’s settings as a keyword to change them, such as hvg={"top_n": 2000}, pca={"dims": 30} and neighbors={"k": 21}, the values that the saved Tabula Sapiens run used. run.report() returns the settings with each stage’s summary and warnings, such as the cells that filtering removed. Before you interpret a new dataset, check that filter with the quality-control tutorial.
Keep run to plot and read marker tables without recomputing them. A label names one completed run in a store: calling the recipe again with label="baseline" raises a ValueError, so reopen that run with ds.pipeline.open(label="baseline") or give a new run a new label.
Continue with the page that fits your next step:
Name clusters from their marker genes in the PBMC analysis, then test the names against more markers in the annotation tutorial.
Import H5AD, Matrix Market and other formats with the import and export tutorial, or translate a Scanpy or Seurat workflow with the Scanpy or Seurat guide.
Call each step yourself through
ds.features,ds.reduction,ds.graph,ds.embeddings,ds.clustersandds.markers, which run the same computations as the recipe; the graph construction tutorial calls them from normalization to Leiden clustering.Analyze peak counts with
ds.pipeline.atacin the scATAC-seq tutorial, and antibody panels withds.pipeline.adtin the CITE-seq tutorial.
- The Tabula Sapiens Consortium, & Quake, S. R. (2024). Tabula Sapiens reveals transcription factor expression, senescence effects, and sex-specific features in cell types from 28 human organs and tissues. openRxiv. 10.1101/2024.12.03.626516