dynamo-release icon indicating copy to clipboard operation
dynamo-release copied to clipboard

AttributeError: 'AnchoredSizeLocator' object has no attribute 'get_subplotspec'

Open DanieleMuraro opened this issue 3 years ago • 8 comments

Hi,

I installed dynamo with python 3.10.2 using

pip install dynamo-release

I then downloaded your zebrafish tutorial

https://raw.githubusercontent.com/aristoteleo/dynamo-tutorials/master/zebrafish.ipynb

and tried to run it (see pdf attached):

zebrafish.pdf

I got an odd looking umap (see pdf) and the error

AttributeError: 'AnchoredSizeLocator' object has no attribute 'get_subplotspec'

when running

dyn.pl.phase_portraits(adata, genes=adata.var_names[adata.var.use_for_dynamics][:4], figsize=(6, 4), color='Cell_type')

Could you please advise?

The YML file of the conda environment is at the link:

https://drive.google.com/file/d/1mDaUzzDloRzmHS9HV7eUq7CZp13yqNX_/view?usp=sharing

Thanks,

Daniele

DanieleMuraro avatar Feb 12 '22 17:02 DanieleMuraro

hey @DanieleMuraro, thanks for using dynamo.

Regarding the first umap issue, I believe it is a umap version issue. We have fixed this issue. Could you please pull the latest dynamo repo and then setup install?

Regarding the second issue, it related to the fact that we used tight_layout for our plots. what is your matplotlib version? if you use 3.4.1, it should work well.

Please let me know if you still have any issues after installing latest dynamo and use matplotlib=3.4.1.

In addition, we are going to release a new version of dynamo to PyPi in a few days which should fix all issues you bring up.

Xiaojieqiu avatar Feb 12 '22 23:02 Xiaojieqiu

Hi @Xiaojieqiu

Thank you so much for your help :-)

It worked using Python 3.9.10 with the following requirements.txt:

numpy==1.20.0
pandas>=1.1.2
scipy>=1.4.1
scikit-learn>=0.19.1
cvxopt>=1.2.3
anndata==0.7.5
loompy>=3.0.5
matplotlib==3.4.1
trimap>=1.0.11
setuptools
numdifftools>=0.9.39
umap-learn>=0.5.1
PATSY>=0.5.1
statsmodels>=0.9.0
numba>=0.46.0
seaborn>=0.9.0
colorcet>=2.0.1
tqdm
python-igraph>=0.7.1
pynndescent>=0.5.2
pre-commit
networkx
h5py<3.2

The only very minor issue is with dyn.get_all_dependencies_version() returning:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Input In [27], in <module>
----> 1 dyn.get_all_dependencies_version()

File /lustre/scratch117/cellgen/team205/dm19/kazu/notebooks/workflow/dynamo/dynamo-release/dynamo/get_version.py:175, in get_all_dependencies_version(display)
    172 import pandas as pd
    174 _package_name = "dynamo-release"
--> 175 _package = pkg_resources.working_set.by_key[_package_name]
    177 all_dependencies = [str(r).split(">")[0] for r in _package.requires()]  # retrieve deps from setup.py
    178 all_dependencies.sort(reverse=True)

KeyError: 'dynamo-release'

but it is doesn't prevent using the package:

dynamo.pdf

I report the yml file in case it's useful for anybody:

https://drive.google.com/file/d/1YhaMdFpefc1KcvetZRaOp6J59_OQO1Tr/view?usp=sharing

DanieleMuraro avatar Feb 13 '22 13:02 DanieleMuraro

Hello! @DanieleMuraro I built the environment based on the environment file you provided. But I got a mistake in the second step.

dyn.tl.dynamics(adata, model='stochastic', cores=3) Traceback (most recent call last): File "", line 1, in File "/DATA/sxz/data/anaconda3/envs/dynamo-env/lib/python3.9/site-packages/dynamo/tools/dynamics.py", line 496, in dynamics conn=subset_adata.obsp["moments_con"], File "/DATA/sxz/data/anaconda3/envs/dynamo-env/lib/python3.9/site-packages/anndata/_core/aligned_mapping.py", line 113, in getitem _subset(self.parent_mapping[key], self.subset_idx), File "/DATA/sxz/data/anaconda3/envs/dynamo-env/lib/python3.9/site-packages/anndata/_core/aligned_mapping.py", line 148, in getitem return self._data[key] KeyError: 'moments_con'

Can you help me check the error? Thanks.

xiaozhongshen avatar Feb 14 '22 15:02 xiaozhongshen

Hi @xiaozhongshen

Which anndata version are you using?

Best,

Daniele

DanieleMuraro avatar Feb 14 '22 15:02 DanieleMuraro

Thanks @DanieleMuraro and @xiaozhongshen

it seems like the moments_con is not computed for your data, please run dyn.tl.moments(adata) first

Xiaojieqiu avatar Feb 14 '22 17:02 Xiaojieqiu

Hi @Xiaojieqiu

Thank you so much for your help :-)

It worked using Python 3.9.10 with the following requirements.txt:

numpy==1.20.0
pandas>=1.1.2
scipy>=1.4.1
scikit-learn>=0.19.1
cvxopt>=1.2.3
anndata==0.7.5
loompy>=3.0.5
matplotlib==3.4.1
trimap>=1.0.11
setuptools
numdifftools>=0.9.39
umap-learn>=0.5.1
PATSY>=0.5.1
statsmodels>=0.9.0
numba>=0.46.0
seaborn>=0.9.0
colorcet>=2.0.1
tqdm
python-igraph>=0.7.1
pynndescent>=0.5.2
pre-commit
networkx
h5py<3.2

The only very minor issue is with dyn.get_all_dependencies_version() returning:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Input In [27], in <module>
----> 1 dyn.get_all_dependencies_version()

File /lustre/scratch117/cellgen/team205/dm19/kazu/notebooks/workflow/dynamo/dynamo-release/dynamo/get_version.py:175, in get_all_dependencies_version(display)
    172 import pandas as pd
    174 _package_name = "dynamo-release"
--> 175 _package = pkg_resources.working_set.by_key[_package_name]
    177 all_dependencies = [str(r).split(">")[0] for r in _package.requires()]  # retrieve deps from setup.py
    178 all_dependencies.sort(reverse=True)

KeyError: 'dynamo-release'

but it is doesn't prevent using the package:

dynamo.pdf

I report the yml file in case it's useful for anybody:

https://drive.google.com/file/d/1YhaMdFpefc1KcvetZRaOp6J59_OQO1Tr/view?usp=sharing

Hi @xiaozhongshen,

Thanks for using the dynamo package. Regarding the issue you mentioned above, I tested the function and it works well Could you shed some light on how you installed the dynamo package? 1) pip install dynamo-release 2) from source with pip install -e . 3) download github repo and import the dynamo subfolder

In your Yaml file, dynamo-release is not installed, so it is probably the method (3) mentioned above. In this case, the dynamo-release is not installed via pip or conda formally, so get_all_dependencies_version cannot obtain it from the environment and thus won't work. You can install dynamo in your environment by cd to git repo (root directory o f this dynamo repository, containing a dynamo subfolder) and use pip install -e . to install the development version, or any method mentioned on this page.

Please let us know if you encounter any other issues. Thank you.

dummyindex avatar Feb 15 '22 20:02 dummyindex

Hi @Xiaojieqiu

Thanks for your reply. I used:

git clone https://github.com/aristoteleo/dynamo-release.git
cd dynamo-release/
python setup.py install --user

I tried with

pip install -e .

and it worked!

Thanks :-)

Best,

Daniele

DanieleMuraro avatar Feb 16 '22 12:02 DanieleMuraro

Hi @Xiaojieqiu I met the same `AttributeError: 'AnchoredSizeLocator' object has no attribute 'get_subplotspec'' error like @DanieleMuraro. So I re-install dynamo by

git clone https://github.com/aristoteleo/dynamo-release.git
cd dynamo-release/
python setup.py install --user
pip install -e .

but for the last step pip install -e . I encountered below error

WARNING: Ignoring invalid distribution -nndata (c:\programdata\anaconda3\envs\python38\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\envs\python38\lib\site-packages)
WARNING: Ignoring invalid distribution -nndata (c:\programdata\anaconda3\envs\python38\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\envs\python38\lib\site-packages)
Obtaining file:///C:/Users/hyjfo/dynamo-release
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
    Preparing wheel metadata ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\ProgramData\Anaconda3\envs\python38\python.exe' 'c:\programdata\anaconda3\envs\python38\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\hyjfo\AppData\Local\Temp\tmpo38nj747'
         cwd: C:\Users\hyjfo\dynamo-release
    Complete output (26 lines):
    Traceback (most recent call last):
      File "c:\programdata\anaconda3\envs\python38\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 349, in <module>
        main()
      File "c:\programdata\anaconda3\envs\python38\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 331, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "c:\programdata\anaconda3\envs\python38\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 151, in prepare_metadata_for_build_wheel
        return hook(metadata_directory, config_settings)
      File "C:\Users\hyjfo\AppData\Local\Temp\pip-build-env-9j0_fiml\overlay\Lib\site-packages\flit_core\buildapi.py", line 49, in prepare_metadata_for_build_wheel
        metadata = make_metadata(module, ini_info)
      File "C:\Users\hyjfo\AppData\Local\Temp\pip-build-env-9j0_fiml\overlay\Lib\site-packages\flit_core\common.py", line 408, in make_metadata
        md_dict.update(get_info_from_module(module, ini_info.dynamic_metadata))
      File "C:\Users\hyjfo\AppData\Local\Temp\pip-build-env-9j0_fiml\overlay\Lib\site-packages\flit_core\common.py", line 205, in get_info_from_module
        docstring, version = get_docstring_and_version_via_import(target)
      File "C:\Users\hyjfo\AppData\Local\Temp\pip-build-env-9j0_fiml\overlay\Lib\site-packages\flit_core\common.py", line 178, in get_docstring_and_version_via_import
        spec.loader.exec_module(m)
      File "<frozen importlib._bootstrap_external>", line 843, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "C:\Users\hyjfo\dynamo-release\dynamo\__init__.py", line 6, in <module>
        __version__ = get_version(__file__)
      File "C:\Users\hyjfo\dynamo-release\dynamo\get_version.py", line 159, in get_version
        or get_version_from_git(parent)
      File "C:\Users\hyjfo\dynamo-release\dynamo\get_version.py", line 88, in get_version_from_git
        release, dev, hex_, dirty = match_groups(f"{RE_GIT_DESCRIBE}$", p.stdout.rstrip("\r\n"))
      File "C:\Users\hyjfo\dynamo-release\dynamo\get_version.py", line 21, in match_groups
        raise re.error(f"Regex does not match “{target}”. RE Pattern: {regex}", regex)
    re.error: Regex does not match “v1.0.0-594-g84bc4bfe”. RE Pattern: v?(?:([\d.]+)-(\d+)-g)?([0-9a-f]{7})(-dirty)?$
    ----------------------------------------
WARNING: Discarding file:///C:/Users/hyjfo/dynamo-release. Command errored out with exit status 1: 'C:\ProgramData\Anaconda3\envs\python38\python.exe' 'c:\programdata\anaconda3\envs\python38\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\hyjfo\AppData\Local\Temp\tmpo38nj747' Check the logs for full command output.
ERROR: Command errored out with exit status 1: 'C:\ProgramData\Anaconda3\envs\python38\python.exe' 'c:\programdata\anaconda3\envs\python38\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\hyjfo\AppData\Local\Temp\tmpo38nj747' Check the logs for full command output.
WARNING: Ignoring invalid distribution -nndata (c:\programdata\anaconda3\envs\python38\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\envs\python38\lib\site-packages)
WARNING: Ignoring invalid distribution -nndata (c:\programdata\anaconda3\envs\python38\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\envs\python38\lib\site-packages)
WARNING: Ignoring invalid distribution -nndata (c:\programdata\anaconda3\envs\python38\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\envs\python38\lib\site-packages)

hyjforesight avatar Mar 10 '22 19:03 hyjforesight

Hello @hyjforesight, sorry for the confusion but in fact you only need to install the package through python setup.py install --user once. Excuting pip install -e . after it would cause duplicated installation. Meanwhile, using -e flag might prevent pip from using metadata specified in setup.py and cause unexpected problems. If you run into any problems about dependencies when using python setup.py install --user, you could try to run pip install -r requirements.txt in dynamo-release folder and re-execute python setup.py install --user. Thank you so much.

elfofmaxwell avatar Aug 30 '22 14:08 elfofmaxwell

Hello @DanieleMuraro, about the

AttributeError: 'AnchoredSizeLocator' object has no attribute 'get_subplotspe
c'

problem, seemly it is caused by bugs in matplotlib and has been fixed after version 3.5.3. Could you upgrade the package and try again? Thank you so much!

elfofmaxwell avatar Aug 30 '22 15:08 elfofmaxwell