Skip to content

Commit

Permalink
Fix notebook bugs and dependency issues (#281)
Browse files Browse the repository at this point in the history
* Fix failing cell in integration.ipynb

In the original cell the following code was specified:

```
data = snap.read_dataset(
    "colon.h5ads",
    update_data_locations = {"colon_transverse_SM-CSSDA": "colon_transverse_SM-CSSDA.h5ad"},
)
data
```

This raises the following error:
```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[25], line 1
----> 1 data = snap.read_dataset(
      2     "colon.h5ads",
      3     update_data_locations = {"colon_transverse_SM-CSSDA": "colon_transverse_SM-CSSDA.h5ad"},
      4 )
      5 data

TypeError: read_dataset() got an unexpected keyword argument 'update_data_locations'
```

Looking at the `read_dataset` function definition in pyanndata-0.3.2:
https://docs.rs/pyanndata/0.3.2/pyanndata/anndata/fn.read_dataset.html

It looks like the arg `update_data_locations` should actually be
`adata_files_update`.

* Address deprecated way of initializing AnnData in _scrublet.py

While running SnapAtac2 notebooks the following warning was
fairly frequently encountered when running `snap.pp.scrublet()`:

```
/usr/local/lib/python3.11/site-packages/anndata/_core/anndata.py:522: FutureWarning:

The dtype argument is deprecated and will be removed in late 2024.
```

It looks like the `anndata` project plans to deprecate and completely
remove the `dtype` argument to `AnnData` instantiation somewhat soon.
See: scverse/anndata@85162c7
See also: scverse/anndata#1126

This commit removes the `dtype` argument from `AnnData` instantiation
as it will be removed in future versions of `AnnData`.

* Add dependencies to `recommend` so more notebooks run properly

This commit adds some additional dependencies so that more notebooks
under `docs/tutorials` can run properly when installing with
`pip install snapatac2[recommend]`.

In future work, it may make sense to remove dependencies like
`scanorama` and `harmonypy` from `extra`
`[project.optional-dependencies]` as `scanpy` already shares the
exact same dependencies and it may be easier for future maintenance
for `scanpy` to deal with versioning and pinning.
  • Loading branch information
njmei authored Mar 31, 2024
1 parent b73dcfd commit 3bcb4a2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/tutorials/integration.ipynb
Git LFS file not shown
2 changes: 1 addition & 1 deletion snapatac2-python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ Changelog = "https://kzhang.org/SnapATAC2/version/dev/changelog.html"

[project.optional-dependencies]
extra = ["scanorama>=1.7.3", "harmonypy>=0.0.9", "xgboost>=1.4", "umap-learn>=0.5.0"]
recommend = ["scanpy[skmisc]>=1.9", "scvi-tools>=1.0"]
recommend = ["scanpy[scanorama, skmisc, magic, harmony]>=1.9", "scvi-tools>=1.0"]
all = ["snapatac2[extra]", "snapatac2[recommend]"]
test = ["pytest", "hypothesis==6.72.4"]
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def scrub_doublets_core(
del count_matrix_sim
gc.collect()
_, evecs = spectral(
AnnData(X=merged_matrix, dtype=merged_matrix.dtype),
AnnData(X=merged_matrix),
features=None,
n_comps=n_comps,
inplace=False,
Expand Down

0 comments on commit 3bcb4a2

Please sign in to comment.