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.

Reuse results and compare analysis settings

Change one analysis setting, compute only the results that depend on it, and compare the analyses. The example starts from a saved RNA analysis of 100,000 cells from 28 tissues of 24 donors in the Tabula Sapiens human atlas The Tabula Sapiens Consortium & Quake (2024) and changes one setting at a time: the neighbor count from 21 to 31, and separately the number of principal components from 30 to 40. With 31 neighbors, CyteArc reuses the saved normalization, PCA, and nearest-neighbor search index and computes only new neighbors and a new graph; with 40 components, the analysis forks at PCA. At Leiden resolution 1.0, the saved analysis has 52 clusters, the 31-neighbor analysis 49, and the 40-component analysis 60. Against the saved clusters, the 31-neighbor clusters score an adjusted Rand index (ARI) of 0.93, the same as the saved graph clustered again with another random seed, and the 40-component clusters 0.87. A plan of the full RNA recipe with 31 neighbors reports, before anything runs, that its first eight stages need no new results, and the finished run records each stage’s time, cores, and memory.

The examples need CyteArc’s extra optional dependencies (installation).

Open the saved analysis

The prepared store holds the atlas sample and a completed RNA pipeline run labeled rna.

PipelineRun(run_id='0559770dee10...', recipe='rna', status='completed', assay='RNA', label='rna')
100,000 cells from 28 tissues of 24 donors
2,000 variable genes, 30 principal components, 21 neighbors, Leiden resolution 1.0
Run outputs: input_cell_selection, analysis_cell_selection, feature_universe, highly_variable_features, normalized, pca, ann_index, neighbors, connectivity_map, embedding_initialization, umap, clusters, markers, leiden

Started: 2026-11-14T15:42:40.722499Z | Wall time: 31.972 s

The saved run kept 30 principal components and built a graph of 21 neighbors per cell, the two settings that the next sections change. The run then clustered the graph with Leiden at resolutions 0.5 and 1.0 and kept the resolution 1.0 partition as its clusters. A pipeline run records one call of a recipe, a method such as ds.pipeline.rna that runs every stage of an analysis, from freezing the input cells and their metadata to ranking markers. The run keeps the call’s settings and, for each output listed above, an artifact reference that identifies one saved, immutable result without loading it: baseline_run["pca"], for example, returns the reference of the run’s PCA.

Change one setting at a time

A call reuses an artifact when the store holds a complete one with the same operation, parameters, and inputs, and computes a new one otherwise. Starting from the cells and variable genes that the saved run analyzed, build the chain from normalization to the neighbor graph three times: with the saved settings, with 31 neighbors, and with 40 principal components.

Saved settings return the saved run's artifacts: True
k = 21, 30 PCsk = 31, 30 PCsk = 21, 40 PCs
normalized expression2ae95f7440d92ae95f7440d92ae95f7440d9
PCAf908664365e5f908664365e575dcb79e0384
search index00cc6d31361400cc6d3136149f016a5d8ff3
neighbors44b2e986053ca8b32a8c8f55e49ad087ee95
graphd4d3ea3d329386639066c2298f5d6d7bb3e3

Started: 2026-11-14T15:43:12.700959Z | Wall time: 78.576 s

Repeating the saved settings returned the saved run’s own five artifacts, so nothing was computed. The 31-neighbor analysis shares the saved normalized expression, PCA, and search index: the index is built over the 30 principal components and returns any number of neighbors per query, so only the neighbors and the graph are new. Of these five steps, the 40-component analysis shares only the normalized expression: PCA changes, and so do the search index, the neighbors, and the graph, which all depend on PCA.

Trace where the analyses diverge

ds.artifacts.lineage follows the inputs that results record back to the cells and genes they came from, and reports each shared input once. Trace the three graphs together:

ArtifactLineage(outputs=3, artifacts=16, dependencies=23)

Started: 2026-11-14T15:44:31.279706Z | Wall time: 0.469 s

The lineage covers 16 artifacts and 23 dependencies, held as a NetworkX directed graph in lineage.graph. The diagram below draws lineage.graph with each artifact colored by the analysis that added it to the store, and leaves out an arrow when a longer path already connects the two artifacts, such as the arrow from the analysis cells to the normalized expression.

Source
Lineage diagram of the three neighbor graphs, read from top to bottom, with one box per artifact and arrows from inputs to the results computed from them, leaving out arrows that a longer path already implies, such as from the analysis cells to the normalized expression. Gray boxes in the center belong to the saved run: the analysis cells, gene names and gene statistics, variable genes, normalized expression, gene scaling, PCA with 30 PCs, its search index, neighbors with k = 21, and the saved graph. Two blue boxes at the right are new for k = 31: neighbors with k = 31, drawn from the saved search index, and their graph. Four orange boxes at the left are new for 40 PCs: PCA with 40 PCs, branching from the shared gene scaling, then its own search index, neighbors with k = 21, and graph.

Started: 2026-11-14T15:44:31.751315Z | Wall time: 0.236 s

The diagram adds the shared results that the table leaves out: the analysis cells, the gene names and gene statistics that the variable-gene selection read, the variable genes, and the gene scaling that both PCA results read, each gene’s mean and standard deviation. lineage.to_markdown() exports the lineage as Markdown, with a Mermaid diagram and each artifact’s operation, parameters, and path, to keep with an analysis or share in a review. lineage.to_mermaid() returns the diagram source alone.

Plan a recipe run before starting it

ds.pipeline.plan takes a recipe’s name and its arguments and reports which stages the call would reuse and which it would compute, and why, without computing or writing anything (Plan a call). Repeat the saved run’s recorded settings with 31 neighbors in place of 21: the saved run switched off QC filtering, cell-cycle scoring, and doublet scoring, and its record supplies the variable-gene, PCA, and Leiden settings and the cell columns that it froze with its cells (snapshot_columns):

statusreasonwall time in the saved run (s)
stage
input_snapshotreused
highly_variable_featuresreused
normalizationreused
pcareused
ann_indexreused
neighborsreused
connectivityreused
embedding_initializationreused
umapcomputedchanged95.3
leidencomputedchanged33.9
markerscomputedupstream25.2

Started: 2026-11-14T15:44:31.990465Z | Wall time: 1.903 s

The call would reuse its first eight stages. Its neighbors and graph are the 31-neighbor results that build_graph saved above, and the UMAP initialization is computed from PCA, not from the graph. UMAP and the leiden stage, which clusters the graph at both resolutions, would compute because their input graph changed (changed), and marker ranking waits on the new clusters (upstream). The last column is what each computed stage took when the saved run computed it, on the machine that built the store.

Run the recipe and read what each stage used

Run the same call. The new run’s report, run_k31.report(), records for each stage its wall and CPU time, the peak resident memory (RSS) and OS threads of the process, and the bytes received over the network (Stage resources):

4 workers, 6 GiB memory budget, 20 CPUs available
createdreusedwall (s)CPU (s)corespeak RSS (GiB)threadsreceived (MB)
stage
input_snapshot050.60.50.91.31760.0
highly_variable_features020.20.20.91.31760.0
normalization010.10.10.81.31750.0
pca020.10.00.61.31750.0
ann_index010.10.00.61.31750.0
neighbors010.10.10.81.31750.0
connectivity010.10.00.61.31750.0
embedding_initialization010.10.00.61.31750.0
umap10131.8130.11.01.57760.0
leiden2081.188.11.11.65760.0
markers1035.590.02.53.89730.0

Started: 2026-11-14T15:44:33.896036Z | Wall time: 251.023 s

The process had 4 workers, set by nthreads=4 when the store was opened, and could use 20 CPUs. Its 6 GiB memory budget, set by the CYTEARC_MEM_BUDGET environment variable where this page ran, is the memory that CyteArc plans each operation to fit in (Memory budget). In the table, the created and reused columns count each stage’s artifacts, the cores column is CPU time divided by wall time, and the threads column counts the process’s OS threads, 73 to 76 here whatever the stage computes, so the cores column, not the threads column, shows how much of a stage ran in parallel.

The eight reused stages took at most 0.6 s each. UMAP took 131.8 s on one core: its layout runs on a single thread by default, because a parallel layout is not reproducible. The leiden stage created both partitions in 81.1 s on 1.1 cores: most of its time went to compiling CyteArc’s Leiden code at its first use in a new installation, which runs on one core, while the clustering itself runs on the store’s 4 workers. Marker ranking used 2.5 cores and reached the run’s highest peak RSS, 3.89 GiB, against 1.31 GiB during the reused stages. The received column stays at 0.0 MB because the store is on local disk. On a remote store, the column shows the bytes received during each stage, counted over the process’s network namespace: on a container worker that is mostly the stage’s reads, and on a laptop usually the whole machine’s traffic. The plan’s estimates put the three computed stages in the same order: UMAP 95.3 s planned and 131.8 s here, the leiden stage 33.9 s and 81.1 s, and marker ranking 25.2 s and 35.5 s.

Compare the three analyses

The 31-neighbor run holds its own UMAP and Leiden clusters beside the saved run’s. Lay out and cluster the 40-component graph the same way, and draw the three layouts side by side, colored by the atlas’s compartment annotation:

Three UMAPs of the 100,000 cells side by side, titled k = 21, 30 PCs (saved run); k = 31, 30 PCs; and k = 21, 40 PCs, with cells colored by the atlas's compartment: endothelium, epithelium, germline, immune, neural, and stromal, plus a legend entry, None, for cells without a compartment. The saved and 31-neighbor layouts share one arrangement: two large immune groups at the left and center, endothelial and stromal cells above them, epithelial cells at the right and in a band along the bottom, and a separate germline island at the lower right. The 40-PC layout keeps the compartments apart in a different arrangement: stromal cells at the top, endothelial cells below them, the two immune groups at the lower left and center, epithelial islands at the top, left, and right with no band along the bottom, and the germline island at the right.

Started: 2026-11-14T15:48:44.921915Z | Wall time: 123.541 s

All three layouts keep the same compartments apart: two large immune groups, stromal and endothelial cells next to each other, several epithelial islands, and germline cells on their own. The 31-neighbor layout starts from the saved run’s initialization, which the run reused because the initialization is computed from the shared PCA, and keeps the saved arrangement. The 40-component layout starts from a new initialization computed from its own PCA and arranges the same compartments differently, with epithelial islands at the top, left, and right and no band along the bottom.

Count the clusters at the saved Leiden resolution, and score each clustering against the saved one with the adjusted Rand index (ARI), which is 1 for identical partitions and near 0 for chance agreement. Clustering the saved graph again with another random seed shows how far the seed alone moves the clusters:

clustersadjusted Rand index with the saved clusters
k = 21, 30 PCs (saved run)521.00
k = 21, 30 PCs, another Leiden seed530.93
k = 31, 30 PCs490.93
k = 21, 40 PCs600.87

Started: 2026-11-14T15:50:48.466070Z | Wall time: 1.658 s

With another random seed, Leiden finds 53 clusters on the saved graph, against the saved run’s 52, with an ARI of 0.93. With 31 neighbors, Leiden finds 49 clusters with the same ARI, so the step from 21 to 31 neighbors moves the clusters no further than a new seed does. With 40 components, Leiden finds 60 clusters with an ARI of 0.87, so the step from 30 to 40 components changes this clustering more than a new seed does. The neighbor graph and clustering tutorials show how these settings shape a graph and its clusters.

Find a saved result by its inputs

ds.artifacts.list finds saved results by kind, operation, and exact inputs, and returns every match. Find the graph that the saved run built from its neighbors:

{"saved run's graph": True, 'operation': 'build_connectivity_map', 'parameters': {'local_connectivity': 1.0, 'bandwidth': 1.5}, 'inputs': {'neighbors': {'type': 'artifact', 'scope': 'assay', 'kind': 'neighbors', 'artifact_id': '44b2e986053ce86eda2342da8a752fc407dc160b0e8493cc403aed4a36de5985', 'assay': 'RNA'}}, 'complete': True}

Started: 2026-11-14T15:50:50.127255Z | Wall time: 0.015 s

Exactly one graph matched: the saved run’s, built by build_connectivity_map with a local_connectivity of 1.0 and a bandwidth of 1.5 from the saved neighbors, 55e63bce7f20 in the first table. The provenance guide explains how results record their inputs.

Recompute a result or recover from an interruption

invalidate_cache=True makes a call compute a new artifact even when a matching one exists, as in ds.features.normalize(cell_selection, hvg_ref, invalidate_cache=True), and leaves the earlier artifact on disk. CyteArc also stops reusing a result when a release changes what its operation computes (Operation revisions).

Ctrl-C stops a recipe at its next safe checkpoint, so the current computation may finish first. A cytearc.CancellationToken passed as cancel= stops the recipe the same way from another thread, and the recipe then raises cytearc.PipelineCancelled. Either way the run is recorded as interrupted, and repeating the call with the same settings and label starts a new run that reuses every result the interrupted one completed. Partial writes are never reused: ds.artifacts.prune_incomplete(dry_run=True) lists them, and dry_run=False removes them. Remove them only when no other process is writing to the store, because a write in progress also looks incomplete (artifacts API reference).

References
  1. 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