Skip to content

Commit

Permalink
Fix incompatibility with latest pandas/scipy (#149)
Browse files Browse the repository at this point in the history
* Fix incompatibility with latest pandas/scipy

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
grst and pre-commit-ci[bot] authored Jan 17, 2025
1 parent e5943ea commit 28d1eee
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 81 deletions.
65 changes: 0 additions & 65 deletions .flake8

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ infercnv_env/

# Node.js
node_modules/

# uv
uv.lock
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ except in that they look similar, but not identical, to the results of InferCNV.

Please refer to the [documentation][link-docs]. In particular, the

- [API documentation][link-api].
- [API documentation][link-api].

## Installation

Expand Down
18 changes: 9 additions & 9 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ Specify `vX.X.X` as a tag name and create a release. For more information, see [

Please write documentation for new or changed features and use-cases. This project uses [sphinx][] with the following features:

- the [myst][] extension allows to write documentation in markdown/Markedly Structured Text
- [Numpy-style docstrings][numpydoc] (through the [napoloen][numpydoc-napoleon] extension).
- Jupyter notebooks as tutorials through [myst-nb][] (See [Tutorials with myst-nb](#tutorials-with-myst-nb-and-jupyter-notebooks))
- [Sphinx autodoc typehints][], to automatically reference annotated input and output types
- Citations (like {cite:p}`Virshup_2023`) can be included with [sphinxcontrib-bibtex](https://sphinxcontrib-bibtex.readthedocs.io/)
- the [myst][] extension allows to write documentation in markdown/Markedly Structured Text
- [Numpy-style docstrings][numpydoc] (through the [napoloen][numpydoc-napoleon] extension).
- Jupyter notebooks as tutorials through [myst-nb][] (See [Tutorials with myst-nb](#tutorials-with-myst-nb-and-jupyter-notebooks))
- [Sphinx autodoc typehints][], to automatically reference annotated input and output types
- Citations (like {cite:p}`Virshup_2023`) can be included with [sphinxcontrib-bibtex](https://sphinxcontrib-bibtex.readthedocs.io/)

See the [scanpy developer docs](https://scanpy.readthedocs.io/en/latest/dev/documentation.html) for more information
on how to write documentation.
Expand All @@ -120,10 +120,10 @@ repository.

#### Hints

- If you refer to objects from other packages, please add an entry to `intersphinx_mapping` in `docs/conf.py`. Only
if you do so can sphinx automatically create a link to the external documentation.
- If building the documentation fails because of a missing link that is outside your control, you can add an entry to
the `nitpick_ignore` list in `docs/conf.py`
- If you refer to objects from other packages, please add an entry to `intersphinx_mapping` in `docs/conf.py`. Only
if you do so can sphinx automatically create a link to the external documentation.
- If building the documentation fails because of a missing link that is outside your control, you can add an entry to
the `nitpick_ignore` list in `docs/conf.py`

#### Building the docs locally

Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ urls.Source = "https://github.com/icbi-lab/infercnvpy"
urls.Home-page = "https://github.com/icbi-lab/infercnvpy"
dependencies = [
'anndata>=0.7.3',
'scanpy>=1.6.0',
"scanpy>=1.9",
'pandas>=1',
'numpy>=1.20', # includes type annotations
'tqdm>=4.63.0', # fixes tqdm.auto
Expand All @@ -36,7 +36,6 @@ dependencies = [
'pytest-benchmark',
# for debug logging (referenced from the issue template)
"session-info",
"ipython"
]

[project.optional-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/infercnvpy/pl/_chromosome_heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def chromosome_heatmap_summary(
tmp_obs.index = tmp_obs.index.astype(str)

def _get_group_mean(group):
group_mean = np.mean(adata.obsm[f"X_{use_rep}"][adata.obs[groupby] == group, :], axis=0)
group_mean = np.mean(adata.obsm[f"X_{use_rep}"][adata.obs[groupby].values == group, :], axis=0)
if len(group_mean.shape) == 1:
# derived from an array instead of sparse matrix -> 1 dim instead of 2
group_mean = group_mean[np.newaxis, :]
Expand Down
4 changes: 2 additions & 2 deletions src/infercnvpy/tl/_infercnv.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def infercnv(
raise ValueError("Ensure your var_names are unique!")
if {"chromosome", "start", "end"} - set(adata.var.columns) != set():
raise ValueError(
"Genomic positions not found. There need to be `chromosome`, `start`, and " "`end` columns in `adata.var`. "
"Genomic positions not found. There need to be `chromosome`, `start`, and `end` columns in `adata.var`. "
)

var_mask = adata.var["chromosome"].isnull()
Expand Down Expand Up @@ -388,7 +388,7 @@ def _get_reference(
f"{reference_cat[~reference_cat_in_obs]}"
)

reference = np.vstack([np.mean(adata.X[obs_col == cat, :], axis=0) for cat in reference_cat])
reference = np.vstack([np.mean(adata.X[obs_col.values == cat, :], axis=0) for cat in reference_cat])

if reference.ndim == 1:
reference = reference[np.newaxis, :]
Expand Down
2 changes: 1 addition & 1 deletion src/infercnvpy/tl/_scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def cnv_score(
if groupby not in adata.obs.columns and groupby == "cnv_leiden":
raise ValueError("`cnv_leiden` not found in `adata.obs`. Did you run `tl.leiden`?")
cluster_score = {
cluster: np.mean(np.abs(adata.obsm[f"X_{use_rep}"][adata.obs[groupby] == cluster, :]))
cluster: np.mean(np.abs(adata.obsm[f"X_{use_rep}"][adata.obs[groupby].values == cluster, :]))
for cluster in adata.obs[groupby].unique()
}

Expand Down

0 comments on commit 28d1eee

Please sign in to comment.