Skip to content

From clicks to a notebook

Intermediate 10 minutes Data: the session from From counts to clusters, optionally with Sub-clustering

Analysis done by clicking is hard to report and harder to repeat. Skopia records every step that changes the data, with its parameters, and writes the record out as a Jupyter notebook that re-runs the analysis and a Markdown document you can adapt for a methods section. Each step is labeled with how faithfully it reproduces, so the export never claims more than it delivers (Analysis record and notebook export).

1. Open the record

Open File → Analysis record…. The header names the file the session loaded. Below it, a summary line counts the steps by how they will reproduce. After the first tutorial and the sub-clustering, it read:

14 steps in the report · 7 re-run as written · 7 need skopia · 0 manual · 6 ran on a cell selection

The analysis record

The badge on each step is its fidelity:

  • EXACT: the step exports as plain scanpy code with the recorded parameters (Normalize Total, Log1p, PCA, UMAP, Leiden and others).
  • SKOPIA: the step is reproduced by calling Skopia's own Python API, because scanpy has no equivalent (the marker-gene ranking stored for later selection, a named subset and the steps scoped to it).
  • MANUAL: the step is described but cannot be re-run as code.

A step that ran on part of the cells carries a SELECTION 600/1,000 badge.

2. Annotate it

  • Type a Title and an Abstract: they become the document's heading and opening paragraph.
  • Add note on a step to say why you ran it or what it showed. Notes appear under the step in the export.
  • Start here on a step drops the earlier steps from the report (they stay in the history, greyed out), which is useful when the first part of a session was exploration.

3. Export

  1. Under Export, choose Both (notebook and Markdown). Keep code cells and figures ticked.
  2. Type an output folder, or Browse to one. The folder must already exist.
  3. Set the file name, for example toy_analysis, and click Export.

The panel lists what it wrote. For a session with a named subset there are three files:

toy_analysis.ipynb
toy_analysis.md
toy_analysis_selections.json

The JSON file holds the cell selections the scoped steps ran on, so the notebook can recreate the subset on exactly the same cells.

4. Run the notebook

The notebook's first code cell sets SOURCE_PATH to the file the session loaded; change that line if the data has moved. Run it in an environment where Skopia is installed, since the SKOPIA steps import it (the project's pixi environment works; add Jupyter, which Skopia does not install).

We ran the exported notebook for this tutorial's session outside the app. It printed the same clusters the browser showed: leiden with 334, 266, 176, 134 and 90 cells, and leiden_mesen with 231, 208 and 161 cells plus 400 unassigned.

What does not travel

Figures attached to the record with ◧ Figure are written into the notebook when you export, but they are not saved in the .h5ad, which would grow with every capture. Export before you close the session if you want them. Figure records in the Figures tab are saved with the data.

Where next