Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Read metadata and select cells

Read the cell and feature tables of a CyteArc store, add a cell column, and select cells by their metadata, then find where the store keeps its counts and saved results. The example is the mouse pancreas at embryonic day 15.5 from Bastidas-Ponce et al. (2019): 3,696 cells and 27,998 genes, prepared with a saved RNA analysis. The cell table has a column named clusters and the saved analysis a field of the same name, and the two hold different labels: the table holds the 8 cell types published with the data, and the analysis holds 12 Leiden clusters computed from the counts. Some computed clusters hold a single published type: all 385 cells of cluster 4 are Ngn3 high EP (endocrine progenitor) cells. Some published types span several clusters: Ductal is the most common type in four clusters.

Open a prepared pancreas dataset

A DataStore opens a Zarr store, a directory of compressed arrays that CyteArc reads a block at a time, so the complete count matrix never has to fit in memory. The cell table, ds.cells, describes the cells that every assay shares. Each assay, such as ds.RNA, holds its count matrix and a feature table, ds.RNA.feats. A saved analysis is a pipeline run: the record of one call of a recipe such as ds.pipeline.rna. The run keeps its results and a frozen selection of the cells it analyzed, so later edits to the cell table leave the run unchanged.

Started: 2026-11-17T22:28:38.349859Z | Wall time: 1.121 s

The cytearc_docs example repository holds this store with a completed RNA run labeled rna. Download the store, then open it and the run: ds.pipeline.open(label="rna") reads the saved run without computing anything again.

Started: 2026-11-17T22:28:39.473578Z | Wall time: 3.164 s

DataStore has 3696 (3696) cells with 1 assays: RNA Cell metadata: 'I', 'ids', 'names', 'G2M_score', 'RNA_UMAP1', 'RNA_UMAP2', 'RNA_clusters', 'RNA_leiden_cluster', 'RNA_nCounts', 'RNA_nFeatures', 'RNA_percentMito', 'RNA_percentRibo', 'S_score', 'clusters', 'clusters_coarse' RNA assay has 27998 features and following metadata: 'I', 'ids', 'names', 'dropOuts', 'highly_variable_genes', 'nCells'

Started: 2026-11-17T22:28:42.640189Z | Wall time: 2.491 s

The listing counts the active cells and, in parentheses, all cells of the store. The Boolean column I marks the active cells, which fetch and the analysis recipes read by default. A filter, such as the floor on detected genes that CyteArc applies when it first opens a store for writing, removes cells from I and keeps their rows. Here all 3,696 cells are active.

The store has one RNA assay with 27,998 genes. Every assay spans all cells of the store. When an assay measured only some of them, as after a merge of stores with different assays, a Boolean column <assay>_I, such as ADT_I, marks the cells it measured; the dataset merging tutorial shows how to select them. Columns prefixed RNA_ hold per-cell values from the RNA assay, such as RNA_nCounts, each cell’s total counts, and RNA_nFeatures, its number of detected genes. clusters, clusters_coarse, S_score and G2M_score came with the published data.

Read the cell and feature tables

ds.cells and ds.RNA.feats are MetaData tables, which read each column from the store when asked. head shows the first rows of every column:

IidsnamesdropOutshighly_variable_genesnCells
0TrueXkr4Xkr43690False6
1TrueGm37381Gm373813696NaN0
2TrueRp1Rp13696NaN0
3TrueRp1-1Rp1-13696NaN0
4TrueSox17Sox173696NaN0

Started: 2026-11-17T22:28:45.133171Z | Wall time: 0.028 s

In the feature table, nCells counts the cells in which a gene is detected and dropOuts the cells in which it is not, so the two add up to 3,696 for each gene. highly_variable_genes came with the published data and is missing, shown as NaN, for some genes, such as the four above that no cell detects. The saved run keeps its own variable genes as its output highly_variable_features. to_pandas_dataframe copies chosen columns into a pandas DataFrame, for every row unless you pass a key column:

RNA_nCountsRNA_nFeaturesclusters
ids
AAACCTGAGAGGGATA4954.02356.0Pre-endocrine
AAACCTGAGCCTTGAT7071.02613.0Ductal
AAACCTGAGGCAATTA4070.01984.0Alpha
AAACCTGCATCATCCC8362.02860.0Ductal
AAACCTGGTAAGTGGC5026.02211.0Ngn3 high EP

Started: 2026-11-17T22:28:45.163494Z | Wall time: 0.017 s

fetch reads one column as a NumPy array for the active cells, and fetch_all reads it for every row of the table. Count the published cell types:

cells
published type
Ductal916
Ngn3 high EP642
Pre-endocrine592
Beta591
Alpha481
Ngn3 low EP262
Epsilon142
Delta70

Started: 2026-11-17T22:28:45.182435Z | Wall time: 0.011 s

Ductal cells are the largest group, 916 of the 3,696 cells, and Delta cells the smallest, 70 cells.

Compare the table’s clusters with the run’s clusters

analysis_run.cells reads the run’s cell fields from its saved results, for the cells that the run analyzed. One of those fields is also named clusters, and it holds the 12 Leiden clusters that the run computed. Plots follow the same split: with layout=, color_by="clusters" reads the cell table’s column, and with run=, the run’s field. Count the published types in each run cluster, then draw the run’s UMAP colored each way:

Run cell fields: I, ids, names, umap_1, umap_2, clusters
RNA_clusters equals the run's clusters: True
The resolution 0.5 clustering is the run's clusters: True
cellsmost common published typeshare of cells
run cluster
1552Beta0.97
2544Ductal0.77
3449Alpha0.94
4385Ngn3 high EP1.00
5369Pre-endocrine0.84
6347Pre-endocrine0.62
7227Ductal0.67
8213Ductal0.96
9194Epsilon0.70
10175Ngn3 high EP0.58
11145Ductal0.83
1296Delta0.72

Started: 2026-11-17T22:28:45.195122Z | Wall time: 0.085 s

Two UMAP panels of the 3,696 pancreas cells on the saved run's layout, each with its labels printed on the cells. The left panel is colored by the cell table's clusters column, the 8 published cell types: Ductal cells with scattered Ngn3 low EP cells on the right, Ngn3 high EP cells along the top arc, Pre-endocrine cells at the arc's left end and down the left edge, and Delta, Epsilon, Alpha and Beta cells on the left, with Beta lowest. The right panel is colored by the run's clusters field, 12 Leiden clusters: cluster 1 covers the Beta cells, cluster 3 the Alpha cells, cluster 9 the Epsilon cells and cluster 12 the Delta cells; clusters 6, 4 and 10 run along the top arc from left to right, cluster 5 sits on the left edge below cluster 6, and clusters 2, 7, 8 and 11 divide the Ductal region.

Started: 2026-11-17T22:28:45.282601Z | Wall time: 0.595 s

Some run clusters hold almost a single published type: 97% of cluster 1 is Beta, 94% of cluster 3 is Alpha, 96% of cluster 8 is Ductal and all of cluster 4 is Ngn3 high EP. The two rarest types each form most of a cluster: 70% of cluster 9 is Epsilon and 72% of cluster 12 is Delta. A published type can also span several run clusters. Ductal is the most common type in clusters 2, 7, 8 and 11, which divide the Ductal cells on the right of the UMAP, and the Ngn3 high EP cells along the top arc fall into clusters 6, 4 and 10, with 385 of the 642 in cluster 4. Cluster 6, 62% Pre-endocrine, covers the left end of the top arc, where Ngn3 high EP cells give way to Pre-endocrine cells.

The run’s clusters and the table’s types line up cell for cell here because the run analyzed all 3,696 cells and all of them are still active. When the run’s cells and the active cells differ, read both with fetch_all, which aligns the run’s field to every row of the table, with a fill value in the rows that the run did not analyze. The run’s clusters are the Leiden clustering that it computed at resolution 0.5, its only candidate, which ds.artifacts.find returns by the run’s graph and that resolution. The table’s RNA_clusters and RNA_leiden_cluster columns are copies of the run’s clusters, and RNA_UMAP1 and RNA_UMAP2 of its umap_1 and umap_2, written into the table when the store was prepared, and RNA_clusters matches the run’s clusters for every cell.

Add a cell column

insert writes a new column to the cell table. Its values cover either every row or only the rows that key selects, the active cells by default; in the second case the other rows stay missing unless you pass fill_value. Replacing an existing column needs overwrite=True, which here lets the notebook run again on the same store. Mark the 369 cells of run cluster 5, which is 84% Pre-endocrine:

cells
in_cluster_5
False3327
True369

Started: 2026-11-17T22:28:45.880434Z | Wall time: 0.030 s

Pancreas UMAP colored by the in_cluster_5 column. The 369 cells of run cluster 5, in orange, form a compact group at the left edge of the layout, in the Pre-endocrine region above the Beta cells; the other 3,327 cells are blue.

Started: 2026-11-17T22:28:45.912355Z | Wall time: 0.274 s

The marked cells sit at the left edge of the UMAP, in the Pre-endocrine region above the Beta cells. Pass the new column as key to fetch to read another column for the marked cells only, without changing I:

fetch with key: 369 | fetch_all: 3696
cells
published type
Pre-endocrine310
Beta37
Alpha22

Started: 2026-11-17T22:28:46.189146Z | Wall time: 0.016 s

Run cluster 5 holds 310 of the 592 Pre-endocrine cells, and cluster 6 holds most of the rest. Cluster 5’s 37 Beta and 22 Alpha cells sit where the Pre-endocrine cells meet the Beta and Alpha cells, so the run draws this cluster’s boundary a little past the published one.

Select cells by metadata

sift returns a Boolean mask over every row of the table for one numeric range. Its bounds are exclusive unless you pass keep_bounds=True, so the next call marks the cells with more than 1,000 and fewer than 15,000 total counts:

Inside the range: 3669 | outside: 27
cells
published type
Ductal25
Ngn3 high EP1
Ngn3 low EP1

Started: 2026-11-17T22:28:46.207053Z | Wall time: 0.015 s

Of the 3,696 cells, 3,669 fall inside the range. Ductal cells are a quarter of the table but 25 of the 27 cells outside the range, so a filter at these bounds would remove Ductal cells and almost nothing else. multi_sift takes one range per column and marks the cells inside all of them. Add a range of 500 to 4,000 detected genes, then plot both columns against their bounds:

Inside both ranges: 3667

Started: 2026-11-17T22:28:46.224110Z | Wall time: 0.013 s

Two histograms of the 3,696 pancreas cells: total counts per cell on the left, peaking near 5,000 with a long tail to the right, and detected genes per cell on the right, peaking near 2,300. Dashed red lines mark the multi_sift bounds of 1,000 and 15,000 counts and 500 and 4,000 genes. Both lower bounds lie left of every cell, and only the right tails, colored red, fall outside the ranges; the red tail of the count panel holds the 27 cells outside the count range.

Started: 2026-11-17T22:28:46.238531Z | Wall time: 0.402 s

Both lower bounds sit below every cell, so the ranges exclude only the high tails, in red, and the detected-gene range excludes 2 cells that the count range kept, leaving 3,667 inside both. get_index_by returns the positions, among all rows of the table, of the cells whose value matches one of the given labels:

Ductal cells: 916
Active cells before: 3696 | after: 3696

Started: 2026-11-17T22:28:46.642309Z | Wall time: 0.015 s

get_index_by finds the 916 Ductal cells, and I still marks all 3,696 cells: masks and row positions leave the table unchanged until you write them into a column. To analyze a subset, insert its mask as a Boolean column, as with in_cluster_5 above, and pass the column’s name to a recipe as cells=. Individual analysis methods, such as ds.features.normalize, take a cell selection instead: ds.snapshot_cell_selection("<column>") freezes the cells that a column marks into one, and the run’s analysis_cell_selection, used below, is such a selection. The MetaData section of the assays and metadata API reference lists the methods that update, reset and drop columns.

Inspect counts and saved results

ds.RNA.rawData is the RNA count matrix as a chunked array, which reads blocks of cells on demand, and ds.RNA.normed() is a view that normalizes those blocks as they are read. Neither reads any counts, so both shapes print at once:

Raw shape: (3696, 27998)
Normed shape: (3696, 27998)

Started: 2026-11-17T22:28:46.658353Z | Wall time: 0.010 s

Both are 3,696 cells by 27,998 genes. The custom analyses tutorial streams these count blocks into a statistic of your own.

Analysis methods save each result in the store as an artifact and return an ArtifactRef, a small reference that identifies the result without loading it. The run’s outputs are such references: analysis_run["normalized"] is the normalization that the run saved. A request whose operation, parameters and inputs match a complete result reuses that result instead of computing it again, so asking for the normalization of the run’s cells and variable genes returns the run’s own:

Reused: True
ArtifactRef(assay='RNA', kind='normalized', artifact_id='9929213febd1...')

Started: 2026-11-17T22:28:46.670306Z | Wall time: 0.062 s

ds.artifacts.inspect reports a result’s status and the parameters that produced it, and ds.artifacts.load opens its arrays for code that reads them directly:

Complete: True | operation: run_normalization
Normalizer: norm_lib_size
{'size_factor': 1000.0, 'log_transform': True, 'renormalize_subset': True}
{'data': (3696, 2000), 'feature_m2': (2000,), 'feature_sum': (2000,)}

Started: 2026-11-17T22:28:46.734113Z | Wall time: 0.029 s

The run normalized each cell over the 2,000 variable genes it selected: renormalize_subset divides each cell’s counts by its total over those genes, size_factor scales each cell’s values to sum to 1,000, and log_transform takes log1p. These values differ from those of ds.RNA.normed() above, which by default divides by each cell’s total over all 27,998 genes and takes no log. data holds the values, and feature_sum and feature_m2 hold each gene’s sum and sum of squared deviations, from which the scaling step before PCA reads each gene’s mean and standard deviation without reading data again. The reuse tutorial shows how results branch and trace back to their inputs.

Look inside the store

A CyteArc store is a Zarr directory tree. Groups hold arrays, and each array has its own shape, data type and chunks, the blocks in which it is compressed and read. The top level holds the RNA assay, the store-wide artifacts, the cell table (cellData) and the pipeline records:

/
├── RNA
├── artifacts
├── cellData
└── pipeline

Started: 2026-11-17T22:28:46.767287Z | Wall time: 0.011 s

ds.zw is the store’s root Zarr group. Its cellData group stores each column of the cell table as its own one-dimensional array, so reading one column decodes no other:

shapedtypechunks
cellData column
I(3696,)bool(3696,)
RNA_nCounts(3696,)float64(3696,)
RNA_nFeatures(3696,)float64(3696,)

Started: 2026-11-17T22:28:46.780462Z | Wall time: 0.012 s

Each column fits in one chunk of all 3,696 rows. The RNA group holds the count matrices, their summaries, the feature table (featureData) and the RNA artifacts:

/RNA
├── artifacts
│   ├── ann_index
│   ├── cluster_labels
│   ├── cluster_selection
│   ├── connectivity_map
│   ├── embedding
│   ├── embedding_initialization
│   ├── feature_scaling
│   ├── feature_selection
│   ├── feature_summary
│   ├── marker_table
│   ├── metadata_snapshot
│   ├── neighbors
│   ├── normalized
│   └── reduction
├── countSummaries
│   ├── columnPositive (27998,) int64
│   ├── featureSums
│   ├── rowPositive (3696,) int64
│   └── rowSums (3696,) float64
├── counts (3696, 27998) uint16
├── countsT (27998, 3696) uint16
└── featureData
    ├── I (27998,) bool
    ├── __cytearc_missing__highly_variable_genes (27998,) bool
    ├── dropOuts (27998,) int64
    ├── highly_variable_genes (27998,) <U5
    ├── ids (27998,) <U15
    ├── nCells (27998,) int64
    └── names (27998,) <U15

  countsT: shape=(27998, 3696), dtype=uint16, chunks=(27056, 1848), shards=(27056, 3696)
  counts: shape=(3696, 27998), dtype=uint16, chunks=(3696, 13528), shards=(3696, 40584)

Started: 2026-11-17T22:28:46.794653Z | Wall time: 0.024 s

counts holds the matrix cell by cell, 3,696 rows of 27,998 genes, and countsT holds the same values gene by gene, 27,998 rows of 3,696 cells, so that gene-wise steps such as variable-gene selection and marker search read whole genes at once, at the cost of storing the counts twice. The two lines under the tree give each matrix’s chunks and shards; a shard is one stored object that holds several chunks. countSummaries keeps each cell’s total (rowSums) and detected genes (rowPositive), each gene’s number of detected cells (columnPositive) and, in featureSums, each cell’s total over the mitochondrial genes and over the ribosomal genes, from which RNA_percentMito and RNA_percentRibo are computed.

Each artifact is a group at RNA/artifacts/<kind>/<artifact_id>, or at artifacts/<kind>/<artifact_id> for store-wide results such as cell selections. The path names the kind of result and a random identifier but no parameters, so a second PCA with other settings becomes a sibling group under RNA/artifacts/reduction, and the parameters that ds.artifacts.inspect reports tell the two apart. The provenance guide explains what each artifact records.

Pass start="RNA/featureData" or start="RNA/artifacts" to show_zarr_tree to list a deeper group; the Zarr internals guide describes the complete layout. CyteArc writes new stores as Zarr v3 and refuses to open an RNA store written as Zarr v2 or without countsT: import such a store again from its source, as the import tutorial shows, or rebuild it with repack_zarr, as the FAQ explains.

References
  1. Bastidas-Ponce, A., Tritschler, S., Dony, L., Scheibner, K., Tarquis-Medina, M., Salinno, C., Schirge, S., Burtscher, I., Böttcher, A., Theis, F. J., Lickert, H., & Bakhti, M. (2019). Comprehensive single cell mRNA profiling reveals a detailed roadmap for pancreatic endocrinogenesis. Development, 146(12), dev173849. 10.1242/dev.173849