Skip to content

Commit

Permalink
Bump liana to 1.3.0 (#862)
Browse files Browse the repository at this point in the history
  • Loading branch information
DriesSchaumont authored Aug 16, 2024
1 parent e5c3608 commit 5b0a66d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

* Removed `--disable_library_compatibility_check` in favour of `--check_library_compatibility` to the `mapping/cellranger_multi` component and the `ingestion/cellranger_multi` workflow (PR #818).

* `lianapy`: bumped version to `1.2.1` (PR #827).
* `lianapy`: bumped version to `1.3.0` (PR #827 and PR #862). Additionally, `groupby` is now a required argument.

* `XGBoost`: bump version to `2.0.3` (PR #646).

Expand Down
5 changes: 2 additions & 3 deletions src/interpret/lianapy/config.vsh.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ functionality:
description: "Layer in anndata.AnnData.layers to use. If None, use mudata.mod[modality].X."
- name: "--groupby"
type: string
default: "bulk_labels"
required: false
required: true
description: "The key of the observations grouping to consider."
- name: "--resource_name"
type: string
Expand Down Expand Up @@ -93,7 +92,7 @@ platforms:
- type: python
__merge__: [/src/base/requirements/anndata_mudata.yaml, .]
packages:
- liana~=1.2.1
- liana~=1.3.0
test_setup:
- type: python
__merge__: [ /src/base/requirements/viashpy.yaml, .]
Expand Down
16 changes: 12 additions & 4 deletions src/interpret/lianapy/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
# TODO: Remove when grouping labels exist
# For sign/PCA/
import numpy as np
import pandas as pd

### VIASH START
par = {
"input": "integration.pca.output.h5mu",
"input": "resources_test/pbmc_1k_protein_v3/pbmc_1k_protein_v3_mms.h5mu",
"output": "foo.h5mu",
"output_compression": "gzip",
"modality": "rna",
"layer": None,
"gene_symbol": "gene_symbol",
"groupby": "bulk_labels",
"groupby": "harmony_integration_leiden_1.0",
"resource_name": "consensus",
"expr_prop": 0.1,
"min_cells": 5,
Expand All @@ -31,8 +32,12 @@ def main():

# Add dummy grouping labels when they do not exist
if par['groupby'] not in mod.obs:
foo = mod.obsm.to_df().iloc[:, 0]
mod.obs[par['groupby']] = np.sign(foo).astype('category')
raise ValueError(f"Column {par['groupy']} does not exist in "
f".obs for modality {par['modality']}.")
mod_col = mod.obs[par['groupby']]
original_groupby_col = mod_col.copy()
if not isinstance(mod_col, pd.CategoricalDtype):
mod.obs[par['groupby']] = mod_col.astype(str).astype('category')

# Solve gene labels
orig_gene_label = mod.var.index
Expand All @@ -57,6 +62,9 @@ def main():
# Return original gene labels
mod.var_names = orig_gene_label

# Undo modifications to groupby column
mod.obs[par["groupby"]] = original_groupby_col

# TODO: make sure compression is needed
mdata.write_h5mu(par['output'].strip(), compression=par['output_compression'])

Expand Down
10 changes: 5 additions & 5 deletions src/interpret/lianapy/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

## VIASH START
meta = {
'executable': './target/native/interpret/lianapy/',
'executable': './target/executable/interpret/lianapy/',
'resources_dir': './resources_test/pbmc_1k_protein_v3/'
}
## VIASH END
Expand All @@ -21,8 +21,8 @@ def test_lianapy(run_component, tmp_path):
"--input", input_file,
"--output_compression", "gzip",
"--modality", "rna",
# "--layer", "log_normalized",
"--groupby", "bulk_labels",
"--layer", "log_normalized",
"--groupby", "harmony_integration_leiden_1.0",
"--resource_name", "consensus",
"--gene_symbol", "gene_symbol",
"--expr_prop", "0.1",
Expand All @@ -39,8 +39,8 @@ def test_lianapy(run_component, tmp_path):
np.testing.assert_array_equal(output_data.mod['rna'].X.data, input_data.mod['rna'].X.data)
np.testing.assert_array_equal(input_data.mod['rna'].var.index, output_data.mod['rna'].var.index)
assert "liana_res" in output_data.mod["rna"].uns
assert all(elem in output_data.mod['rna'].obs['bulk_labels'].values for elem in output_data.mod['rna'].uns['liana_res']['source'].unique())
assert all(elem in output_data.mod['rna'].obs['bulk_labels'].values for elem in output_data.mod['rna'].uns['liana_res']['target'].unique())
assert all(elem in output_data.mod['rna'].obs['harmony_integration_leiden_1.0'].values for elem in output_data.mod['rna'].uns['liana_res']['source'].unique())
assert all(elem in output_data.mod['rna'].obs['harmony_integration_leiden_1.0'].values for elem in output_data.mod['rna'].uns['liana_res']['target'].unique())

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

0 comments on commit 5b0a66d

Please sign in to comment.