From 262799c0a78e366bd14a9a0539e44c705ec45e40 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Tue, 17 Nov 2026 20:19:52 +0100 Subject: [PATCH 01/14] add validate_dataset component --- .../validate_dataset/config.vsh.yaml | 32 ++++++++++++ src/validation/validate_dataset/script.py | 32 ++++++++++++ src/validation/validate_dataset/test.py | 51 +++++++++++++++++++ .../config.vsh.yaml | 0 .../main.nf | 0 .../config.vsh.yaml | 0 .../main.nf | 0 7 files changed, 115 insertions(+) create mode 100644 src/validation/validate_dataset/config.vsh.yaml create mode 100644 src/validation/validate_dataset/script.py create mode 100644 src/validation/validate_dataset/test.py rename src/workflows/scrnaseq/{process_cellxgene_census => load_cellxgene_census}/config.vsh.yaml (100%) rename src/workflows/scrnaseq/{process_cellxgene_census => load_cellxgene_census}/main.nf (100%) rename src/workflows/scrnaseq/{process_openproblems_op3 => load_openproblems_op3}/config.vsh.yaml (100%) rename src/workflows/scrnaseq/{process_openproblems_op3 => load_openproblems_op3}/main.nf (100%) diff --git a/src/validation/validate_dataset/config.vsh.yaml b/src/validation/validate_dataset/config.vsh.yaml new file mode 100644 index 0000000..4365e15 --- /dev/null +++ b/src/validation/validate_dataset/config.vsh.yaml @@ -0,0 +1,32 @@ +name: validate_dataset +namespace: validation +description: | + Check that a dataset matches its file format in `src/api`. Fails when a required + slot is missing, so that an invalid dataset is never published. +argument_groups: + - name: Inputs + description: Pass one or more of these files. + arguments: + - name: --input_raw + __merge__: /src/api/file_raw.yaml + direction: input + required: false + - name: --input_dataset + __merge__: /src/api/file_common_dataset.yaml + direction: input + required: false +resources: + - type: python_script + path: script.py +test_resources: + - type: python_script + path: test.py + - path: /resources_test/common/cxg_mouse_pancreas_atlas +engines: + - type: docker + image: openproblems/base_python:1 +runners: + - type: executable + - type: nextflow + directives: + label: [lowtime, midmem, lowcpu] diff --git a/src/validation/validate_dataset/script.py b/src/validation/validate_dataset/script.py new file mode 100644 index 0000000..087e8d2 --- /dev/null +++ b/src/validation/validate_dataset/script.py @@ -0,0 +1,32 @@ +import yaml +from openproblems.project.component_tests.run_and_check_output import check_format + +## VIASH START +par = { + "input_raw": "resources_test/common/cxg_mouse_pancreas_atlas/raw.anndata.zarr", + "input_dataset": "resources_test/common/cxg_mouse_pancreas_atlas/dataset.anndata.zarr", +} +meta = { + "config": "target/executable/validation/validate_dataset/.config.vsh.yaml", +} +## VIASH END + +# read the file formats from the built config, in which viash has resolved the merges +with open(meta["config"]) as f: + config = yaml.safe_load(f) +arguments = [ + arg + for group in config.get("argument_groups", []) + for arg in group["arguments"] +] + +# check every input that was passed +inputs = [arg for arg in arguments if par.get(arg["name"].lstrip("-")) is not None] +assert inputs, "Pass at least one of " + ", ".join(arg["name"] for arg in arguments) + +for arg in inputs: + clean_name = arg["name"].lstrip("-") + print(f">> Checking {clean_name} against '{arg['label']}'", flush=True) + check_format({**arg, "clean_name": clean_name, "value": par[clean_name]}) + +print(">> All inputs match their format", flush=True) diff --git a/src/validation/validate_dataset/test.py b/src/validation/validate_dataset/test.py new file mode 100644 index 0000000..6babb82 --- /dev/null +++ b/src/validation/validate_dataset/test.py @@ -0,0 +1,51 @@ +import shutil +import subprocess +from pathlib import Path + +import anndata as ad + +## VIASH START +meta = { + "executable": "target/executable/validation/validate_dataset/validate_dataset", + "resources_dir": "resources_test/common", + "temp_dir": "/tmp", +} +## VIASH END + +resources = Path(meta["resources_dir"]) / "cxg_mouse_pancreas_atlas" +raw = resources / "raw.anndata.zarr" +dataset = resources / "dataset.anndata.zarr" + + +def validate(*args): + return subprocess.run([meta["executable"], *args], capture_output=True, text=True) + + +print(">> Valid raw and processed datasets pass", flush=True) +for args in [ + ["--input_raw", raw], + ["--input_dataset", dataset], + ["--input_raw", raw, "--input_dataset", dataset], +]: + out = validate(*map(str, args)) + assert out.returncode == 0, out.stdout + out.stderr + +print(">> A raw dataset is not a processed dataset", flush=True) +out = validate("--input_dataset", str(raw)) +assert out.returncode != 0 +assert "is missing slot" in out.stdout + out.stderr, out.stdout + out.stderr + +print(">> A raw dataset without a required obs column fails", flush=True) +adata = ad.read_zarr(raw) +del adata.obs["cell_type_ontology_term_id"] +broken = Path(meta["temp_dir"]) / "broken.anndata.zarr" +shutil.rmtree(broken, ignore_errors=True) +adata.write_zarr(broken) +out = validate("--input_raw", str(broken)) +assert out.returncode != 0 +assert "cell_type_ontology_term_id" in out.stdout + out.stderr, out.stdout + out.stderr + +print(">> Passing no input fails", flush=True) +assert validate().returncode != 0 + +print(">> All tests passed", flush=True) diff --git a/src/workflows/scrnaseq/process_cellxgene_census/config.vsh.yaml b/src/workflows/scrnaseq/load_cellxgene_census/config.vsh.yaml similarity index 100% rename from src/workflows/scrnaseq/process_cellxgene_census/config.vsh.yaml rename to src/workflows/scrnaseq/load_cellxgene_census/config.vsh.yaml diff --git a/src/workflows/scrnaseq/process_cellxgene_census/main.nf b/src/workflows/scrnaseq/load_cellxgene_census/main.nf similarity index 100% rename from src/workflows/scrnaseq/process_cellxgene_census/main.nf rename to src/workflows/scrnaseq/load_cellxgene_census/main.nf diff --git a/src/workflows/scrnaseq/process_openproblems_op3/config.vsh.yaml b/src/workflows/scrnaseq/load_openproblems_op3/config.vsh.yaml similarity index 100% rename from src/workflows/scrnaseq/process_openproblems_op3/config.vsh.yaml rename to src/workflows/scrnaseq/load_openproblems_op3/config.vsh.yaml diff --git a/src/workflows/scrnaseq/process_openproblems_op3/main.nf b/src/workflows/scrnaseq/load_openproblems_op3/main.nf similarity index 100% rename from src/workflows/scrnaseq/process_openproblems_op3/main.nf rename to src/workflows/scrnaseq/load_openproblems_op3/main.nf From 783946835440d62e9b1eed12a8ae96eca9762009 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Tue, 17 Nov 2026 20:19:52 +0100 Subject: [PATCH 02/14] split scrnaseq workflows into load and process --- scripts/create_resources/cellxgene_census.sh | 10 +- scripts/create_resources/openproblems_op3.sh | 13 +-- .../create_resources/openproblems_op3_test.sh | 24 +++-- .../scrnaseq/arguments_subsample.yaml | 38 ++++++++ .../load_cellxgene_census/config.vsh.yaml | 93 ++---------------- .../scrnaseq/load_cellxgene_census/main.nf | 97 +++---------------- .../load_openproblems_op3/config.vsh.yaml | 81 +--------------- .../scrnaseq/load_openproblems_op3/main.nf | 92 ++---------------- .../scrnaseq/process_scrnaseq/config.vsh.yaml | 43 ++++++++ .../scrnaseq/process_scrnaseq/main.nf | 51 ++++++++++ 10 files changed, 187 insertions(+), 355 deletions(-) create mode 100644 src/workflows/scrnaseq/arguments_subsample.yaml create mode 100644 src/workflows/scrnaseq/process_scrnaseq/config.vsh.yaml create mode 100644 src/workflows/scrnaseq/process_scrnaseq/main.nf diff --git a/scripts/create_resources/cellxgene_census.sh b/scripts/create_resources/cellxgene_census.sh index ab4344f..89687a5 100755 --- a/scripts/create_resources/cellxgene_census.sh +++ b/scripts/create_resources/cellxgene_census.sh @@ -117,14 +117,8 @@ param_list: dataset_reference: steuernagel2022hypomap dataset_organism: mus_musculus -normalization_methods: [log_cp10k, sqrt_cp10k, l1_sqrt] -output_dataset: '$id/dataset.anndata.zarr' +output_raw: '$id/raw.anndata.zarr' output_state: '$id/state.yaml' -output_raw: force_null -output_normalized: force_null -output_pca: force_null -output_hvg: force_null -output_knn: force_null publish_dir: s3://openproblems-data/resources/datasets/scrnaseq HERE @@ -144,7 +138,7 @@ HERE tw launch https://github.com/openproblems-bio/datasets.git \ --revision build/main \ --pull-latest \ - --main-script target/nextflow/workflows/scrnaseq/process_cellxgene_census/main.nf \ + --main-script target/nextflow/workflows/scrnaseq/load_cellxgene_census/main.nf \ --workspace 53907369739130 \ --compute-env 6TeIFgV5OY4pJCk8I0bfOh \ --params-file "/tmp/params.yaml" \ diff --git a/scripts/create_resources/openproblems_op3.sh b/scripts/create_resources/openproblems_op3.sh index fc2e8a9..6939129 100755 --- a/scripts/create_resources/openproblems_op3.sh +++ b/scripts/create_resources/openproblems_op3.sh @@ -1,5 +1,5 @@ #!/bin/bash -#It is an example how to set parameters and execute processing for the op3 dataset. +# Load the OP3 dataset as a raw dataset. set -e params_file="/tmp/datasets_op3.yaml" @@ -13,16 +13,9 @@ param_list: dataset_description: "The OP3 dataset is to-date the largest single-cell small molecule perturbation dataset in primary tissue with multiple donor replicates." dataset_url: "https://ftp.ncbi.nlm.nih.gov/geo/series/GSE279nnn/GSE279945/suppl/GSE279945_sc_counts_processed.h5ad" dataset_reference: GSE279945 -normalization_methods: - - log_cp10k -output_dataset: '$id/dataset.anndata.zarr' do_subsample: False +output_raw: '$id/raw.anndata.zarr' output_state: '$id/state.yaml' -output_raw: force_null -output_normalized: force_null -output_pca: force_null -output_hvg: force_null -output_knn: force_null publish_dir: s3://openproblems-data/resources/datasets HERE @@ -38,7 +31,7 @@ HERE tw launch https://github.com/openproblems-bio/datasets.git \ --revision build/main \ --pull-latest \ - --main-script target/nextflow/workflows/scrnaseq/process_openproblems_op3/main.nf \ + --main-script target/nextflow/workflows/scrnaseq/load_openproblems_op3/main.nf \ --workspace 53907369739130 \ --params-file "$params_file" \ --labels op3,dataset_loader \ diff --git a/scripts/create_resources/openproblems_op3_test.sh b/scripts/create_resources/openproblems_op3_test.sh index 71573b0..8d4aeaf 100755 --- a/scripts/create_resources/openproblems_op3_test.sh +++ b/scripts/create_resources/openproblems_op3_test.sh @@ -19,24 +19,28 @@ HERE set -x nextflow run . \ - -main-script target/nextflow/workflows/scrnaseq/process_openproblems_op3/main.nf \ + -main-script target/nextflow/workflows/scrnaseq/load_openproblems_op3/main.nf \ -profile docker \ -resume \ --input https://ftp.ncbi.nlm.nih.gov/geo/series/GSE279nnn/GSE279945/suppl/GSE279945_sc_counts_processed.h5ad \ - --id openproblems_sop3 \ + --id openproblems_op3 \ --dataset_name "OP3: single-cell multimodal dataset in PBMCs for perturbation prediction benchmarking" \ --dataset_summary "The Open Problems Perurbation Prediction (OP3) dataset with small molecule perturbations in PBMCs" \ --dataset_description "The OP3 dataset is to-date the largest single-cell small molecule perturbation dataset in primary tissue with multiple donor replicates." \ --dataset_url "https://ftp.ncbi.nlm.nih.gov/geo/series/GSE279nnn/GSE279945/suppl/GSE279945_sc_counts_processed.h5ad" \ --dataset_reference GSE279945 \ --do_subsample False \ - --normalization_methods log_cp10k \ - --output_dataset '$id/dataset.anndata.zarr' \ - --output_state '$id/state.yaml' \ - --output_raw force_null \ - --output_normalized force_null \ - --output_pca force_null \ - --output_hvg force_null \ - --output_knn force_null \ + --output_raw '$id/raw.anndata.zarr' \ + --output_state '$id/load_state.yaml' \ --publish_dir $DATASET_DIR \ -config /tmp/nextflow.config + +nextflow run . \ + -main-script target/nextflow/workflows/scrnaseq/process_scrnaseq/main.nf \ + -profile docker \ + -resume \ + --id openproblems_op3 \ + --input "$DATASET_DIR/openproblems_op3/raw.anndata.zarr" \ + --output_dataset '$id/dataset.anndata.zarr' \ + --output_state '$id/process_state.yaml' \ + --publish_dir $DATASET_DIR diff --git a/src/workflows/scrnaseq/arguments_subsample.yaml b/src/workflows/scrnaseq/arguments_subsample.yaml new file mode 100644 index 0000000..909e492 --- /dev/null +++ b/src/workflows/scrnaseq/arguments_subsample.yaml @@ -0,0 +1,38 @@ +name: Sampling options +description: Subsample the dataset, e.g. to create test resources. +arguments: + - name: --do_subsample + type: boolean + default: false + description: Whether or not to subsample the dataset. + - name: --n_obs + type: integer + description: Maximum number of observations to be kept. It might end up being + less because empty cells / genes are removed. + default: 500 + - name: --n_vars + type: integer + description: Maximum number of variables to be kept. It might end up being + less because empty cells / genes are removed. + default: 500 + - name: --keep_features + type: string + multiple: true + description: A list of genes to keep. + - name: --keep_cell_type_categories + type: string + multiple: true + description: Cell types to keep. + required: false + - name: --keep_batch_categories + type: string + multiple: true + description: Batches to keep. + required: false + - name: --even + type: boolean_true + description: Subsample evenly from different batches. + - name: --seed + type: integer + description: A seed for the subsampling. + default: 0 diff --git a/src/workflows/scrnaseq/load_cellxgene_census/config.vsh.yaml b/src/workflows/scrnaseq/load_cellxgene_census/config.vsh.yaml index 124c725..aeaa12e 100644 --- a/src/workflows/scrnaseq/load_cellxgene_census/config.vsh.yaml +++ b/src/workflows/scrnaseq/load_cellxgene_census/config.vsh.yaml @@ -1,7 +1,7 @@ -name: process_cellxgene_census +name: load_cellxgene_census namespace: workflows/scrnaseq description: | - Fetch and process datasets originating from the CELLxGENE census. + Fetch a dataset from the CELLxGENE Census and store it as a raw dataset. argument_groups: - name: Input database description: Open CellxGene Census by version or URI. @@ -13,12 +13,13 @@ argument_groups: required: false example: s3://bucket/path - name: --census_version - description: Which release of CellxGene census to use. Possible values are - "latest", "stable", or the date of one of the releases (e.g. "2023-07-25"). - For more information, check the documentation on [Census data + description: | + The date of the CELLxGENE Census release to use (e.g. "2023-07-25"). `latest` + and `stable` are not allowed, so that the same parameters always give the same + dataset. For more information, check the documentation on [Census data releases](https://chanzuckerberg.github.io/cellxgene-census/cellxgene_census_docsite_data_release_info.html). type: string - example: stable + example: "2023-07-25" required: false - name: Cell query description: Arguments related to the query. @@ -108,94 +109,20 @@ argument_groups: type: string description: The organism of the dataset. required: true - - name: Sampling options - arguments: - - name: --do_subsample - type: boolean - default: false - description: Whether or not to subsample the dataset - - name: --n_obs - type: integer - description: Maximum number of observations to be kept. It might end up being - less because empty cells / genes are removed. - default: 500 - - name: --n_vars - type: integer - description: Maximum number of variables to be kept. It might end up being - less because empty cells / genes are removed. - default: 500 - - name: --keep_features - type: string - multiple: true - description: A list of genes to keep. - - name: --keep_cell_type_categories - type: string - multiple: true - description: Categories indexes to be selected - required: false - - name: --keep_batch_categories - type: string - multiple: true - description: Categories indexes to be selected - required: false - - name: --even - type: boolean_true - description: Subsample evenly from different batches - - name: --seed - type: integer - description: A seed for the subsampling. - example: 123 - - name: Normalization - arguments: - - name: --normalization_methods - type: string - multiple: true - choices: [log_cp10k, log_cpm, sqrt_cp10k, sqrt_cpm, l1_sqrt, log_scran_pooling] - default: [log_cp10k, log_cpm, sqrt_cp10k, sqrt_cpm, l1_sqrt] - description: Which normalization methods to run. + - __merge__: /src/workflows/scrnaseq/arguments_subsample.yaml - name: Outputs arguments: - - name: --output_dataset - __merge__: /src/api/file_common_dataset.yaml - direction: output - required: true - name: --output_raw __merge__: /src/api/file_raw.yaml direction: output - required: false - - name: --output_normalized - __merge__: /src/api/file_normalized.yaml - direction: output - required: false - - name: --output_pca - __merge__: /src/api/file_pca.yaml - direction: output - required: false - - name: --output_hvg - __merge__: /src/api/file_hvg.yaml - direction: output - required: false - - name: --output_knn - __merge__: /src/api/file_knn.yaml - direction: output - required: false + required: true resources: - type: nextflow_script path: main.nf entrypoint: run_wf dependencies: - name: loaders/scrnaseq/cellxgene_census - - name: normalization/log_cp - - name: normalization/log_scran_pooling - - name: normalization/sqrt_cp - - name: normalization/l1_sqrt - name: processors/subsample - - name: processors/pca - - name: processors/hvg - - name: processors/knn - # test_resources: - # - type: nextflow_script - # path: main.nf - # entrypoint: test_wf + - name: validation/validate_dataset runners: - type: nextflow diff --git a/src/workflows/scrnaseq/load_cellxgene_census/main.nf b/src/workflows/scrnaseq/load_cellxgene_census/main.nf index 06a0971..ab3e866 100644 --- a/src/workflows/scrnaseq/load_cellxgene_census/main.nf +++ b/src/workflows/scrnaseq/load_cellxgene_census/main.nf @@ -10,43 +10,17 @@ workflow run_wf { input_ch main: - - // create different normalization methods by overriding the defaults - normalization_methods = [ - log_cp.run( - key: "log_cp10k", - args: [normalization_id: "log_cp10k", n_cp: 10000], - ), - log_cp.run( - key: "log_cpm", - args: [normalization_id: "log_cpm", n_cp: 1000000], - ), - sqrt_cp.run( - key: "sqrt_cp10k", - args: [normalization_id: "sqrt_cp10k", n_cp: 10000], - ), - sqrt_cp.run( - key: "sqrt_cpm", - args: [normalization_id: "sqrt_cpm", n_cp: 1000000], - ), - l1_sqrt.run( - key: "l1_sqrt", - args: [normalization_id: "l1_sqrt"], - ), - log_scran_pooling.run( - key: "log_scran_pooling", - args: [normalization_id: "log_scran_pooling"], - ) - ] - output_ch = input_ch - // store original id for later use + // a moving release would give a different dataset for the same parameters | map{ id, state -> - [id, state + [_meta: [join_id: id]]] + if (!state.input_uri && !(state.census_version ==~ /\d{4}-\d{2}-\d{2}/)) { + error "Dataset '${id}': --census_version must be the date of a Census release, got '${state.census_version}'" + } + [id, state] } - // fetch data from legacy openproblems + // fetch data from the CELLxGENE Census | cellxgene_census.run( fromState: [ "input_uri": "input_uri", @@ -67,7 +41,8 @@ workflow run_wf { ], toState: ["output_raw": "output"] ) - + + // subsample if so desired | subsample.run( runIf: { id, state -> state.do_subsample }, @@ -85,58 +60,14 @@ workflow run_wf { toState: ["output_raw": "output"] ) - | runEach( - components: normalization_methods, - id: { id, state, comp -> - if (state.normalization_methods.size() > 1) { - id + "/" + comp.name - } else { - id - } - }, - filter: { id, state, comp -> - comp.name in state.normalization_methods - }, - fromState: ["input": "output_raw"], - toState: { id, output, state, comp -> - state + [ - output_normalized: output.output, - normalization_id: comp.name - ] - } + // fail before publishing anything that does not match the raw format + | validate_dataset.run( + fromState: ["input_raw": "output_raw"], + toState: { id, output, state -> state } ) - | hvg.run( - fromState: ["input": "output_normalized"], - toState: ["output_hvg": "output"] - ) - - | pca.run( - fromState: ["input": "output_hvg"], - toState: ["output_pca": "output" ] - ) - - | knn.run( - fromState: ["input": "output_pca"], - toState: ["output_knn": "output"] - ) - - // add synonym - | map{ id, state -> - [id, state + [output_dataset: state.output_knn]] - } - - // only output the files for which an output file was specified - | setState([ - "output_dataset", - "output_raw", - "output_normalized", - "output_pca", - "output_hvg", - "output_knn", - "_meta" - ]) + | setState(["output_raw"]) emit: output_ch -} \ No newline at end of file +} diff --git a/src/workflows/scrnaseq/load_openproblems_op3/config.vsh.yaml b/src/workflows/scrnaseq/load_openproblems_op3/config.vsh.yaml index 8d9610c..0758b99 100644 --- a/src/workflows/scrnaseq/load_openproblems_op3/config.vsh.yaml +++ b/src/workflows/scrnaseq/load_openproblems_op3/config.vsh.yaml @@ -1,8 +1,7 @@ -name: process_openproblems_op3 +name: load_openproblems_op3 namespace: workflows/scrnaseq description: | - "Fetch, filter, normalize, and prepare datasets from the Open Problems Perturbation Prediction (OP3) dataset - for benchmarking and analysis." + Fetch the Open Problems Perturbation Prediction (OP3) dataset and store it as a raw dataset. argument_groups: - name: Input options description: "Options for selecting input data" @@ -64,90 +63,20 @@ argument_groups: required: true default: "The OP3 dataset is to-date the largest single-cell small molecule perturbation dataset in primary tissue with multiple donor replicates." - - name: Sampling options - arguments: - - name: --do_subsample - type: boolean - default: false - description: "Whether or not to subsample the dataset." - - name: --n_obs - type: integer - description: "Maximum number of observations to be kept. It might end up being - less because empty cells / genes are removed." - default: 500 - - name: --n_vars - type: integer - description: "Maximum number of variables to be kept. It might end up being - less because empty cells / genes are removed." - default: 500 - - name: --keep_features - type: string - multiple: true - description: "A list of genes to keep." - - name: --keep_cell_type_categories - type: string - multiple: true - description: "Categories indexes to be selected." - required: false - - name: --keep_batch_categories - type: string - multiple: true - description: "Categories indexes to be selected." - required: false - - name: --even - type: boolean_true - description: "Subsample evenly from different batches." - - name: --seed - type: integer - description: "A seed for the subsampling." - example: 123 - - name: Normalization - arguments: - - name: --normalization_methods - type: string - multiple: true - choices: [log_cp10k, log_cpm, sqrt_cp10k, sqrt_cpm, l1_sqrt, log_scran_pooling] - default: [log_cp10k, log_cpm, sqrt_cp10k, sqrt_cpm, l1_sqrt] - description: "Which normalization methods to run." + - __merge__: /src/workflows/scrnaseq/arguments_subsample.yaml - name: Outputs arguments: - - name: --output_dataset - __merge__: /src/api/file_common_dataset.yaml - direction: output - required: true - name: --output_raw __merge__: /src/api/file_raw.yaml - direction: output - required: false - - name: --output_normalized - __merge__: /src/api/file_normalized.yaml - direction: output - required: false - - name: --output_pca - __merge__: /src/api/file_pca.yaml - direction: output - required: false - - name: --output_hvg - __merge__: /src/api/file_hvg.yaml direction: output - required: false - - name: --output_knn - __merge__: /src/api/file_knn.yaml - direction: output - required: false + required: true resources: - type: nextflow_script path: main.nf entrypoint: run_wf dependencies: - name: loaders/scrnaseq/openproblems_op3 - - name: normalization/log_cp - - name: normalization/log_scran_pooling - - name: normalization/sqrt_cp - - name: normalization/l1_sqrt - name: processors/subsample - - name: processors/pca - - name: processors/hvg - - name: processors/knn + - name: validation/validate_dataset runners: - type: nextflow diff --git a/src/workflows/scrnaseq/load_openproblems_op3/main.nf b/src/workflows/scrnaseq/load_openproblems_op3/main.nf index de955eb..97d639e 100644 --- a/src/workflows/scrnaseq/load_openproblems_op3/main.nf +++ b/src/workflows/scrnaseq/load_openproblems_op3/main.nf @@ -10,46 +10,12 @@ workflow run_wf { input_ch main: - - // create different normalization methods by overriding the defaults - normalization_methods = [ - log_cp.run( - key: "log_cp10k", - args: [normalization_id: "log_cp10k", n_cp: 10000], - ), - log_cp.run( - key: "log_cpm", - args: [normalization_id: "log_cpm", n_cp: 1000000], - ), - sqrt_cp.run( - key: "sqrt_cp10k", - args: [normalization_id: "sqrt_cp10k", n_cp: 10000], - ), - sqrt_cp.run( - key: "sqrt_cpm", - args: [normalization_id: "sqrt_cpm", n_cp: 1000000], - ), - l1_sqrt.run( - key: "l1_sqrt", - args: [normalization_id: "l1_sqrt"], - ), - log_scran_pooling.run( - key: "log_scran_pooling", - args: [normalization_id: "log_scran_pooling"], - ) - ] - output_ch = input_ch - // store original id for later use - | map{ id, state -> - [id, state + [_meta: [join_id: id]]] - } - // fetch data from OP3 dataset | openproblems_op3.run( fromState: [ - "input": "input", + "input": "input", "data_type": "data_type", "donor_id": "donor_id", "cell_type": "cell_type", @@ -81,58 +47,14 @@ workflow run_wf { toState: ["output_raw": "output"] ) - | runEach( - components: normalization_methods, - id: { id, state, comp -> - if (state.normalization_methods.size() > 1) { - id + "/" + comp.name - } else { - id - } - }, - filter: { id, state, comp -> - comp.name in state.normalization_methods - }, - fromState: ["input": "output_raw"], - toState: { id, output, state, comp -> - state + [ - output_normalized: output.output, - normalization_id: comp.name - ] - } - ) - - | hvg.run( - fromState: ["input": "output_normalized"], - toState: ["output_hvg": "output"] + // fail before publishing anything that does not match the raw format + | validate_dataset.run( + fromState: ["input_raw": "output_raw"], + toState: { id, output, state -> state } ) - | pca.run( - fromState: ["input": "output_hvg"], - toState: ["output_pca": "output" ] - ) - - | knn.run( - fromState: ["input": "output_pca"], - toState: ["output_knn": "output"] - ) - - // add synonym - | map{ id, state -> - [id, state + [output_dataset: state.output_knn]] - } - - // only output the files for which an output file was specified - | setState([ - "output_dataset", - "output_raw", - "output_normalized", - "output_pca", - "output_hvg", - "output_knn", - "_meta" - ]) + | setState(["output_raw"]) emit: output_ch -} +} diff --git a/src/workflows/scrnaseq/process_scrnaseq/config.vsh.yaml b/src/workflows/scrnaseq/process_scrnaseq/config.vsh.yaml new file mode 100644 index 0000000..b775e42 --- /dev/null +++ b/src/workflows/scrnaseq/process_scrnaseq/config.vsh.yaml @@ -0,0 +1,43 @@ +name: process_scrnaseq +namespace: workflows/scrnaseq +description: | + Process a raw scRNA-seq dataset into a common dataset: normalise the counts to + log CP10k, select highly variable genes, compute a PCA on those genes and build + a kNN graph on the PCA embedding. +argument_groups: + - name: Inputs + arguments: + - name: --input + __merge__: /src/api/file_raw.yaml + direction: input + required: true + - name: Outputs + arguments: + - name: --output_dataset + __merge__: /src/api/file_common_dataset.yaml + direction: output + required: true + - name: --output_normalized + __merge__: /src/api/file_normalized.yaml + direction: output + required: false + - name: --output_hvg + __merge__: /src/api/file_hvg.yaml + direction: output + required: false + - name: --output_pca + __merge__: /src/api/file_pca.yaml + direction: output + required: false +resources: + - type: nextflow_script + path: main.nf + entrypoint: run_wf +dependencies: + - name: normalization/log_cp + - name: processors/hvg + - name: processors/pca + - name: processors/knn + - name: validation/validate_dataset +runners: + - type: nextflow diff --git a/src/workflows/scrnaseq/process_scrnaseq/main.nf b/src/workflows/scrnaseq/process_scrnaseq/main.nf new file mode 100644 index 0000000..6504ab6 --- /dev/null +++ b/src/workflows/scrnaseq/process_scrnaseq/main.nf @@ -0,0 +1,51 @@ +workflow auto { + findStates(params, meta.config) + | meta.workflow.run( + auto: [publish: "state"] + ) +} + +workflow run_wf { + take: + input_ch + + main: + output_ch = input_ch + + | log_cp.run( + fromState: ["input": "input"], + args: [normalization_id: "log_cp10k", n_cp: 10000], + toState: ["output_normalized": "output"] + ) + + | hvg.run( + fromState: ["input": "output_normalized"], + toState: ["output_hvg": "output"] + ) + + | pca.run( + fromState: ["input": "output_hvg"], + toState: ["output_pca": "output"] + ) + + | knn.run( + fromState: ["input": "output_pca"], + toState: ["output_dataset": "output"] + ) + + // fail before publishing anything that does not match the common dataset format + | validate_dataset.run( + fromState: ["input_dataset": "output_dataset"], + toState: { id, output, state -> state } + ) + + | setState([ + "output_dataset", + "output_normalized", + "output_hvg", + "output_pca" + ]) + + emit: + output_ch +} From 529a1fcbf0a5dc45414ce72ac89714fe8b25c9e5 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Tue, 17 Nov 2026 20:19:52 +0100 Subject: [PATCH 03/14] pin number of threads --- _viash.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_viash.yaml b/_viash.yaml index 28d54b5..b136e1a 100644 --- a/_viash.yaml +++ b/_viash.yaml @@ -21,7 +21,7 @@ links: config_mods: | .runners[.type == "nextflow"].config.labels := { lowmem : "memory = 20.Gb", midmem : "memory = 50.Gb", highmem : "memory = 100.Gb", lowcpu : "cpus = 5", midcpu : "cpus = 15", highcpu : "cpus = 30", lowtime : "time = 1.h", midtime : "time = 4.h", hightime : "time = 8.h", veryhightime : "time = 24.h" } - .engines[.type == "docker"].setup += { type: "docker", env: ["ANNDATA_ZARR_WRITE_FORMAT=3"] } + .engines[.type == "docker"].setup += { type: "docker", env: ["ANNDATA_ZARR_WRITE_FORMAT=3", "OMP_NUM_THREADS=4", "OPENBLAS_NUM_THREADS=4", "MKL_NUM_THREADS=4", "NUMBA_NUM_THREADS=4"] } repositories: - name: openproblems From e712b068442e710a6e89a6cd11d61deb7fe88598 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Tue, 17 Nov 2026 20:19:52 +0100 Subject: [PATCH 04/14] use load and process workflows in notebooks --- .../cxg_immune_cell_atlas.ipynb | 42 +++++++++++------ .../cxg_mouse_pancreas_atlas.ipynb | 46 ++++++++++++------- scripts/create_test_resources/helpers.py | 9 ++-- 3 files changed, 63 insertions(+), 34 deletions(-) diff --git a/scripts/create_test_resources/cxg_immune_cell_atlas.ipynb b/scripts/create_test_resources/cxg_immune_cell_atlas.ipynb index 0a0eb1d..09d0ce4 100644 --- a/scripts/create_test_resources/cxg_immune_cell_atlas.ipynb +++ b/scripts/create_test_resources/cxg_immune_cell_atlas.ipynb @@ -37,23 +37,14 @@ ], "id": "90648396" }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Process\n", - "\n", - "The counts are normalised to log counts per 10,000 (log CP10k). We then select the 1000 most highly variable genes, compute a 50-dimensional PCA on those genes, and build a 15-nearest-neighbour graph on the PCA embedding." - ], - "id": "21501390" - }, { "cell_type": "code", "execution_count": null, + "id": "82c148a7", "metadata": {}, "outputs": [], "source": [ - "output_dir = helpers.run_workflow(\"scrnaseq/process_cellxgene_census\", {\n", + "output_dir = helpers.run_workflow(\"scrnaseq/load_cellxgene_census\", {\n", " \"id\": \"cxg_immune_cell_atlas\",\n", " \"species\": \"homo_sapiens\",\n", " \"census_version\": \"2023-07-25\",\n", @@ -69,10 +60,33 @@ " \"n_obs\": 600,\n", " \"n_vars\": 1500,\n", " \"seed\": 123,\n", - " \"normalization_methods\": [\"log_cp10k\"],\n", - " \"output_dataset\": \"$id/dataset.anndata.zarr\",\n", - " \"output_state\": \"$id/state.yaml\",\n", + " \"output_raw\": \"$id/raw.anndata.zarr\",\n", + " \"output_state\": \"$id/load_state.yaml\",\n", "})" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Process\n", + "\n", + "The counts are normalised to log counts per 10,000 (log CP10k). We then select the 1000 most highly variable genes, compute a 50-dimensional PCA on those genes, and build a 15-nearest-neighbour graph on the PCA embedding." + ], + "id": "21501390" + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "output_dir = helpers.run_workflow(\"scrnaseq/process_scrnaseq\", {\n", + " \"id\": \"cxg_immune_cell_atlas\",\n", + " \"input\": str(output_dir / \"cxg_immune_cell_atlas\" / \"raw.anndata.zarr\"),\n", + " \"output_dataset\": \"$id/dataset.anndata.zarr\",\n", + " \"output_state\": \"$id/process_state.yaml\",\n", + "}, output_dir=output_dir)" ], "id": "59d861f0" }, diff --git a/scripts/create_test_resources/cxg_mouse_pancreas_atlas.ipynb b/scripts/create_test_resources/cxg_mouse_pancreas_atlas.ipynb index 8701c0d..25f4805 100644 --- a/scripts/create_test_resources/cxg_mouse_pancreas_atlas.ipynb +++ b/scripts/create_test_resources/cxg_mouse_pancreas_atlas.ipynb @@ -37,27 +37,16 @@ ], "id": "18351d38" }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Process\n", - "\n", - "The counts are normalised to log counts per 10,000 (log CP10k). We then select the 1000 most highly variable genes, compute a 50-dimensional PCA on those genes, and build a 15-nearest-neighbour graph on the PCA embedding.\n", - "\n", - "We keep the result of every step, so that each of them can be tested on its own." - ], - "id": "7e40b79b" - }, { "cell_type": "code", "execution_count": null, + "id": "9e0cc2ba", "metadata": {}, "outputs": [], "source": [ "steps = [\"raw\", \"normalized\", \"hvg\", \"pca\", \"dataset\"]\n", "\n", - "output_dir = helpers.run_workflow(\"scrnaseq/process_cellxgene_census\", {\n", + "output_dir = helpers.run_workflow(\"scrnaseq/load_cellxgene_census\", {\n", " \"id\": \"cxg_mouse_pancreas_atlas\",\n", " \"species\": \"mus_musculus\",\n", " \"census_version\": \"2023-07-25\",\n", @@ -73,10 +62,35 @@ " \"n_obs\": 600,\n", " \"n_vars\": 1500,\n", " \"seed\": 123,\n", - " \"normalization_methods\": [\"log_cp10k\"],\n", - " **{f\"output_{step}\": f\"$id/{step}.anndata.zarr\" for step in steps},\n", - " \"output_state\": \"$id/state.yaml\",\n", + " \"output_raw\": \"$id/raw.anndata.zarr\",\n", + " \"output_state\": \"$id/load_state.yaml\",\n", "})" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Process\n", + "\n", + "The counts are normalised to log counts per 10,000 (log CP10k). We then select the 1000 most highly variable genes, compute a 50-dimensional PCA on those genes, and build a 15-nearest-neighbour graph on the PCA embedding.\n", + "\n", + "We keep the result of every step, so that each of them can be tested on its own." + ], + "id": "7e40b79b" + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "output_dir = helpers.run_workflow(\"scrnaseq/process_scrnaseq\", {\n", + " \"id\": \"cxg_mouse_pancreas_atlas\",\n", + " \"input\": str(output_dir / \"cxg_mouse_pancreas_atlas\" / \"raw.anndata.zarr\"),\n", + " **{f\"output_{step}\": f\"$id/{step}.anndata.zarr\" for step in steps[1:]},\n", + " \"output_state\": \"$id/process_state.yaml\",\n", + "}, output_dir=output_dir)" ], "id": "81cb2eab" }, diff --git a/scripts/create_test_resources/helpers.py b/scripts/create_test_resources/helpers.py index 2101786..6229b09 100644 --- a/scripts/create_test_resources/helpers.py +++ b/scripts/create_test_resources/helpers.py @@ -46,14 +46,15 @@ def link_to_github(notebook): transform.save() -def run_workflow(workflow, params, highmem=None): +def run_workflow(workflow, params, highmem=None, output_dir=None): """Run a workflow of this repository, return the directory with its outputs. `highmem` overrides the memory of processes labelled `highmem` (e.g. "64.GB"), - for workflows that load large source files. + for workflows that load large source files. Pass the `output_dir` of a previous + run to publish into the same directory. """ - output_dir = Path(tempfile.mkdtemp()) - params_file = output_dir / "params.json" + output_dir = Path(output_dir or tempfile.mkdtemp()) + params_file = output_dir / f"params_{workflow.replace('/', '_')}.json" params_file.write_text(json.dumps({**params, "publish_dir": str(output_dir)})) configs = ["-c", "common/nextflow_helpers/labels_ci.config"] if highmem is not None: From 4d8351d003518f6d835ee1460f97cadaacc1056c Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Tue, 17 Nov 2026 20:19:52 +0100 Subject: [PATCH 05/14] update changelog --- CHANGELOG.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce0719c..d8b1347 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ * MINOR CHANGE: Bump Viash to 0.9.7. +* MAJOR CHANGE: Split the scRNA-seq workflows into loading and processing. `load_cellxgene_census` and `load_openproblems_op3` (optionally subsample and) write a raw dataset, and `process_scrnaseq` turns any raw dataset into a common dataset with a single normalisation (log CP10k). They replace `process_cellxgene_census` and `process_openproblems_op3`. + +* NEW FUNCTIONALITY: `validation/validate_dataset` checks a raw or common dataset against its format in `src/api`. The load and process workflows run it before publishing, so an invalid dataset fails the run. + +* MINOR CHANGE: `load_cellxgene_census` requires a dated Census release, since `latest` and `stable` give different datasets over time. + +* MINOR CHANGE: Pin BLAS, OpenMP and numba to 4 threads in every Docker image. The PCA (and with it the kNN graph) depended on the number of cores of the machine. + * MAJOR CHANGE: Raw scRNA-seq datasets must have CELLxGENE-style ontology term ids for the assay, cell type, developmental stage, disease, self-reported ethnicity, sex and tissue. The multimodal loaders use a new `file_multimodal_raw` spec, in which these stay optional. * MINOR CHANGE: The OP3 loader adds these ontology term ids, based on its cell type annotation and the donor metadata in GEO. From 1c224cb49a79b510ee5a02c6a94a11664660a57a Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Tue, 17 Nov 2026 20:26:53 +0100 Subject: [PATCH 06/14] update test resources --- _viash.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_viash.yaml b/_viash.yaml index b136e1a..ba6f228 100644 --- a/_viash.yaml +++ b/_viash.yaml @@ -32,6 +32,6 @@ repositories: info: test_resources: # created by scripts/create_test_resources/cxg_mouse_pancreas_atlas.ipynb - - path: lamin://openproblems/data-dev/collection/Ajn1Lo8zZomVzKtQ0001 + - path: lamin://openproblems/data-dev/collection/Ajn1Lo8zZomVzKtQ0002 dest: resources_test/common/cxg_mouse_pancreas_atlas strip_prefix: resources_test/datasets/cxg_mouse_pancreas_atlas/ From ee285d681f6f123998969d4f0b4268dead899a02 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Tue, 17 Nov 2026 20:32:58 +0100 Subject: [PATCH 07/14] ci force From c7836dea498c1a39a56f55997c5a9cbfc5830ff7 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Wed, 18 Nov 2026 14:14:24 +0100 Subject: [PATCH 08/14] update test resources --- _viash.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_viash.yaml b/_viash.yaml index ba6f228..b9677dc 100644 --- a/_viash.yaml +++ b/_viash.yaml @@ -32,6 +32,6 @@ repositories: info: test_resources: # created by scripts/create_test_resources/cxg_mouse_pancreas_atlas.ipynb - - path: lamin://openproblems/data-dev/collection/Ajn1Lo8zZomVzKtQ0002 + - path: lamin://openproblems/data-dev/collection/Ajn1Lo8zZomVzKtQ0003 dest: resources_test/common/cxg_mouse_pancreas_atlas strip_prefix: resources_test/datasets/cxg_mouse_pancreas_atlas/ From 3b34af3f82b83e3d98547a9bcd63824484c5ca8e Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Wed, 18 Nov 2026 14:14:24 +0100 Subject: [PATCH 09/14] ci force From 0058f47eba50c671ba174bcc488e93a9f61432f9 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Wed, 18 Nov 2026 15:25:17 +0100 Subject: [PATCH 10/14] store organism in obs of raw scrnaseq datasets --- src/api/file_raw.yaml | 9 ++----- .../scrnaseq/cellxgene_census/config.vsh.yaml | 9 ++----- .../scrnaseq/cellxgene_census/script.py | 24 ++++++++++++++++--- src/loaders/scrnaseq/cellxgene_census/test.py | 4 ++-- .../config.vsh.yaml | 5 ---- .../script.py | 19 +++++++++++++-- .../cellxgene_census_from_source_h5ad/test.py | 3 +-- .../scrnaseq/openproblems_op3/config.vsh.yaml | 6 ----- .../scrnaseq/openproblems_op3/script.py | 6 ++--- 9 files changed, 48 insertions(+), 37 deletions(-) diff --git a/src/api/file_raw.yaml b/src/api/file_raw.yaml index 3eccaa6..b1a0263 100644 --- a/src/api/file_raw.yaml +++ b/src/api/file_raw.yaml @@ -5,7 +5,7 @@ summary: An unprocessed dataset as output by a dataset loader. description: | This dataset contains raw counts and metadata as output by a dataset loader. - Cell metadata is annotated with ontology term ids, as in CELLxGENE: these are required for the assay, cell type, developmental stage, disease, self-reported ethnicity, sex and tissue. + Cell metadata is annotated with ontology term ids, as in CELLxGENE: these are required for the assay, cell type, developmental stage, disease, organism, self-reported ethnicity, sex and tissue. The organism is annotated per cell, so a dataset can contain cells from several organisms. The format of this file is derived from the [CELLxGENE schema v4.0.0](https://github.com/chanzuckerberg/single-cell-curation/blob/main/schema/4.0.0/schema.md). info: @@ -91,7 +91,7 @@ info: Ontology term identifier for the organism, providing a standardized reference for the organism. Must be a term from the NCBI Taxonomy Ontology (`NCBITaxon:`) which is a child of `NCBITaxon:33208`. - required: false + required: true - type: string name: self_reported_ethnicity @@ -201,11 +201,6 @@ info: type: string description: Long description of the dataset. required: true - - name: dataset_organism - type: string - description: The organism of the sample in the dataset. - required: false - multiple: true - name: dataset_technology type: string description: The technology used to generate the dataset. diff --git a/src/loaders/scrnaseq/cellxgene_census/config.vsh.yaml b/src/loaders/scrnaseq/cellxgene_census/config.vsh.yaml index 3a49142..dbcfce7 100644 --- a/src/loaders/scrnaseq/cellxgene_census/config.vsh.yaml +++ b/src/loaders/scrnaseq/cellxgene_census/config.vsh.yaml @@ -29,8 +29,8 @@ argument_groups: arguments: - name: --species type: string - description: The organism to query, usually one of `Homo sapiens` or `Mus - musculus`. + description: The organism to query, one of `homo_sapiens` or `mus_musculus`. + Also stored in `.obs["organism"]` and `.obs["organism_ontology_term_id"]`. required: true example: homo_sapiens - name: --obs_value_filter @@ -131,11 +131,6 @@ argument_groups: type: string description: Long description of the dataset. required: true - - name: --dataset_organism - type: string - multiple: true - description: The organism of the dataset. - required: true resources: - type: python_script path: script.py diff --git a/src/loaders/scrnaseq/cellxgene_census/script.py b/src/loaders/scrnaseq/cellxgene_census/script.py index f3c0f48..132dfe5 100644 --- a/src/loaders/scrnaseq/cellxgene_census/script.py +++ b/src/loaders/scrnaseq/cellxgene_census/script.py @@ -1,4 +1,5 @@ import cellxgene_census +import pandas as pd import scanpy as sc import logging @@ -20,11 +21,16 @@ "dataset_reference": "ref", "dataset_summary": "summ", "dataset_description": "desc", - "dataset_organism": "mus_musculus", "output": "output.zarr", } ## VIASH END +# organisms in the Census, with their NCBI Taxonomy term +CENSUS_ORGANISMS = { + "homo_sapiens": ("Homo sapiens", "NCBITaxon:9606"), + "mus_musculus": ("Mus musculus", "NCBITaxon:10090"), +} + def connect_census(uri, census_version): """ Connect to CellxGene Census or user-provided TileDBSoma object @@ -119,9 +125,18 @@ def add_batch_to_obs(adata, par): # store in adata adata.obs["batch"] = obs_batch +def add_organism_to_obs(adata, par): + logger.info("Add organism to obs.") + species = par["species"].lower().replace(" ", "_") + if species not in CENSUS_ORGANISMS: + raise ValueError(f"Unknown species '{par['species']}', expected one of {list(CENSUS_ORGANISMS)}") + label, term_id = CENSUS_ORGANISMS[species] + adata.obs["organism"] = pd.Categorical([label] * adata.n_obs) + adata.obs["organism_ontology_term_id"] = pd.Categorical([term_id] * adata.n_obs) + def add_metadata_to_uns(adata, par): logger.info("Add metadata to the AnnData object.") - for key in ["dataset_id", "dataset_name", "dataset_url", "dataset_reference", "dataset_summary", "dataset_description", "dataset_organism"]: + for key in ["dataset_id", "dataset_name", "dataset_url", "dataset_reference", "dataset_summary", "dataset_description"]: adata.uns[key] = par[key] def print_unique(adata, column): @@ -132,7 +147,7 @@ def print_summary(adata): logger.info(f"Resulting dataset: {adata}") logger.info("Summary of dataset:") - obs_fields = ["assay", "assay_ontology_term_id", "cell_type", "cell_type_ontology_term_id", "dataset_id", "development_stage", "development_stage_ontology_term_id", "disease", "disease_ontology_term_id", "tissue", "tissue_ontology_term_id", "tissue_general", "tissue_general_ontology_term_id"] + obs_fields = ["assay", "assay_ontology_term_id", "cell_type", "cell_type_ontology_term_id", "dataset_id", "development_stage", "development_stage_ontology_term_id", "disease", "disease_ontology_term_id", "organism", "organism_ontology_term_id", "tissue", "tissue_ontology_term_id", "tissue_general", "tissue_general_ontology_term_id"] for field in obs_fields: print_unique(adata, field) def write_anndata(adata, par): @@ -171,6 +186,9 @@ def main(par, meta): # add batch to obs add_batch_to_obs(adata, par) + # add organism to obs + add_organism_to_obs(adata, par) + # add metadata to uns add_metadata_to_uns(adata, par) diff --git a/src/loaders/scrnaseq/cellxgene_census/test.py b/src/loaders/scrnaseq/cellxgene_census/test.py index 10af062..de73a7d 100644 --- a/src/loaders/scrnaseq/cellxgene_census/test.py +++ b/src/loaders/scrnaseq/cellxgene_census/test.py @@ -26,7 +26,6 @@ def test_cellxgene_extract_metadata_expression(run_component, tmp_path): "--dataset_reference", "test_dataset_reference", "--dataset_summary", "test_dataset_summary", "--dataset_description", "test_dataset_description", - "--dataset_organism", "test_homo_sapiens", ]) # check whether file exists @@ -40,6 +39,8 @@ def test_cellxgene_extract_metadata_expression(run_component, tmp_path): assert np.all(adata.obs["is_primary_data"] == True) assert "cell_type_ontology_term_id" in adata.obs.columns assert "disease" in adata.obs.columns + assert list(adata.obs["organism"].unique()) == ["Homo sapiens"] + assert list(adata.obs["organism_ontology_term_id"].unique()) == ["NCBITaxon:9606"] assert adata.n_obs > 10 assert np.all([x in ["male+male", "female+female"] for x in adata.obs["batch"]]) @@ -54,7 +55,6 @@ def test_cellxgene_extract_metadata_expression(run_component, tmp_path): assert list(adata.uns["dataset_reference"]) == ["test_dataset_reference"], "Incorrect .uns['dataset_reference']" assert adata.uns["dataset_summary"] == "test_dataset_summary", "Incorrect .uns['dataset_summary']" assert adata.uns["dataset_description"] == "test_dataset_description", "Incorrect .uns['dataset_description']" - assert list(adata.uns["dataset_organism"]) == ["test_homo_sapiens"], "Incorrect .uns['dataset_organism']" if __name__ == '__main__': diff --git a/src/loaders/scrnaseq/cellxgene_census_from_source_h5ad/config.vsh.yaml b/src/loaders/scrnaseq/cellxgene_census_from_source_h5ad/config.vsh.yaml index 8d7b13f..ef9bdc3 100644 --- a/src/loaders/scrnaseq/cellxgene_census_from_source_h5ad/config.vsh.yaml +++ b/src/loaders/scrnaseq/cellxgene_census_from_source_h5ad/config.vsh.yaml @@ -88,11 +88,6 @@ argument_groups: type: string description: Long description of the dataset. required: true - - name: --dataset_organism - type: string - multiple: true - description: The organism of the dataset. - required: true resources: - type: python_script path: script.py diff --git a/src/loaders/scrnaseq/cellxgene_census_from_source_h5ad/script.py b/src/loaders/scrnaseq/cellxgene_census_from_source_h5ad/script.py index e949762..e142de1 100644 --- a/src/loaders/scrnaseq/cellxgene_census_from_source_h5ad/script.py +++ b/src/loaders/scrnaseq/cellxgene_census_from_source_h5ad/script.py @@ -1,4 +1,5 @@ import cellxgene_census +import pandas as pd import scanpy as sc import tempfile import logging @@ -16,7 +17,6 @@ "dataset_reference": "ref", "dataset_summary": "summ", "dataset_description": "desc", - "dataset_organism": "mus_musculus", "output": "output.zarr", } ## VIASH END @@ -60,9 +60,19 @@ def add_batch_to_obs(adata, par): # store in adata adata.obs["batch"] = obs_batch +def add_organism_to_obs(adata): + # CELLxGENE schema >= 6.0.0 stores the organism in uns instead of obs + for key in ["organism", "organism_ontology_term_id"]: + if key in adata.obs.columns: + continue + if key not in adata.uns: + raise ValueError(f"Source h5ad has no '{key}' in .obs or .uns") + logger.info("Copy .uns['%s'] to .obs", key) + adata.obs[key] = pd.Categorical([adata.uns.pop(key)] * adata.n_obs) + def add_metadata_to_uns(adata, par): logger.info("Add metadata to the AnnData object.") - for key in ["dataset_id", "dataset_name", "dataset_url", "dataset_reference", "dataset_summary", "dataset_description", "dataset_organism"]: + for key in ["dataset_id", "dataset_name", "dataset_url", "dataset_reference", "dataset_summary", "dataset_description"]: adata.uns[key] = par[key] def print_unique(adata, column): @@ -85,6 +95,8 @@ def print_summary(adata): print_unique(adata, "development_stage_ontology_term_id") print_unique(adata, "disease") print_unique(adata, "disease_ontology_term_id") + print_unique(adata, "organism") + print_unique(adata, "organism_ontology_term_id") print_unique(adata, "tissue") print_unique(adata, "tissue_ontology_term_id") print_unique(adata, "tissue_general") @@ -113,6 +125,9 @@ def main(par, meta): # add batch to obs add_batch_to_obs(adata, par) + # add organism to obs + add_organism_to_obs(adata) + # add metadata to uns add_metadata_to_uns(adata, par) diff --git a/src/loaders/scrnaseq/cellxgene_census_from_source_h5ad/test.py b/src/loaders/scrnaseq/cellxgene_census_from_source_h5ad/test.py index 120c7e2..4343599 100644 --- a/src/loaders/scrnaseq/cellxgene_census_from_source_h5ad/test.py +++ b/src/loaders/scrnaseq/cellxgene_census_from_source_h5ad/test.py @@ -25,7 +25,6 @@ def test_cellxgene_extract_metadata_expression(run_component, tmp_path): "--dataset_reference", "test_dataset_reference", "--dataset_summary", "test_dataset_summary", "--dataset_description", "test_dataset_description", - "--dataset_organism", "test_homo_sapiens", ]) # check whether file exists @@ -38,6 +37,7 @@ def test_cellxgene_extract_metadata_expression(run_component, tmp_path): assert "is_primary_data" in adata.obs.columns assert "cell_type_ontology_term_id" in adata.obs.columns assert "disease" in adata.obs.columns + assert list(adata.obs["organism_ontology_term_id"].unique()) == ["NCBITaxon:9606"] assert adata.n_obs > 10 assert np.all([x in ["C41", "C58", "C70", "C72"] for x in adata.obs["batch"]]) @@ -51,7 +51,6 @@ def test_cellxgene_extract_metadata_expression(run_component, tmp_path): assert list(adata.uns["dataset_reference"]) == ["test_dataset_reference"], "Incorrect .uns['dataset_reference']" assert adata.uns["dataset_summary"] == "test_dataset_summary", "Incorrect .uns['dataset_summary']" assert adata.uns["dataset_description"] == "test_dataset_description", "Incorrect .uns['dataset_description']" - assert list(adata.uns["dataset_organism"]) == ["test_homo_sapiens"], "Incorrect .uns['dataset_organism']" if __name__ == '__main__': diff --git a/src/loaders/scrnaseq/openproblems_op3/config.vsh.yaml b/src/loaders/scrnaseq/openproblems_op3/config.vsh.yaml index 844b2f3..6d38561 100644 --- a/src/loaders/scrnaseq/openproblems_op3/config.vsh.yaml +++ b/src/loaders/scrnaseq/openproblems_op3/config.vsh.yaml @@ -59,12 +59,6 @@ argument_groups: description: "Bibtex reference of the paper in which the dataset was published." required: false default: [GSE279945] - - name: "--dataset_organism" - type: string - multiple: true - description: "The organism of the dataset." - required: false - default: [homo_sapiens] - name: "--dataset_url" type: string description: "Link to the original source of the dataset." diff --git a/src/loaders/scrnaseq/openproblems_op3/script.py b/src/loaders/scrnaseq/openproblems_op3/script.py index eb4c77a..1ecb281 100644 --- a/src/loaders/scrnaseq/openproblems_op3/script.py +++ b/src/loaders/scrnaseq/openproblems_op3/script.py @@ -18,7 +18,6 @@ "dataset_summary": "The Open Problems Perurbation Prediction (OP3) dataset with small molecule perturbations in PBMCs", "dataset_description": "The OP3 dataset is to-date the largest single-cell small molecule perturbation dataset in primary tissue with multiple donor replicates.", "dataset_reference": ["GSE279945"], - "dataset_organism": ["homo_sapiens"], "output": "output.zarr", } meta = {} @@ -122,6 +121,7 @@ def fix_splits(adata): "assay_ontology_term_id": "EFO:0009922", # 10x 3' v3 "tissue_ontology_term_id": "UBERON:0000178", # blood "disease_ontology_term_id": "PATO:0000461", # normal + "organism_ontology_term_id": "NCBITaxon:9606", # Homo sapiens "self_reported_ethnicity_ontology_term_id": "HANCESTRO:0005", # European ancestry, "caucasian" in GEO } @@ -133,7 +133,8 @@ def add_ontology_term_ids(adata): obs[column] = obs["donor_id"].map({donor: terms[column] for donor, terms in DONOR_ONTOLOGY.items()}) for column, term in SAMPLE_ONTOLOGY.items(): obs[column] = term - columns = ["cell_type_ontology_term_id", *DONOR_ONTOLOGY["Donor 1"], *SAMPLE_ONTOLOGY] + obs["organism"] = "Homo sapiens" + columns = ["cell_type_ontology_term_id", *DONOR_ONTOLOGY["Donor 1"], *SAMPLE_ONTOLOGY, "organism"] for column in columns: if obs[column].isna().any(): raise ValueError(f"Missing ontology term ids in obs['{column}']") @@ -153,7 +154,6 @@ def add_metadata_to_uns(adata, par): adata.uns['dataset_name'] = par["dataset_name"] adata.uns['dataset_summary'] = par["dataset_summary"] adata.uns['dataset_description'] = par["dataset_description"] - adata.uns['dataset_organism'] = par["dataset_organism"] adata.uns['dataset_url'] = par["dataset_url"] adata.uns['dataset_reference'] = par["dataset_reference"] adata.uns['dataset_version'] = '1.0.0' From 972b311d5079e18dd396d5fee9d20fce0ddfe152 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Wed, 18 Nov 2026 15:25:17 +0100 Subject: [PATCH 11/14] drop dataset_organism from census workflow and scripts --- scripts/create_resources/cellxgene_census.sh | 10 ---------- .../create_test_resources/cxg_immune_cell_atlas.ipynb | 1 - .../cxg_mouse_pancreas_atlas.ipynb | 1 - .../scrnaseq/load_cellxgene_census/config.vsh.yaml | 8 +------- src/workflows/scrnaseq/load_cellxgene_census/main.nf | 1 - 5 files changed, 1 insertion(+), 20 deletions(-) diff --git a/scripts/create_resources/cellxgene_census.sh b/scripts/create_resources/cellxgene_census.sh index 89687a5..ea9dbb5 100755 --- a/scripts/create_resources/cellxgene_census.sh +++ b/scripts/create_resources/cellxgene_census.sh @@ -11,7 +11,6 @@ # dataset_description: # dataset_url: # dataset_reference: -# dataset_organism: # not sure which dataset ids to use # - id: cellxgene_census/human_brain_atlas @@ -24,7 +23,6 @@ # dataset_description: Delineating the gene regulatory programs underlying complex cell types is fundamental for understanding brain functions in health and disease. Here, we comprehensively examine human brain cell epigenomes by probing DNA methylation and chromatin conformation at single-cell resolution in over 500,000 cells from 46 brain regions. We identified 188 cell types and characterized their molecular signatures. Integrative analyses revealed concordant changes in DNA methylation, chromatin accessibility, chromatin organization, and gene expression across cell types, cortical areas, and basal ganglia structures. With these resources, we developed scMCodes that reliably predict brain cell types using their methylation status at select genomic sites. This multimodal epigenomic brain cell atlas provides new insights into the complexity of cell type-specific gene regulation in the adult human brain. # dataset_url: https://cellxgene.cziscience.com/collections/fdebfda9-bb9a-4b4b-97e5-651097ea07b0 # dataset_reference: tian2023singlecell -# dataset_organism: homo_sapiens cat > "/tmp/params.yaml" << 'HERE' param_list: @@ -38,7 +36,6 @@ param_list: dataset_description: To better understand pancreatic β-cell heterogeneity we generated a mouse pancreatic islet atlas capturing a wide range of biological conditions. The atlas contains scRNA-seq datasets of over 300,000 mouse pancreatic islet cells, of which more than 100,000 are β-cells, from nine datasets with 56 samples, including two previously unpublished datasets. The samples vary in sex, age (ranging from embryonic to aged), chemical stress, and disease status (including T1D NOD model development and two T2D models, mSTZ and db/db) together with different diabetes treatments. Additional information about data fields is available in anndata uns field 'field_descriptions' and on https://github.com/theislab/mm_pancreas_atlas_rep/blob/main/resources/cellxgene.md. dataset_url: https://cellxgene.cziscience.com/collections/296237e2-393d-4e31-b590-b03f74ac5070 dataset_reference: hrovatin2023delineating - dataset_organism: mus_musculus - id: cellxgene_census/hlca species: homo_sapiens census_version: "2023-07-25" @@ -49,7 +46,6 @@ param_list: dataset_description: The integrated Human Lung Cell Atlas (HLCA) represents the first large-scale, integrated single-cell reference atlas of the human lung. It consists of over 2 million cells from the respiratory tract of 486 individuals, and includes 49 different datasets. It is split into the HLCA core, and the extended or full HLCA. The HLCA core includes data of healthy lung tissue from 107 individuals, and includes manual cell type annotations based on consensus across 6 independent experts, as well as demographic, biological and technical metadata. dataset_url: https://cellxgene.cziscience.com/collections/6f6d381a-7701-4781-935c-db10d30de293 dataset_reference: sikkema2023integrated - dataset_organism: homo_sapiens - id: cellxgene_census/tabula_sapiens species: homo_sapiens census_version: "2023-07-25" @@ -60,7 +56,6 @@ param_list: dataset_description: Tabula Sapiens is a benchmark, first-draft human cell atlas of nearly 500,000 cells from 24 organs of 15 normal human subjects. This work is the product of the Tabula Sapiens Consortium. Taking the organs from the same individual controls for genetic background, age, environment, and epigenetic effects and allows detailed analysis and comparison of cell types that are shared between tissues. Our work creates a detailed portrait of cell types as well as their distribution and variation in gene expression across tissues and within the endothelial, epithelial, stromal and immune compartments. dataset_url: https://cellxgene.cziscience.com/collections/e5f58829-1a66-40b5-a624-9046778e74f5 dataset_reference: consortium2022tabula - dataset_organism: homo_sapiens - id: cellxgene_census/immune_cell_atlas species: homo_sapiens census_version: "2023-07-25" @@ -71,7 +66,6 @@ param_list: dataset_description: Despite their crucial role in health and disease, our knowledge of immune cells within human tissues remains limited. We surveyed the immune compartment of 16 tissues from 12 adult donors by single-cell RNA sequencing and VDJ sequencing generating a dataset of ~360,000 cells. To systematically resolve immune cell heterogeneity across tissues, we developed CellTypist, a machine learning tool for rapid and precise cell type annotation. Using this approach, combined with detailed curation, we determined the tissue distribution of finely phenotyped immune cell types, revealing hitherto unappreciated tissue-specific features and clonal architecture of T and B cells. Our multitissue approach lays the foundation for identifying highly resolved immune cell types by leveraging a common reference dataset, tissue-integrated expression analysis, and antigen receptor sequencing. dataset_url: https://cellxgene.cziscience.com/collections/62ef75e4-cbea-454e-a0ce-998ec40223d3 dataset_reference: dominguez2022crosstissue - dataset_organism: homo_sapiens - id: cellxgene_census/gtex_v9 species: homo_sapiens census_version: "2023-07-25" @@ -82,7 +76,6 @@ param_list: dataset_description: Understanding the function of genes and their regulation in tissue homeostasis and disease requires knowing the cellular context in which genes are expressed in tissues across the body. Single cell genomics allows the generation of detailed cellular atlases in human tissues, but most efforts are focused on single tissue types. Here, we establish a framework for profiling multiple tissues across the human body at single-cell resolution using single nucleus RNA-Seq (snRNA-seq), and apply it to 8 diverse, archived, frozen tissue types (three donors per tissue). We apply four snRNA-seq methods to each of 25 samples from 16 donors, generating a cross-tissue atlas of 209,126 nuclei profiles, and benchmark them vs. scRNA-seq of comparable fresh tissues. We use a conditional variational autoencoder (cVAE) to integrate an atlas across tissues, donors, and laboratory methods. We highlight shared and tissue-specific features of tissue-resident immune cells, identifying tissue-restricted and non-restricted resident myeloid populations. These include a cross-tissue conserved dichotomy between LYVE1- and HLA class II-expressing macrophages, and the broad presence of LAM-like macrophages across healthy tissues that is also observed in disease. For rare, monogenic muscle diseases, we identify cell types that likely underlie the neuromuscular, metabolic, and immune components of these diseases, and biological processes involved in their pathology. For common complex diseases and traits analyzed by GWAS, we identify the cell types and gene modules that potentially underlie disease mechanisms. The experimental and analytical frameworks we describe will enable the generation of large-scale studies of how cellular and molecular processes vary across individuals and populations. dataset_url: https://cellxgene.cziscience.com/collections/a3ffde6c-7ad2-498a-903c-d58e732f7470 dataset_reference: eraslan2022singlenucleus - dataset_organism: homo_sapiens - id: cellxgene_census/human_retina_cell_atlas species: homo_sapiens census_version: "2023-07-25" @@ -93,7 +86,6 @@ param_list: dataset_description: As the light sensing part of the visual system, the human retina is composed of five classes of neuron, including photoreceptors, horizontal cells, amacrine, bipolar, and retinal ganglion cells. Each class of neuron can be further classified into subgroups with the abundance varying three orders of magnitude. Therefore, to capture all cell types in the retina and generate a complete single cell reference atlas, it is essential to scale up from currently published single cell profiling studies to improve the sensitivity. In addition, to gain a better understanding of gene regulation at single cell level, it is important to include sufficient scATAC-seq data in the reference. To fill the gap, we performed snRNA-seq and snATAC-seq for the retina from healthy donors. To further increase the size of the dataset, we then collected and incorporated publicly available datasets. All data underwent a unified preprocessing pipeline and data integration. Multiple integration methods were benchmarked by scIB, and scVI was chosen. To harness the power of multiomics, snATAC-seq datasets were also preprocessed, and scGlue was used to generate co-embeddings between snRNA-seq and snATAC-seq cells. To facilitate the public use of references, we employ CELLxGENE and UCSC Cell Browser for visualization. By combining previously published and newly generated datasets, a single cell atlas of the human retina that is composed of 2.5 million single cells from 48 donors has been generated. As a result, over 90 distinct cell types are identified based on the transcriptomics profile with the rarest cell type accounting for about 0.01% of the cell population. In addition, open chromatin profiling has been generated for over 400K nuclei via single nuclei ATAC-seq, allowing systematic characterization of cis-regulatory elements for individual cell type. Integrative analysis reveals intriguing differences in the transcriptome, chromatin landscape, and gene regulatory network among cell class, subgroup, and type. In addition, changes in cell proportion, gene expression and chromatin openness have been observed between different gender and over age. Accessible through interactive browsers, this study represents the most comprehensive reference cell atlas of the human retina to date. As part of the human cell atlas project, this resource lays the foundation for further research in understanding retina biology and diseases. dataset_url: https://cellxgene.cziscience.com/collections/4c6eaf5c-6d57-4c76-b1e9-60df8c655f1e dataset_reference: li2023integrated - dataset_organism: homo_sapiens - id: cellxgene_census/dkd species: homo_sapiens census_version: "2023-07-25" @@ -104,7 +96,6 @@ param_list: dataset_description: Multimodal single cell sequencing is a powerful tool for interrogating cell-specific changes in transcription and chromatin accessibility. We performed single nucleus RNA (snRNA-seq) and assay for transposase accessible chromatin sequencing (snATAC-seq) on human kidney cortex from donors with and without diabetic kidney disease (DKD) to identify altered signaling pathways and transcription factors associated with DKD. Both snRNA-seq and snATAC-seq had an increased proportion of VCAM1+ injured proximal tubule cells (PT_VCAM1) in DKD samples. PT_VCAM1 has a pro-inflammatory expression signature and transcription factor motif enrichment implicated NFkB signaling. We used stratified linkage disequilibrium score regression to partition heritability of kidney-function-related traits using publicly-available GWAS summary statistics. Cell-specific PT_VCAM1 peaks were enriched for heritability of chronic kidney disease (CKD), suggesting that genetic background may regulate chromatin accessibility and DKD progression. snATAC-seq found cell-specific differentially accessible regions (DAR) throughout the nephron that change accessibility in DKD and these regions were enriched for glucocorticoid receptor (GR) motifs. Changes in chromatin accessibility were associated with decreased expression of insulin receptor, increased gluconeogenesis, and decreased expression of the GR cytosolic chaperone, FKBP5, in the diabetic proximal tubule. Cleavage under targets and release using nuclease (CUT&RUN) profiling of GR binding in bulk kidney cortex and an in vitro model of the proximal tubule (RPTEC) showed that DAR co-localize with GR binding sites. CRISPRi silencing of GR response elements (GRE) in the FKBP5 gene body reduced FKBP5 expression in RPTEC, suggesting that reduced FKBP5 chromatin accessibility in DKD may alter cellular response to GR. We developed an open-source tool for single cell allele specific analysis (SALSA) to model the effect of genetic background on gene expression. Heterozygous germline single nucleotide variants (SNV) in proximal tubule ATAC peaks were associated with allele-specific chromatin accessibility and differential expression of target genes within cis-coaccessibility networks. Partitioned heritability of proximal tubule ATAC peaks with a predicted allele-specific effect was enriched for eGFR, suggesting that genetic background may modify DKD progression in a cell-specific manner. dataset_url: https://cellxgene.cziscience.com/collections/b3e2c6e3-9b05-4da9-8f42-da38a664b45b dataset_reference: wilson2022multimodal - dataset_organism: homo_sapiens - id: cellxgene_census/hypomap species: mus_musculus census_version: "2023-07-25" @@ -115,7 +106,6 @@ param_list: dataset_description: The hypothalamus plays a key role in coordinating fundamental body functions. Despite recent progress in single-cell technologies, a unified catalogue and molecular characterization of the heterogeneous cell types and, specifically, neuronal subtypes in this brain region are still lacking. Here we present an integrated reference atlas “HypoMap” of the murine hypothalamus consisting of 384,925 cells, with the ability to incorporate new additional experiments. We validate HypoMap by comparing data collected from SmartSeq2 and bulk RNA sequencing of selected neuronal cell types with different degrees of cellular heterogeneity. dataset_url: https://cellxgene.cziscience.com/collections/d86517f0-fa7e-4266-b82e-a521350d6d36 dataset_reference: steuernagel2022hypomap - dataset_organism: mus_musculus output_raw: '$id/raw.anndata.zarr' output_state: '$id/state.yaml' diff --git a/scripts/create_test_resources/cxg_immune_cell_atlas.ipynb b/scripts/create_test_resources/cxg_immune_cell_atlas.ipynb index 09d0ce4..371e5e4 100644 --- a/scripts/create_test_resources/cxg_immune_cell_atlas.ipynb +++ b/scripts/create_test_resources/cxg_immune_cell_atlas.ipynb @@ -55,7 +55,6 @@ " \"dataset_description\": \"Despite their crucial role in health and disease, our knowledge of immune cells within human tissues remains limited. We surveyed the immune compartment of 16 tissues from 12 adult donors by single-cell RNA sequencing and VDJ sequencing generating a dataset of ~360,000 cells. To systematically resolve immune cell heterogeneity across tissues, we developed CellTypist, a machine learning tool for rapid and precise cell type annotation. Using this approach, combined with detailed curation, we determined the tissue distribution of finely phenotyped immune cell types, revealing hitherto unappreciated tissue-specific features and clonal architecture of T and B cells. Our multitissue approach lays the foundation for identifying highly resolved immune cell types by leveraging a common reference dataset, tissue-integrated expression analysis, and antigen receptor sequencing.\",\n", " \"dataset_url\": \"https://cellxgene.cziscience.com/collections/62ef75e4-cbea-454e-a0ce-998ec40223d3\",\n", " \"dataset_reference\": \"dominguez2022crosstissue\",\n", - " \"dataset_organism\": \"homo_sapiens\",\n", " \"do_subsample\": True,\n", " \"n_obs\": 600,\n", " \"n_vars\": 1500,\n", diff --git a/scripts/create_test_resources/cxg_mouse_pancreas_atlas.ipynb b/scripts/create_test_resources/cxg_mouse_pancreas_atlas.ipynb index 25f4805..038cff3 100644 --- a/scripts/create_test_resources/cxg_mouse_pancreas_atlas.ipynb +++ b/scripts/create_test_resources/cxg_mouse_pancreas_atlas.ipynb @@ -57,7 +57,6 @@ " \"dataset_description\": \"To better understand pancreatic β-cell heterogeneity we generated a mouse pancreatic islet atlas capturing a wide range of biological conditions. The atlas contains scRNA-seq datasets of over 300,000 mouse pancreatic islet cells, of which more than 100,000 are β-cells, from nine datasets with 56 samples, including two previously unpublished datasets. The samples vary in sex, age (ranging from embryonic to aged), chemical stress, and disease status (including T1D NOD model development and two T2D models, mSTZ and db/db) together with different diabetes treatments. Additional information about data fields is available in anndata uns field 'field_descriptions' and on https://github.com/theislab/mm_pancreas_atlas_rep/blob/main/resources/cellxgene.md.\",\n", " \"dataset_url\": \"https://cellxgene.cziscience.com/collections/296237e2-393d-4e31-b590-b03f74ac5070\",\n", " \"dataset_reference\": \"hrovatin2023delineating\",\n", - " \"dataset_organism\": \"mus_musculus\",\n", " \"do_subsample\": True,\n", " \"n_obs\": 600,\n", " \"n_vars\": 1500,\n", diff --git a/src/workflows/scrnaseq/load_cellxgene_census/config.vsh.yaml b/src/workflows/scrnaseq/load_cellxgene_census/config.vsh.yaml index 3a4d9ac..d4b22d5 100644 --- a/src/workflows/scrnaseq/load_cellxgene_census/config.vsh.yaml +++ b/src/workflows/scrnaseq/load_cellxgene_census/config.vsh.yaml @@ -26,8 +26,7 @@ argument_groups: arguments: - name: --species type: string - description: The organism to query, usually one of `Homo sapiens` or `Mus - musculus`. + description: The organism to query, one of `homo_sapiens` or `mus_musculus`. required: false default: homo_sapiens multiple: false @@ -106,11 +105,6 @@ argument_groups: type: string description: Long description of the dataset. required: true - - name: --dataset_organism - type: string - multiple: true - description: The organism of the dataset. - required: true - __merge__: /src/workflows/scrnaseq/arguments_subsample.yaml - name: Outputs arguments: diff --git a/src/workflows/scrnaseq/load_cellxgene_census/main.nf b/src/workflows/scrnaseq/load_cellxgene_census/main.nf index ab3e866..0cda35b 100644 --- a/src/workflows/scrnaseq/load_cellxgene_census/main.nf +++ b/src/workflows/scrnaseq/load_cellxgene_census/main.nf @@ -37,7 +37,6 @@ workflow run_wf { "dataset_reference": "dataset_reference", "dataset_summary": "dataset_summary", "dataset_description": "dataset_description", - "dataset_organism": "dataset_organism", ], toState: ["output_raw": "output"] ) From 2016acfc21f63dc5f4dbc3e010f6390a884fc057 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Wed, 18 Nov 2026 15:25:17 +0100 Subject: [PATCH 12/14] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index af14fa1..ab714d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ * MAJOR CHANGE: Raw scRNA-seq datasets must have CELLxGENE-style ontology term ids for the assay, cell type, developmental stage, disease, self-reported ethnicity, sex and tissue. The multimodal loaders use a new `file_multimodal_raw` spec, in which these stay optional. +* MAJOR CHANGE: Raw scRNA-seq datasets store the organism per cell in `obs['organism_ontology_term_id']` (required, NCBI Taxonomy) and `obs['organism']`, instead of `uns['dataset_organism']`. The CELLxGENE Census loaders fill it in from `--species` or the source h5ad, and the OP3 loader sets `NCBITaxon:9606`. Multimodal and spatial datasets still use `uns['dataset_organism']`. + * BUG FIX: The loaders store `uns['dataset_reference']` and `uns['dataset_organism']` as lists, as declared in `src/api`, since a dataset can have several references and organisms. The OP3 loader takes both as arguments instead of hardcoding them. * BUG FIX: `uns['pca_variance']` is declared as an `object` in `file_pca`, since `processors/pca` writes a dict. From 5b6a0eb78ef7de09408d6fafedfc937cc0bffc31 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Wed, 18 Nov 2026 16:02:24 +0100 Subject: [PATCH 13/14] update test resources --- _viash.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_viash.yaml b/_viash.yaml index b9677dc..28e1ccd 100644 --- a/_viash.yaml +++ b/_viash.yaml @@ -32,6 +32,6 @@ repositories: info: test_resources: # created by scripts/create_test_resources/cxg_mouse_pancreas_atlas.ipynb - - path: lamin://openproblems/data-dev/collection/Ajn1Lo8zZomVzKtQ0003 + - path: lamin://openproblems/data-dev/collection/Ajn1Lo8zZomVzKtQ0004 dest: resources_test/common/cxg_mouse_pancreas_atlas strip_prefix: resources_test/datasets/cxg_mouse_pancreas_atlas/ From 4f8ea5c63171b1817da53348569b33c7658af7a2 Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Wed, 18 Nov 2026 16:02:24 +0100 Subject: [PATCH 14/14] ci force