A dataset is an h5ad file with raw counts and a column of cell type labels, plus a configuration
file in datasets/. The toy dataset is a complete example. Annotation mode also takes data
without labels (see the README).
The file needs
- raw counts, in
Xor in a layer (name it withpreprocessing.count_layer_key), - genes with Ensembl ids or gene symbols in
var(symbols are mapped to Ensembl ids of the dataset'sspecies, which needs thepybiomartpackage and an internet connection; offline, a table of human genes inresources/ensembl/serves human data only), - a column in
obswith the cell type of every cell, and one with the batch if the cells come from several batches.
The toy dataset tests/data/toy_blood.h5ad has raw counts in X, Ensembl ids as var index,
symbols in var["feature_name"], and cell_type and batch_id in obs.
Create datasets/<name>.yml. The file name is the dataset's name. The toy dataset's
datasets/toy.yml in short:
name: toy
path: tests/data/toy_blood.h5ad # or url: ..., or source: cellxgene_census with census_dataset_id
annotation_key: "cell_type"
batch_key: "batch_id"
apply_ontology_mapping: false # the labels are Cell Ontology terms already
species: "human"
tissue: "blood (peripheral blood immune cells)"
preprocessing:
min_cells: 3 # the defaults suit large datasets; 40 cells need a lower valueEvery key is explained in parameters.md. Keys that only
one method reads (celltypist_model, sctype_tissue, scsa_tissue, singler_reference*) are
needed only when that method runs on the dataset.
The scores compare Cell Ontology terms, so every label must resolve to one. Labels from CELLxGENE
are terms already. For other labels set apply_ontology_mapping: true. On the first run, labels
that are not in the mapping table are added to resources/cell_type_ontology_mappings.csv with a
suggested term and reviewed set to False. Check the suggestions, correct chosen_match where
needed and set reviewed to True. The first run has already written the suggested terms
into the preprocessed data, so delete the dataset's preprocessed data and test sets
(cache/datasets/preprocessed/*/<name>_pp.h5ad, cache/datasets/subset/*/<name>_sub*) before
you run again.
Write a parameter file, for example my_dataset.yml:
datasets: [toy]
models: [random_stratified]
subset_sizes: [40] # cells per test set
min_cells_per_type: 5 # cell types with fewer cells are left out of the test set
download_from_zenodo: false # build the test set from the data
fetch_context_from_zenodo: falsenextflow run main.nf -profile local -params-file my_dataset.ymlThis is tests/toy.params.yml. The run preprocesses the data (QC plots in cache/plots/), draws
the test set (cell type counts in cache/subset_qc/), runs the methods and scores them.
- scType and SCSA annotate clusters. They get a clustering sample of the full dataset that contains
the test set; with
fetch_context_from_zenodo: falsethe pipeline builds it. - The scLMs that read human genes only get mouse data as one-to-one human orthologs. Other
organisms need an ortholog table in
ortholog_tables. - SingleR needs a reference: name a celldex reference or a CELLxGENE dataset in the configuration.
- The constrained settings (
*_constrained) use the dataset's cell types as the list of expected types.