Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@

* Fix failing tests for `ingestion/cellranger_postprocessing`, `ingestion/conversion` and `multiomics/process_batches` (PR #869).

* `convert/from_10xh5_to_h5mu`: add .uns slot to mdata root when metrics file is provided (PR #887).

## DOCUMENTATION

* Update authorship of components (PR #835).
Expand Down
5 changes: 3 additions & 2 deletions src/convert/from_10xh5_to_h5mu/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def setup_logger():
.reset_index()\
.set_index("gene_ids")

# parse metrics summary file and store in .obsm or .obs
# parse metrics summary file and store in .uns
if par["input_metrics_summary"] and par["uns_metrics"]:
logger.info("Reading metrics summary file '%s'", par['input_metrics_summary'])

Expand Down Expand Up @@ -76,8 +76,9 @@ def read_percentage(val):
logger.info("Convert to mudata")
mdata = mudata.MuData(adata)

# override root .obs
# override root .obs and .uns
mdata.obs = adata.obs
mdata.uns = adata.uns

# write output
logger.info("Writing %s", par["output"])
Expand Down
23 changes: 21 additions & 2 deletions src/convert/from_10xh5_to_h5mu/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
## VIASH END

input = meta["resources_dir"] + "/pbmc_1k_protein_v3/pbmc_1k_protein_v3_filtered_feature_bc_matrix.h5"
metrics = meta["resources_dir"] + "/pbmc_1k_protein_v3/pbmc_1k_protein_v3_metrics_summary.csv"

def test_run(run_component, random_h5mu_path):
output = random_h5mu_path()
Expand Down Expand Up @@ -40,7 +41,25 @@ def test_run(run_component, random_h5mu_path):
assert (
"CD3" in data.mod["prot"].var_names
), 'Output should contain antibody column "CD3".'



def test_run_with_metrics(run_component, random_h5mu_path):
output = random_h5mu_path()
cmd_pars = [
"--input", input,
"--output", output,
"--input_metrics_summary", metrics,
"--output_compression", "gzip",
]
run_component(cmd_pars)

# check if file exists
assert path.exists(output), "No output was created."

# read it with scanpy
data = read_h5mu(output)

# check whether uns slot was found
assert "metrics_cellranger" in data.uns, "Output mudata object should contain an .uns slot with cellranger metrics."

if __name__ == "__main__":
sys.exit(pytest.main([__file__]))