From 98c8d0b590f158c4407dd6cfb85f3d197546ad5f Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 20 Sep 2024 10:32:12 +0200 Subject: [PATCH 1/3] experimental openproblems interface --- src/dimred/openproblems_dr/config.vsh.yaml | 100 ++++++++++++++++++ src/dimred/openproblems_dr/main.nf | 62 +++++++++++ .../config.vsh.yaml | 70 ++++++++++++ .../openproblems_dr_h5ad_to_h5mu/script.py | 37 +++++++ .../config.vsh.yaml | 65 ++++++++++++ .../openproblems_dr_h5mu_to_h5ad/script.py | 21 ++++ 6 files changed, 355 insertions(+) create mode 100644 src/dimred/openproblems_dr/config.vsh.yaml create mode 100644 src/dimred/openproblems_dr/main.nf create mode 100644 src/dimred/openproblems_dr_h5ad_to_h5mu/config.vsh.yaml create mode 100644 src/dimred/openproblems_dr_h5ad_to_h5mu/script.py create mode 100644 src/dimred/openproblems_dr_h5mu_to_h5ad/config.vsh.yaml create mode 100644 src/dimred/openproblems_dr_h5mu_to_h5ad/script.py diff --git a/src/dimred/openproblems_dr/config.vsh.yaml b/src/dimred/openproblems_dr/config.vsh.yaml new file mode 100644 index 00000000000..a47f335dd5d --- /dev/null +++ b/src/dimred/openproblems_dr/config.vsh.yaml @@ -0,0 +1,100 @@ +name: "openproblems_dr" +namespace: "dimred" +argument_groups: + - name: "Inputs" + arguments: + - name: "--input" + required: true + type: file + description: Path to the sample. + example: dataset.h5mu + + - name: "--input_modality" + type: string + default: "rna" + required: false + + - name: "--input_layer_counts" + type: string + description: In which layer to find the raw counts. If not provided, the raw counts are assumed to be in the .X object. + required: false + + - name: "--input_layer_normalized" + type: string + description: In which layer to find the log normalized counts. If not provided, the raw counts are assumed to be in the .X object. + required: false + default: "log_normalized" + + - name: "--input_var_hvg_score" + type: string + description: In which layer to find the HVG scores. If not provided, the HVG scores are assumed to be in the .var object. + required: false + default: "hvg_score" + - name: Method settings + arguments: + - name: "--method_id" + description: ID of the method to use. + type: string + required: false + choices: [ + densmap, + diffusion_map, + ivis, + lmds, + neuralee, + pca, + phate, + pymde, + simlr, + tsne, + umap + ] + - name: "Outputs" + arguments: + - name: "--output" + type: file + required: true + direction: output + description: Destination path to the output. + example: output.h5mu + + - name: "--output_obsm_key" + description: Key in the .obsm object to use as input. + type: string + required: false +dependencies: + - name: dimred/openproblems_dr_h5mu_to_h5ad + - name: dimred/openproblems_dr_h5ad_to_h5mu + - name: methods/densmap + repository: openproblems_task_dimensionality_reduction + - name: methods/diffusion_map + repository: openproblems_task_dimensionality_reduction + - name: methods/ivis + repository: openproblems_task_dimensionality_reduction + - name: methods/lmds + repository: openproblems_task_dimensionality_reduction + - name: methods/neuralee + repository: openproblems_task_dimensionality_reduction + - name: methods/pca + repository: openproblems_task_dimensionality_reduction + - name: methods/phate + repository: openproblems_task_dimensionality_reduction + - name: methods/pymde + repository: openproblems_task_dimensionality_reduction + - name: methods/simlr + repository: openproblems_task_dimensionality_reduction + - name: methods/tsne + repository: openproblems_task_dimensionality_reduction + - name: methods/umap + repository: openproblems_task_dimensionality_reduction +repositories: + - type: github + name: openproblems_task_dimensionality_reduction + repo: openproblems-bio/task_dimensionality_reduction + tag: build/main +resources: + - type: nextflow_script + path: main.nf + entrypoint: run_wf +runners: + - type: nextflow \ No newline at end of file diff --git a/src/dimred/openproblems_dr/main.nf b/src/dimred/openproblems_dr/main.nf new file mode 100644 index 00000000000..d977e35f082 --- /dev/null +++ b/src/dimred/openproblems_dr/main.nf @@ -0,0 +1,62 @@ +methods = [ + densmap, + diffusion_map, + ivis, + lmds, + neuralee, + pca, + phate, + pymde, + simlr, + tsne, + umap +] + +workflow run_wf { + take: + input_ch + + main: + output_ch = input_ch + + | openproblems_dr_h5mu_to_h5ad.run( + fromState: [ + "input", + "input_modality", + "input_layer_counts", + "input_layer_normalized", + "input_var_hvg_score" + ], + toState: [ + "method_input": "output" + ] + ) + + | runEach( + components: methods, + runIf: { id, state, comp -> + state.method_id == comp.config.name + }, + fromState: [ + "input": "method_input" + ], + toState: [ + "method_output": "output" + ] + ) + + | openproblems_dr_h5ad_to_h5mu.run( + fromState: [ + "input_dataset": "input", + "input_output": "method_output", + "input_modality": "input_modality", + "output_obsm_key": "output_obsm_key", + ], + toState: [ + "output": "output" + ] + ) + + emit: + output_ch +} diff --git a/src/dimred/openproblems_dr_h5ad_to_h5mu/config.vsh.yaml b/src/dimred/openproblems_dr_h5ad_to_h5mu/config.vsh.yaml new file mode 100644 index 00000000000..28fb7c70b4d --- /dev/null +++ b/src/dimred/openproblems_dr_h5ad_to_h5mu/config.vsh.yaml @@ -0,0 +1,70 @@ +name: openproblems_dr_h5ad_to_h5mu +namespace: "dimred" + +argument_groups: + - name: Inputs + arguments: + - name: "--input" + type: file + description: Input h5mu file + direction: input + required: true + example: input.h5mu + + - name: "--input_modality" + type: string + default: "rna" + required: false + + - name: "--input_layer_counts" + type: string + description: In which layer to find the raw counts. If not provided, the raw counts are assumed to be in the .X object. + required: false + + - name: "--input_layer_normalized" + type: string + description: In which layer to find the log normalized counts. If not provided, the raw counts are assumed to be in the .X object. + required: false + default: "log_normalized" + + - name: "--input_var_hvg_score" + type: string + description: In which layer to find the HVG scores. If not provided, the HVG scores are assumed to be in the .var object. + required: false + default: "hvg_score" + + - name: Outputs + arguments: + - name: "--output" + alternatives: ["-o"] + type: file + description: Output h5mu file. + direction: output + required: true + example: output.h5mu + +resources: + - type: python_script + path: script.py + +# test_resources: +# - type: python_script +# path: test.py +# - path: /resources_test/pbmc_1k_protein_v3 + +engines: + - type: docker + image: python:3.12-slim + setup: + - type: apt + packages: + - procps + - type: python + __merge__: [/src/base/requirements/anndata_mudata.yaml, .] + __merge__: [/src/base/requirements/python_test_setup.yaml, .] + +runners: + - type: executable + - type: nextflow + directives: + label: [highcpu, midmem] diff --git a/src/dimred/openproblems_dr_h5ad_to_h5mu/script.py b/src/dimred/openproblems_dr_h5ad_to_h5mu/script.py new file mode 100644 index 00000000000..e7371c02f9c --- /dev/null +++ b/src/dimred/openproblems_dr_h5ad_to_h5mu/script.py @@ -0,0 +1,37 @@ +import mudata as mu +import anndata as ad + +## VIASH START +par = { + "input": "resources_test/pbmc_1k_protein_v3/pbmc_1k_protein_v3_mms.h5mu", + "input_modality": "rna", + "input_layer_counts": "log_normalized", + "input_layer_normalized": "log_normalized", + "output": "output.h5mu" +} +## VIASH END + +print("Reading h5mu file", flush=True) +mdata = mu.read_h5mu(par["input"]) + +print("Transforming to anndata", flush=True) +def get_matrix(mdata, modality, layer): + if layer == "X": + return mdata.mod[modality].X + return mdata.mod[modality].layers[layer] + +adata = ad.AnnData( + layers={ + "counts": get_matrix(mdata, par["input_modality"], par["input_layer_counts"]), + "normalized": get_matrix(mdata, par["input_modality"], par["input_layer_normalized"]) + }, + obs=mdata.mod[par["input_modality"]].obs[[]], + var=mdata.mod[par["input_modality"]].var[[]], + uns={ + "dataset_id": "dummy", + "normalization_id": "dummy" + } +) + +print("Writing h5ad file", flush=True) +adata.write_h5ad(par["output"], compression="gzip") diff --git a/src/dimred/openproblems_dr_h5mu_to_h5ad/config.vsh.yaml b/src/dimred/openproblems_dr_h5mu_to_h5ad/config.vsh.yaml new file mode 100644 index 00000000000..e996091ec69 --- /dev/null +++ b/src/dimred/openproblems_dr_h5mu_to_h5ad/config.vsh.yaml @@ -0,0 +1,65 @@ +name: openproblems_dr_h5mu_to_h5ad +namespace: "dimred" + +argument_groups: + - name: Inputs + arguments: + - name: "--input_dataset" + type: file + description: Input h5mu file + direction: input + required: true + example: input.h5mu + + - name: "--input_output" + type: file + description: Method output h5ad file + direction: input + required: true + example: input.h5ad + + - name: "--input_modality" + type: string + default: "rna" + required: false + + - name: Outputs + arguments: + - name: "--output" + alternatives: ["-o"] + type: file + description: Output h5mu file. + direction: output + required: true + example: output.h5mu + + - name: "--output_obsm_key" + description: Key in the .obsm object to use as input. + type: string + required: false + +resources: + - type: python_script + path: script.py + +# test_resources: +# - type: python_script +# path: test.py +# - path: /resources_test/pbmc_1k_protein_v3 + +engines: + - type: docker + image: python:3.12-slim + setup: + - type: apt + packages: + - procps + - type: python + __merge__: [/src/base/requirements/anndata_mudata.yaml, .] + __merge__: [/src/base/requirements/python_test_setup.yaml, .] + +runners: + - type: executable + - type: nextflow + directives: + label: [highcpu, midmem] diff --git a/src/dimred/openproblems_dr_h5mu_to_h5ad/script.py b/src/dimred/openproblems_dr_h5mu_to_h5ad/script.py new file mode 100644 index 00000000000..69bf67433ef --- /dev/null +++ b/src/dimred/openproblems_dr_h5mu_to_h5ad/script.py @@ -0,0 +1,21 @@ +import mudata as mu +import anndata as ad + +## VIASH START +par = { + "input_dataset": "resources_test/pbmc_1k_protein_v3/pbmc_1k_protein_v3_mms.h5mu", + "input_output": "dr_method_output.h5ad", + "input_modality": "rna", + "output_obsm_key": "X_dr", + "output": "output.h5mu" +} +## VIASH END + +print("Reading h5mu file", flush=True) +mdata = mu.read_h5mu(par["input_dataset"]) +adata = ad.read_h5ad(par["input_output"]) + +mdata.mod[par["input_modality"]].obsm[par["output_obsm_key"]] = adata.obsm["X_emb"] + +print("Writing h5ad file", flush=True) +mdata.write_h5mu(par["output"]) From 12e22472da142369062505391a210960f446e5eb Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Fri, 20 Sep 2024 14:40:00 +0200 Subject: [PATCH 2/3] improve scripts and wfs --- _viash.yaml | 6 +++ src/dimred/openproblems_dr/config.vsh.yaml | 9 +---- src/dimred/openproblems_dr/test.sh | 9 +++++ .../config.vsh.yaml | 32 +++++++-------- .../openproblems_dr_h5ad_to_h5mu/script.py | 30 ++++---------- .../config.vsh.yaml | 30 +++++++------- .../openproblems_dr_h5mu_to_h5ad/script.py | 39 +++++++++++++++---- 7 files changed, 87 insertions(+), 68 deletions(-) create mode 100755 src/dimred/openproblems_dr/test.sh diff --git a/_viash.yaml b/_viash.yaml index 6706c0fe93e..d43500ec99e 100644 --- a/_viash.yaml +++ b/_viash.yaml @@ -27,3 +27,9 @@ config_mods: | .resources += {path: '/src/workflows/utils/labels.config', dest: 'nextflow_labels.config'} .runners[.type == 'nextflow'].directives.tag := '$id' .runners[.type == 'nextflow'].config.script := 'includeConfig("nextflow_labels.config")' + +repositories: + - type: github + name: openproblems_task_dimensionality_reduction + repo: openproblems-bio/task_dimensionality_reduction + tag: build/main diff --git a/src/dimred/openproblems_dr/config.vsh.yaml b/src/dimred/openproblems_dr/config.vsh.yaml index a47f335dd5d..8b0bc70922e 100644 --- a/src/dimred/openproblems_dr/config.vsh.yaml +++ b/src/dimred/openproblems_dr/config.vsh.yaml @@ -27,9 +27,9 @@ argument_groups: - name: "--input_var_hvg_score" type: string - description: In which layer to find the HVG scores. If not provided, the HVG scores are assumed to be in the .var object. + description: In which obsm to find the HVG scores. If not provided, the HVG scores are not passed. required: false - default: "hvg_score" + - name: Method settings arguments: - name: "--method_id" @@ -87,11 +87,6 @@ dependencies: repository: openproblems_task_dimensionality_reduction - name: methods/umap repository: openproblems_task_dimensionality_reduction -repositories: - - type: github - name: openproblems_task_dimensionality_reduction - repo: openproblems-bio/task_dimensionality_reduction - tag: build/main resources: - type: nextflow_script path: main.nf diff --git a/src/dimred/openproblems_dr/test.sh b/src/dimred/openproblems_dr/test.sh new file mode 100755 index 00000000000..b13a2e231fa --- /dev/null +++ b/src/dimred/openproblems_dr/test.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +# viash ns build --parallel -q openproblems --setup cb + +nextflow run . \ + -main-script target/nextflow/dimred/openproblems_dr/main.nf \ + -profile docker \ + --input resources_test/pbmc_1k_protein_v3/pbmc_1k_protein_v3_mms.h5mu \ + --publish_dir output/foo diff --git a/src/dimred/openproblems_dr_h5ad_to_h5mu/config.vsh.yaml b/src/dimred/openproblems_dr_h5ad_to_h5mu/config.vsh.yaml index 28fb7c70b4d..230fba4f63a 100644 --- a/src/dimred/openproblems_dr_h5ad_to_h5mu/config.vsh.yaml +++ b/src/dimred/openproblems_dr_h5ad_to_h5mu/config.vsh.yaml @@ -1,38 +1,29 @@ name: openproblems_dr_h5ad_to_h5mu namespace: "dimred" + argument_groups: - name: Inputs arguments: - - name: "--input" + - name: "--input_dataset" type: file description: Input h5mu file direction: input required: true example: input.h5mu + - name: "--input_output" + type: file + description: Method output h5ad file + direction: input + required: true + example: input.h5ad + - name: "--input_modality" type: string default: "rna" required: false - - name: "--input_layer_counts" - type: string - description: In which layer to find the raw counts. If not provided, the raw counts are assumed to be in the .X object. - required: false - - - name: "--input_layer_normalized" - type: string - description: In which layer to find the log normalized counts. If not provided, the raw counts are assumed to be in the .X object. - required: false - default: "log_normalized" - - - name: "--input_var_hvg_score" - type: string - description: In which layer to find the HVG scores. If not provided, the HVG scores are assumed to be in the .var object. - required: false - default: "hvg_score" - - name: Outputs arguments: - name: "--output" @@ -42,6 +33,11 @@ argument_groups: direction: output required: true example: output.h5mu + + - name: "--output_obsm_key" + description: Key in the .obsm object to use as input. + type: string + required: false resources: - type: python_script diff --git a/src/dimred/openproblems_dr_h5ad_to_h5mu/script.py b/src/dimred/openproblems_dr_h5ad_to_h5mu/script.py index e7371c02f9c..69bf67433ef 100644 --- a/src/dimred/openproblems_dr_h5ad_to_h5mu/script.py +++ b/src/dimred/openproblems_dr_h5ad_to_h5mu/script.py @@ -3,35 +3,19 @@ ## VIASH START par = { - "input": "resources_test/pbmc_1k_protein_v3/pbmc_1k_protein_v3_mms.h5mu", + "input_dataset": "resources_test/pbmc_1k_protein_v3/pbmc_1k_protein_v3_mms.h5mu", + "input_output": "dr_method_output.h5ad", "input_modality": "rna", - "input_layer_counts": "log_normalized", - "input_layer_normalized": "log_normalized", + "output_obsm_key": "X_dr", "output": "output.h5mu" } ## VIASH END print("Reading h5mu file", flush=True) -mdata = mu.read_h5mu(par["input"]) +mdata = mu.read_h5mu(par["input_dataset"]) +adata = ad.read_h5ad(par["input_output"]) -print("Transforming to anndata", flush=True) -def get_matrix(mdata, modality, layer): - if layer == "X": - return mdata.mod[modality].X - return mdata.mod[modality].layers[layer] - -adata = ad.AnnData( - layers={ - "counts": get_matrix(mdata, par["input_modality"], par["input_layer_counts"]), - "normalized": get_matrix(mdata, par["input_modality"], par["input_layer_normalized"]) - }, - obs=mdata.mod[par["input_modality"]].obs[[]], - var=mdata.mod[par["input_modality"]].var[[]], - uns={ - "dataset_id": "dummy", - "normalization_id": "dummy" - } -) +mdata.mod[par["input_modality"]].obsm[par["output_obsm_key"]] = adata.obsm["X_emb"] print("Writing h5ad file", flush=True) -adata.write_h5ad(par["output"], compression="gzip") +mdata.write_h5mu(par["output"]) diff --git a/src/dimred/openproblems_dr_h5mu_to_h5ad/config.vsh.yaml b/src/dimred/openproblems_dr_h5mu_to_h5ad/config.vsh.yaml index e996091ec69..70c639b3d30 100644 --- a/src/dimred/openproblems_dr_h5mu_to_h5ad/config.vsh.yaml +++ b/src/dimred/openproblems_dr_h5mu_to_h5ad/config.vsh.yaml @@ -4,25 +4,34 @@ namespace: "dimred" argument_groups: - name: Inputs arguments: - - name: "--input_dataset" + - name: "--input" type: file description: Input h5mu file direction: input required: true example: input.h5mu - - name: "--input_output" - type: file - description: Method output h5ad file - direction: input - required: true - example: input.h5ad - - name: "--input_modality" type: string default: "rna" required: false + - name: "--input_layer_counts" + type: string + description: In which layer to find the raw counts. If not provided, the raw counts are assumed to be in the .X object. + required: false + + - name: "--input_layer_normalized" + type: string + description: In which layer to find the log normalized counts. If not provided, the raw counts are assumed to be in the .X object. + required: false + default: "log_normalized" + + - name: "--input_var_hvg_score" + type: string + description: In which obsm to find the HVG scores. If not provided, the HVG scores are not passed. + required: false + - name: Outputs arguments: - name: "--output" @@ -32,11 +41,6 @@ argument_groups: direction: output required: true example: output.h5mu - - - name: "--output_obsm_key" - description: Key in the .obsm object to use as input. - type: string - required: false resources: - type: python_script diff --git a/src/dimred/openproblems_dr_h5mu_to_h5ad/script.py b/src/dimred/openproblems_dr_h5mu_to_h5ad/script.py index 69bf67433ef..f30ec9a74b2 100644 --- a/src/dimred/openproblems_dr_h5mu_to_h5ad/script.py +++ b/src/dimred/openproblems_dr_h5mu_to_h5ad/script.py @@ -3,19 +3,44 @@ ## VIASH START par = { - "input_dataset": "resources_test/pbmc_1k_protein_v3/pbmc_1k_protein_v3_mms.h5mu", - "input_output": "dr_method_output.h5ad", + "input": "resources_test/pbmc_1k_protein_v3/pbmc_1k_protein_v3_mms.h5mu", "input_modality": "rna", - "output_obsm_key": "X_dr", + "input_layer_counts": "log_normalized", + "input_layer_normalized": "log_normalized", + "input_var_hvg_score": None, "output": "output.h5mu" } ## VIASH END print("Reading h5mu file", flush=True) -mdata = mu.read_h5mu(par["input_dataset"]) -adata = ad.read_h5ad(par["input_output"]) +mdata = mu.read_h5mu(par["input"]) -mdata.mod[par["input_modality"]].obsm[par["output_obsm_key"]] = adata.obsm["X_emb"] +print("Transforming to anndata", flush=True) +def get_matrix(mdata, modality, layer): + if layer == "X": + return mdata.mod[modality].X + return mdata.mod[modality].layers[layer] + +# create var +var = mdata.mod[par["input_modality"]].var[[]] + +if par["input_var_hvg_score"] is not None: + assert par["input_var_hvg_score"] in var.columns, f"Variable {par['input_var_hvg_score']} not found in var" + var["hvg_score"] = mdata.mod[par["input_modality"]].var[par["input_var_hvg_score"]] + +# create anndata +adata = ad.AnnData( + layers={ + "counts": get_matrix(mdata, par["input_modality"], par["input_layer_counts"]), + "normalized": get_matrix(mdata, par["input_modality"], par["input_layer_normalized"]) + }, + obs=mdata.mod[par["input_modality"]].obs[[]], + var=var, + uns={ + "dataset_id": "dummy", + "normalization_id": "dummy" + } +) print("Writing h5ad file", flush=True) -mdata.write_h5mu(par["output"]) +adata.write_h5ad(par["output"], compression="gzip") From 849413add7fb6ab332de160f2533237c94f0be8b Mon Sep 17 00:00:00 2001 From: Robrecht Cannoodt Date: Sat, 21 Sep 2024 07:54:55 +0200 Subject: [PATCH 3/3] fix issues in components --- src/dimred/openproblems_dr/config.vsh.yaml | 4 ++-- src/dimred/openproblems_dr/main.nf | 22 +++++++++++++------ src/dimred/openproblems_dr/test.sh | 2 ++ .../openproblems_dr_h5ad_to_h5mu/script.py | 5 +++-- .../openproblems_dr_h5mu_to_h5ad/script.py | 2 +- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/dimred/openproblems_dr/config.vsh.yaml b/src/dimred/openproblems_dr/config.vsh.yaml index 8b0bc70922e..ae6c88c62f2 100644 --- a/src/dimred/openproblems_dr/config.vsh.yaml +++ b/src/dimred/openproblems_dr/config.vsh.yaml @@ -35,7 +35,7 @@ argument_groups: - name: "--method_id" description: ID of the method to use. type: string - required: false + required: true choices: [ densmap, diffusion_map, @@ -59,7 +59,7 @@ argument_groups: example: output.h5mu - name: "--output_obsm_key" - description: Key in the .obsm object to use as input. + description: Key in the .obsm object to use as input. If not provided, "X_{method_id}" is used. type: string required: false dependencies: diff --git a/src/dimred/openproblems_dr/main.nf b/src/dimred/openproblems_dr/main.nf index d977e35f082..d7ae75f3fcf 100644 --- a/src/dimred/openproblems_dr/main.nf +++ b/src/dimred/openproblems_dr/main.nf @@ -34,7 +34,7 @@ workflow run_wf { | runEach( components: methods, - runIf: { id, state, comp -> + filter: { id, state, comp -> state.method_id == comp.config.name }, fromState: [ @@ -46,17 +46,25 @@ workflow run_wf { ) | openproblems_dr_h5ad_to_h5mu.run( - fromState: [ - "input_dataset": "input", - "input_output": "method_output", - "input_modality": "input_modality", - "output_obsm_key": "output_obsm_key", - ], + fromState: { id, state -> + def output_obsm_key = state.output_obsm_key + if (!output_obsm_key) { + output_obsm_key = "X_" + state.method_id + } + [ + "input_dataset": state.input, + "input_output": state.method_output, + "input_modality": state.input_modality, + "output_obsm_key": output_obsm_key + ] + }, toState: [ "output": "output" ] ) + | setState(["output"]) + emit: output_ch } diff --git a/src/dimred/openproblems_dr/test.sh b/src/dimred/openproblems_dr/test.sh index b13a2e231fa..73c3daaed14 100755 --- a/src/dimred/openproblems_dr/test.sh +++ b/src/dimred/openproblems_dr/test.sh @@ -5,5 +5,7 @@ nextflow run . \ -main-script target/nextflow/dimred/openproblems_dr/main.nf \ -profile docker \ + -resume \ --input resources_test/pbmc_1k_protein_v3/pbmc_1k_protein_v3_mms.h5mu \ + --method_id pymde \ --publish_dir output/foo diff --git a/src/dimred/openproblems_dr_h5ad_to_h5mu/script.py b/src/dimred/openproblems_dr_h5ad_to_h5mu/script.py index 69bf67433ef..1788a923018 100644 --- a/src/dimred/openproblems_dr_h5ad_to_h5mu/script.py +++ b/src/dimred/openproblems_dr_h5ad_to_h5mu/script.py @@ -4,7 +4,7 @@ ## VIASH START par = { "input_dataset": "resources_test/pbmc_1k_protein_v3/pbmc_1k_protein_v3_mms.h5mu", - "input_output": "dr_method_output.h5ad", + "input_output": "work/90/56062df29c88150755a174b63bdb82/_viash_par/input_output_1/run.pymde.output.h5ad", "input_modality": "rna", "output_obsm_key": "X_dr", "output": "output.h5mu" @@ -15,7 +15,8 @@ mdata = mu.read_h5mu(par["input_dataset"]) adata = ad.read_h5ad(par["input_output"]) -mdata.mod[par["input_modality"]].obsm[par["output_obsm_key"]] = adata.obsm["X_emb"] +adata_dest = mdata.mod[par["input_modality"]] +adata_dest.obsm[par["output_obsm_key"]] = adata.obsm["X_emb"] print("Writing h5ad file", flush=True) mdata.write_h5mu(par["output"]) diff --git a/src/dimred/openproblems_dr_h5mu_to_h5ad/script.py b/src/dimred/openproblems_dr_h5mu_to_h5ad/script.py index f30ec9a74b2..687927c50c4 100644 --- a/src/dimred/openproblems_dr_h5mu_to_h5ad/script.py +++ b/src/dimred/openproblems_dr_h5mu_to_h5ad/script.py @@ -17,7 +17,7 @@ print("Transforming to anndata", flush=True) def get_matrix(mdata, modality, layer): - if layer == "X": + if layer is None: return mdata.mod[modality].X return mdata.mod[modality].layers[layer]