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.

Quickstart (Python)

This page annotates the clusters of a small public dataset, 2,700 peripheral blood mononuclear cells (PBMCs) from 10x Genomics, starting from a fresh Python session. The preprocessing runs locally in a few minutes; the annotation itself runs on CyteType’s servers. The outputs on this page come from a real run of this notebook.

Before you start, you need:

  • Python 3.12 or newer with CyteType and Scanpy installed, for example with pip install cytetype "scanpy[leiden]" (see Installation).

  • A CyteType sign-in on this machine. Run cytetype setup once in a terminal (see Sign in and API keys).

Working in R? The same workflow with Seurat is in the R quickstart.

Load and cluster the data

CyteType annotates the clusters you define, using the marker genes you compute for them. These are the standard Scanpy steps: quality control, normalization, clustering and marker detection.

Started: 2026-10-18T09:26:00.316829Z | Wall time: 1.164 s

Loading...
AnnData object with n_obs × n_vars = 2700 × 32738 var: 'gene_ids'

Started: 2026-10-18T09:26:01.481775Z | Wall time: 1.306 s

Started: 2026-10-18T09:26:02.789262Z | Wall time: 1.919 s

Started: 2026-10-18T09:26:04.709565Z | Wall time: 12.039 s

Started: 2026-10-18T09:26:16.749572Z | Wall time: 0.631 s

Prepare the annotation

CyteType checks the inputs and summarizes each cluster: its top marker genes, how widely genes are expressed, and the cell metadata. It also writes two files to the working directory, vars.h5 (expression) and obs.duckdb (cell metadata and UMAP coordinates), which are uploaded with the job. Prepare your data explains each requirement.

Auto-detected gene symbols in adata.var_names (index) (0% ID-like, 100% unique).
Using coordinates from 'X_umap' for visualization.
Materialized canonical gene symbols in temporary column '__cytetype_gene_symbols' from adata.var_names.
Loading...
Extracting marker genes...
Aggregating cluster metadata...
Loading...
Loading...
Loading...
Writing obs data to duckdb artifact...
Data preparation completed. Ready for submitting jobs.

Started: 2026-10-18T09:26:17.383132Z | Wall time: 0.438 s

Run the annotation

run() uploads the files, submits the job and waits for the results. The report link is printed as soon as the job starts, so you can follow its progress in the browser. If your session ends before the job finishes, the job keeps running and you can fetch the results later (see Run, monitor and rerun jobs).

The study context tells CyteType what the sample is. Include the organism, tissue and condition; Study context and metadata has more examples.

Uploading vars.h5 artifact...
Loading...

Uploading obs.duckdb artifact...
Loading...

CyteType job submitted.
If your session disconnects, results can still be fetched later with:
`results = annotator.get_results()`

[TRACK PROGRESS]
https://cytetype.nygen.io/report/a1a55802-b137-4617-aab0-9a6fe65af05e
[DONE] CyteType job completed.
✓ Job a1a55802-b137-4617-aab0-9a6fe65af05e completed successfully.
     Annotation labels → adata.obs['cytetype_annotation_leiden']
   Cell Ontology terms → adata.obs['cytetype_cellOntologyTerm_leiden']
Cell Ontology term IDs → adata.obs['cytetype_cellOntologyTermID_leiden']
           Cell states → adata.obs['cytetype_cellState_leiden']
   Reviewer confidence → adata.obs['cytetype_reviewerConfidence_leiden']
          Full results → adata.uns['cytetype_results']
Report:
https://cytetype.nygen.io/report/a1a55802-b137-4617-aab0-9a6fe65af05e

Started: 2026-10-18T09:26:17.822558Z | Wall time: 472.362 s

Explore the results

Every cell now carries its cluster’s annotation in adata.obs: the cell type label, its Cell Ontology term and ID, the cell state and the reviewer’s confidence.

leidencytetype_annotation_leidencytetype_cellOntologyTermID_leidencytetype_reviewerConfidence_leiden
00CD8+ effector memory T cellCL:0000909High
11Naive B cellCL:0000788High
22CD4+ conventional T cellCL:0000624Moderate
33Classical monocyteCL:0000860High
44CD56-dim NK cellCL:0000939High
55Non-classical monocyteCL:0000875Moderate
66Naive CD4+ T cellCL:0000895Moderate
77Dendritic cellCL:0000451Moderate
88PlateletCL:0000233High

Started: 2026-10-18T09:34:10.189276Z | Wall time: 0.039 s

UMAP of the PBMC 3k cells colored by CyteType label. On the left, CD56-dim NK cells sit at the top above CD8+ effector memory T cells, with CD4+ conventional T cells and naive CD4+ T cells side by side below them; naive B cells form a separate group at the bottom. On the right, classical monocytes form the largest myeloid group, with non-classical monocytes above them and dendritic cells along their lower-left edge; a few dendritic cells also sit below the T cells, and a small group of platelets sits at the top right.

Started: 2026-10-18T09:34:10.233725Z | Wall time: 0.548 s

Dot plot of the key supporting genes for each CyteType label, grouped by cell type. CD79A, CD79B and MS4A1 are expressed in naive B cells; FCER1A, HLA-DRB1 and HLA-DRB5 in dendritic cells; FCGR3A, FGFBP2 and SPON2 in CD56-dim NK cells; GP9, PF4 and PPBP in platelets; CD14, LYZ and S100A8 in classical monocytes; FCGR3A, LST1 and MS4A7 in non-classical monocytes; and CD3D and CD3E across the T cell labels, with CD8A and CD8B in CD8+ effector memory T cells and CCR7 and LTB in the CD4+ T cell labels.

Started: 2026-10-18T09:34:10.786011Z | Wall time: 0.762 s

Read the evidence

get_results() returns the full results, including the evidence behind each label. Each entry in annotations describes one cluster.

Retrieving results with prefix: 'cytetype'
{'clusterId': '0', 'annotation': 'CD8+ effector memory T cell', 'cellState': 'Cytotoxic Effector Program', 'reviewerConfidence': 'High', 'supportingMarkers': ['CD8A', 'CD8B', 'CD3D', 'KLRG1', 'HOPX', 'SAMD3', 'FGFBP2', 'GZMK', 'CCL5', 'CST7', 'PRF1', 'NKG7']}

Started: 2026-10-18T09:34:11.552476Z | Wall time: 0.023 s

The interactive report holds the full reasoning for every cluster: the candidate cell types that were considered, the marker evidence, quality-control checks and pathway context. The report for this example is public; your own reports are private unless you share them (see Visibility and sharing).

'https://cytetype.nygen.io/report/a1a55802-b137-4617-aab0-9a6fe65af05e'

Started: 2026-10-18T09:34:11.580426Z | Wall time: 0.011 s

Save and clean up

The results are stored in adata.obs and adata.uns, so they are saved with the AnnData file. cleanup() deletes the upload files and the helper column that CyteType added to adata.var.

Deleted artifact file: vars.h5
Deleted artifact file: obs.duckdb
Deleted temporary canonical gene-symbol column '__cytetype_gene_symbols'.

Started: 2026-10-18T09:34:11.596663Z | Wall time: 0.349 s

Next steps