Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clonotype_modularity() seems not to work with schema upgraded AnnData #420

Closed
riederd opened this issue Jun 27, 2023 · 2 comments · Fixed by #421
Closed

clonotype_modularity() seems not to work with schema upgraded AnnData #420

riederd opened this issue Jun 27, 2023 · 2 comments · Fixed by #421
Labels
bug Something isn't working

Comments

@riederd
Copy link
Collaborator

riederd commented Jun 27, 2023

Description
When using adata which was upgraded to the new schema, clonotype_modularity() throws the following error.

/home/rieder/.conda/envs/scirpy/lib/python3.10/site-packages/scipy/optimize/_numdiff.py:576: RuntimeWarning: invalid value encountered in subtract
  df = fun(x) - f0
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[173], line 1
----> 1 ir.tl.clonotype_modularity(adata, target_col="cc_aa_alignment", connectivity_key='connectivities')

File ~/.conda/envs/scirpy/lib/python3.10/site-packages/scirpy/tl/_clonotype_modularity.py:159, in clonotype_modularity(adata, target_col, connectivity_key, permutation_test, n_permutations, key_added, inplace, fdr_correction, random_state, airr_mod)
    155 # remove the entries from previous run, should they exist
    156 # results can be inconsisten otherwise (old dangling "fdr" values when only
    157 # pvalues are calculated)
    158 for suffix in ["fdr", "pvalue"]:
--> 159     for d in [params.mdata, params.adata]:
    160         try:
    161             del d.obs[f"{key_added}_{suffix}"]

File ~/.conda/envs/scirpy/lib/python3.10/site-packages/scirpy/util/__init__.py:239, in DataHandler.mdata(self)
    237     return self._data
    238 else:
--> 239     raise AttributeError("DataHandler was initalized with only AnnData")

AttributeError: DataHandler was initalized with only AnnData

To Reproduce
Use an AnnData object created with scirpy version < 0.13.0, upgrad with scirpy.io.upgrade_schema() follow the 3k Tcell tutorial and run ir.tl.clonotype_modularity(adata, target_col="cc_aa_alignment", connectivity_key='connectivities')

Expected behaviour
function call w/o error

System

  • OS: CentOS 7
  • Python version 3.10
  • Versions of libraries involved
    scirpy==0.13.0 scanpy==1.9.3 anndata==0.9.1 umap==0.5.3 numpy==1.23.5 scipy==1.10.1 pandas==1.5.3 scikit-learn==1.2.2 statsmodels==0.13.5 python-igraph==0.10.3 pynndescent==0.5.10
@riederd riederd added the bug Something isn't working label Jun 27, 2023
@grst
Copy link
Collaborator

grst commented Jun 27, 2023

Hi,
thanks for reporting!
Could you try the proposed fix in fix-420?

pip install git+https://github.com/scverse/scirpy.git@fix-420

@grst grst mentioned this issue Jun 27, 2023
@riederd
Copy link
Collaborator Author

riederd commented Jun 28, 2023

Thanks, it seems to work

@grst grst closed this as completed in #421 Jun 28, 2023
grst added a commit that referenced this issue Jun 28, 2023
* Defer accessing params attributes until in try block

* Update CHANGELOG.md

* [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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants