Skip to content

Commit

Permalink
Fix compatibility with SciPy 1.15.0 (#945)
Browse files Browse the repository at this point in the history
  • Loading branch information
DriesSchaumont authored Jan 7, 2025
1 parent b57e607 commit 075df2f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# openpipelines 2.1.0

## MINOR CHANGES
# MINOR CHANGES

* `grep_annotation_column` and `subset_obsp`: Fix compatibility for SciPy (PR #945).

* `popv`: Pin numpy<2 after new release of scvi-tools (PR #946).

Expand Down
5 changes: 5 additions & 0 deletions src/filter/subset_obsp/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ def main():
# the index dimensions remain unaltered, but .obsp columns will be subset
obsp = adata.obsp[par["input_obsp_key"]]
idx = adata.obs[par["input_obs_key"]].astype(str) == par["input_obs_value"]
# A Series object cannot be used as an indexer for a scipy sparse array
# when the data type is a pandas boolean extension array because
# extension arrays do not define .nonzero()
# See https://github.com/pandas-dev/pandas/issues/46025
idx = idx.to_numpy(dtype="bool", na_value=False)
obsm_subset = obsp[:, idx]

logger.info(f"Writing subset obsp matrix to .obsm {par['output_obsm_key']}")
Expand Down
8 changes: 8 additions & 0 deletions src/metadata/grep_annotation_column/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
### VIASH START
par = {
"input": "./resources_test/concat_test_data/e18_mouse_brain_fresh_5k_filtered_feature_bc_matrix_subset_unique_obs.h5mu",
"input_layer": None,
"modality": "rna",
"matrix": "var",
"input_column": "gene_symbol",
Expand All @@ -21,6 +22,8 @@
"output_fraction_column": "fraction_test",
"output_compression": "gzip",
}

meta = {"resources_dir": "src/utils"}
### VIASH END
sys.path.append(meta["resources_dir"])
from setup_logger import setup_logger
Expand Down Expand Up @@ -90,6 +93,11 @@ def main(par):
logger.info("Applying regex search.")
grep_result = annotation_column.str.contains(par["regex_pattern"], regex=True)
logger.info("Search results: %s", grep_result.value_counts())
# A Series object cannot be used as an indexer for a scipy sparse array
# when the data type is a pandas boolean extension array because
# extension arrays do not define .nonzero()
# See https://github.com/pandas-dev/pandas/issues/46025
grep_result = grep_result.to_numpy(dtype="bool", na_value=False)

other_axis_attribute = {"var": "obs", "obs": "var"}
if par["output_fraction_column"]:
Expand Down

0 comments on commit 075df2f

Please sign in to comment.