Skip to content

Commit

Permalink
Fix incompatibility with latest pandas/scipy
Browse files Browse the repository at this point in the history
  • Loading branch information
grst committed Jan 17, 2025
1 parent e5943ea commit de9956c
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 71 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
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 de9956c

Please sign in to comment.