Analysis record and notebook export¶
Skopia records every operation that changes the data as you work, and turns that record into a Jupyter notebook that re-runs the analysis or a Markdown document you can adapt for a methods section. Each step says how faithfully it reproduces, so the document does not claim more than it can deliver.
Where to find it
File → Analysis record…
How it works¶
Recording is always on, from the moment a dataset is loaded; there is nothing to arm. A record button users forget to press would lose the analysis, so instead you choose afterwards which part of the history the report covers.
Each recorded step holds:
- the operation and its parameters, as Skopia ran them,
- its result (the numbers in the generated one-line summary come from here, for example Leiden clustering at resolution 1.0 → 12 clusters in
.obs['leiden']), - a timestamp,
- the cell selection it ran on, if it ran on a selection rather than the whole dataset,
- the Skopia build that ran it (see Version stamps),
- your note, if you add one, and any figures attached to it.
The record belongs to the dataset. It is written into the .h5ad when you save the file, so reopening that file continues the same history instead of starting a second one.
The record panel¶
The panel opens with a summary that matches the claim the export will make, for example 11 steps in the report, 9 re-run as written, 2 need skopia, 0 manual, plus how many ran on a cell selection.
- Title and Abstract become the document's heading and opening paragraph.
- Each step shows its title, a fidelity badge (
exact,skopiaormanual), aselection N/Mbadge when it ran on a selection, its summary, any warnings, and your note. - Add note / Edit note attaches your own text to a step: why you ran it, or what it showed. Notes appear under the step in the export.
- Show code shows the code the step exports as.
- Start here begins the report at that step. Earlier steps stay in the history, greyed out, and a Report starts here marker shows the boundary.
- Include all steps puts every step back in the report.
- Report new steps only puts everything recorded so far outside the report, so only what you run next is included.
- Clear drops the history. The load step is kept so an export still opens the right file.
If every step is outside the report, the panel says so, and an export is refused rather than written empty.
Attach figures¶
There are two ways to put a picture in the record:
- The ◧ Figure button on the plot adds the current Embedding view as a PNG, attached to the most recent step.
- Attach to record in the Figures tab attaches a saved figure, linked to the step that created that figure. The panel shows an open link back to it.
Figures that are not linked to a step are listed under Unattached figures. × removes a figure from the record.
Attached PNGs are not saved in the h5ad
The record written into the .h5ad leaves out the attached PNGs, which would bloat every saved dataset. Figure records in the Figures tab are kept in the file and can be attached again after reopening; export the notebook or Markdown before closing the session if you want the captured views.
Export¶
- In the Export section, choose Notebook (.ipynb), Markdown (.md) or Both.
- Tick code cells and figures as needed.
- Type or Browse to the output folder, and set a file name (default
analysis; a name, not a path). - Click Export. The panel lists the files written.
The export is written by the backend, into the folder you choose, so a notebook can sit next to the data it reads.
| File | When | Contents |
|---|---|---|
<name>.ipynb |
Notebook or Both | Header, one markdown cell and one code cell per step; attached figures inline. |
<name>.md |
Markdown or Both | The same narrative as Markdown, with code blocks when code cells is ticked. |
<name>_figures/ |
Markdown with figures | One PNG per attached figure, linked from the Markdown. |
<name>_selections.json |
Code cells ticked and a step ran on a selection | The recorded cell indices, keyed step_<n>. |
The notebook's first code cell holds the imports and a SOURCE_PATH constant with the file the session loaded. Change that one line to point the notebook at a copy of the data elsewhere. A dataset that was built in memory (for example by combining datasets) has no file to re-read; the notebook says so and asks you to assign adata yourself.
Fidelity: what re-runs¶
Every step carries one of three labels, and the exported document opens by stating the split in numbers:
11 steps. 9 re-run as written; 2 need the skopia Python API; 0 are manual and are described but not executed.
| Label | Meaning |
|---|---|
exact |
The exported code is the library call Skopia actually made, for example sc.pp.normalize_total(adata, …) with the recorded arguments. |
skopia |
Reproduced by calling Skopia's own Python API with the recorded parameters. The notebook wraps the AnnData in a DataAdaptor (xa) for these steps; see the Python API. |
manual |
Described in prose with its parameters, but not reproduced as code. |
The labels exist because a methods supplement that describes an analysis nobody ran is worse than none. An operation with no code translation still appears in the export as prose, never silently dropped.
To run a notebook with skopia steps, use a Python environment where Skopia is installed (the project's pixi environment, or pip install -e backend) and add Jupyter, which Skopia does not install.
Steps that ran on a selection¶
A step that ran on a cell selection (the cell mask, a lasso) is flagged in the panel and in the export, and the header counts them: N steps ran on a cell selection rather than the whole dataset. For most such steps the exported code runs on the whole dataset, and the step says so. Skopia does not generate subset-and-write-back code for them, because each operation writes back differently (UMAP writes NaN for cells outside the selection, Leiden writes unassigned), and code that is subtly wrong is the failure this feature exists to prevent.
A few operations take the selection as an argument and do replay it, reading the indices from <name>_selections.json: marker genes, diffusion maps, stemFinder, copy-number inference, and the creation of a named subset.
Selections of up to 50,000 cells are kept as indices. Above that the step keeps the count but not the indices, and cannot be replayed on the same cells.
Prefer named subsets for scoped work
Creating a named subset is itself a recorded step: its cells go into <name>_selections.json and the notebook recreates it with xa.create_cell_subset(…). The HVG, PCA, neighbors, UMAP and Leiden steps scoped to it then name the subset, so they replay on exactly those cells, which an ad hoc mask does not give you. The 50,000-cell cap applies to the subset's cells too.
Version stamps¶
Each step records the Skopia build that ran it: 0.7.0 at a release, 0.7.0+g<commit> between releases, with .dirty added when the code had uncommitted changes. A record can outlive the version that started it, so the stamp is per step.
- The document header names the builds that recorded the steps: Recorded by skopia 0.7.0 on 2026-11-30 from
data.h5ad(12,000 cells x 20,000 genes). When steps came from several builds it lists each with its step range. - The notebook's metadata (
metadata.skopia) records the build that rendered it, whose API its code cells call. - A saved
.h5adcarriesuns['skopia_provenance']: the version and build that wrote it, and when.
What it writes¶
| Where | What |
|---|---|
uns['skopia_analysis_record'] |
The record as a JSON string (source, title, abstract, steps, report start), without attached PNGs. Written when the dataset is saved as .h5ad. |
uns['skopia_provenance'] |
version, build, exported_at and, when known, commit of the Skopia that saved the file. |