Starlitnightly / omicverse

A python library for multi omics included bulk, single cell and spatial RNA-seq analysis.
https://starlitnightly.github.io/omicverse/
GNU General Public License v3.0
431 stars 45 forks source link

Error for ov.utils.cal_paga and ov.single.pyVIA #86

Closed looppy95 closed 3 months ago

looppy95 commented 4 months ago

Thank you for developing OmicVerse. I am currently experiencing some issues: When I run: Trajectory Inference with PAGA or Palantir this part of the ov.utils.cal_paga code, ov.utils.cal_paga(adata,use_time_prior=‘dpt_pseudotime’,vkey=‘paga’, groups=‘clusters’) and ov.utils.cal_paga (adata,use_time_prior=‘palantir_pseudotime’,vkey=‘paga’, groups=‘clusters’) and ov.utils.cal_paga(adata,use_time_prior=‘slingshot_pseudotime’,vkey=‘paga’, groups=‘clusters’) and ov.single.pyVIA (adata=adata,adata_key='X_pca',adata_ncomps=80, basis='X_umap', clusters='clusters',knn=30,random_seed=4,root_user=[4823],)


ValueError Traceback (most recent call last) Cell In[16], line 1 ----> 1 ov.utils.cal_paga(adata,use_time_prior='dpt_pseudotime',vkey='paga', 2 groups='clusters')

File ~/miniconda3/envs/omicverse/lib/python3.10/site-packages/omicverse/utils/_paga.py:293, in cal_paga(adata, groups, vkey, use_time_prior, root_key, end_key, threshold_root_end_prior, minimum_spanning_tree, copy) 290 adata.uns["paga"]["connectivities_tree"] = paga.connectivities_tree 291 adata.uns[f"{groups}_sizes"] = np.array(paga.ns) --> 293 paga.compute_transitions() 294 adata.uns["paga"]["transitions_confidence"] = paga.transitions_confidence 295 adata.uns["paga"]["threshold"] = paga.threshold

File ~/miniconda3/envs/omicverse/lib/python3.10/site-packages/omicverse/utils/_paga.py:83, in PAGA_tree.compute_transitions(self) 81 vc = igraph.VertexClustering(g, membership=membership) 82 cg_full = vc.cluster_graph(combine_edges="sum") ---> 83 transitions = get_sparse_from_igraph(cg_full, weight_attr="weight") 84 transitions = transitions - transitions.T 85 transitions_conf = transitions.copy()

File ~/miniconda3/envs/omicverse/lib/python3.10/site-packages/omicverse/utils/_paga.py:189, in get_sparse_from_igraph(graph, weight_attr) 187 shape = (shape, shape) 188 if len(edges) > 0: --> 189 return csr_matrix((weights, zip(*edges)), shape=shape) 190 else: 191 return csr_matrix(shape)

File ~/miniconda3/envs/omicverse/lib/python3.10/site-packages/scipy/sparse/_compressed.py:55, in _cs_matrix.init(self, arg1, shape, dtype, copy) 52 else: 53 if len(arg1) == 2: 54 # (data, ij) format ---> 55 coo = self._coo_container(arg1, shape=shape, dtype=dtype) 56 arrays = coo._coo_to_compressed(self._swap) 57 self.indptr, self.indices, self.data, self._shape = arrays

File ~/miniconda3/envs/omicverse/lib/python3.10/site-packages/scipy/sparse/_coo.py:99, in _coo_base.init(self, arg1, shape, dtype, copy) 96 if dtype is not None: 97 self.data = self.data.astype(dtype, copy=False) ---> 99 self._check()

File ~/miniconda3/envs/omicverse/lib/python3.10/site-packages/scipy/sparse/_coo.py:188, in _coo_base._check(self) 186 """ Checks data structure for consistency """ 187 if self.ndim != len(self.coords): --> 188 raise ValueError('mismatching number of index arrays for shape; ' 189 f'got {len(self.coords)}, expected {self.ndim}') 191 # index arrays should have integer data types 192 for i, idx in enumerate(self.coords):

ValueError: mismatching number of index arrays for shape; got 0, expected 2

Starlitnightly commented 4 months ago

Can you provide more detailed information about the version? Including scipy version, omicverse version, and data types for adata.X

looppy95 commented 4 months ago

Thank you for your response. I am using sample data.

AnnData object with n_obs × n_vars = 2930 × 3000 obs: 'clusters', 'age(days)', 'clusters_enlarged', 'dpt_pseudotime' var: 'n_cells', 'percent_cells', 'robust', 'mean', 'var', 'residual_variances', 'highly_variable_rank', 'highly_variable_features' uns: 'clusters_colors', 'log1p', 'hvg', 'scaled|original|pca_var_ratios', 'scaled|original|cum_sum_eigenvalues', 'neighbors', 'diffmap_evals', 'draw_graph', 'iroot' obsm: 'X_umap', 'scaled|original|X_pca', 'X_diffmap', 'X_draw_graph_fa' varm: 'scaled|original|pca_loadings' layers: 'ambiguous', 'spliced', 'unspliced', 'counts', 'scaled', 'lognorm' obsp: 'distances', 'connectivities'

Package Version


absl-py 2.1.0 adjustText 1.1.1 aiohttp 3.9.5 aiosignal 1.2.0 anndata 0.10.7 annotated-types 0.7.0 anyio 4.3.0 array_api_compat 1.7.1 arrow 1.3.0 ase 3.23.0 astor 0.8.1 asttokens 2.4.1 async-timeout 4.0.3 attrs 23.1.0 autograd 1.6.2 autograd-gamma 0.5.0 backoff 2.2.1 beautifulsoup4 4.12.3 blessed 1.20.0 blinker 1.8.2 boltons 24.0.0 boto3 1.34.117 botocore 1.34.117 Brotli 1.0.9 build 1.2.1 CacheControl 0.14.0 cached-property 1.5.2 captum 0.6.0 certifi 2024.2.2 cffi 1.16.0 charset-normalizer 2.0.4 chex 0.1.86 cleo 2.1.0 click 8.1.7 cloudpickle 3.0.0 colorama 0.4.6 colorcet 3.1.0 comm 0.2.2 contextlib2 21.6.0 contourpy 1.2.1 crashtest 0.4.1 croniter 1.4.1 cryptography 42.0.7 cycler 0.12.1 Cython 3.0.10 cytoolz 0.12.3 dask 2024.5.2 datashader 0.16.2 dateutils 0.6.12 debugpy 1.6.7 decorator 5.1.1 deepdiff 7.0.1 dill 0.3.8 distlib 0.3.8 dm-tree 0.1.8 dnspython 2.6.1 docrep 0.3.2 dulwich 0.21.7 einops 0.8.0 email_validator 2.1.1 et-xmlfile 1.1.0 exceptiongroup 1.2.0 executing 2.0.1 fa2 0.3.5 fa2_modified 0.3.10 fastapi 0.111.0 fastapi-cli 0.0.4 fastjsonschema 2.19.1 filelock 3.13.1 Flask 3.0.3 flax 0.6.1 fonttools 4.53.0 formulaic 1.0.1 frozenlist 1.4.0 fsspec 2024.3.1 future 1.0.0 gdown 5.2.0 get-annotations 0.1.2 gmpy2 2.1.2 graphlib-backport 1.0.3 grpcio 1.56.2 h11 0.14.0 h2 4.1.0 h5py 3.11.0 hnswlib 0.7.0 hpack 4.0.0 httpcore 1.0.5 httpx 0.27.0 hyperframe 6.0.1 idna 3.7 igraph 0.11.5 imagecodecs-lite 2019.12.3 imageio 2.34.1 importlib_metadata 7.1.0 inquirer 3.1.4 installer 0.7.0 interface-meta 1.3.0 ipykernel 6.28.0 ipython 8.25.0 ipywidgets 8.1.3 isodate 0.6.1 itsdangerous 2.2.0 jaraco.classes 3.4.0 jax 0.4.28 jaxlib 0.4.28 jaxopt 0.8.3 jedi 0.19.1 jeepney 0.8.0 Jinja2 3.1.4 jmespath 1.0.1 joblib 1.4.0 jupyter_client 8.6.0 jupyter_core 5.5.0 jupyterlab_widgets 3.0.11 keyring 24.3.1 kiwisolver 1.4.5 lazy_loader 0.4 legacy-api-wrap 1.4 leidenalg 0.10.2 lifelines 0.27.8 lightning 2.0.9.post0 lightning_cloud 0.5.69 lightning-utilities 0.11.2 llvmlite 0.42.0 locket 1.0.0 loompy 3.0.7 Markdown 3.6 markdown-it-py 3.0.0 MarkupSafe 2.1.3 matplotlib 3.6.2 matplotlib-inline 0.1.7 mdurl 0.1.2 mellon 1.4.2 mkl-fft 1.3.8 mkl-random 1.2.4 mkl-service 2.4.0 ml-collections 0.1.1 ml-dtypes 0.4.0 more-itertools 10.2.0 mpmath 1.3.0 msgpack 1.0.8 mudata 0.2.3 multidict 6.0.4 multipledispatch 0.6.0 multiprocess 0.70.16 munkres 1.1.4 natsort 8.4.0 nest-asyncio 1.6.0 networkx 3.1 numba 0.59.1 numpy 1.26.4 numpy-groupies 0.11.1 numpyro 0.13.2 omicverse 1.5.9 openpyxl 3.1.2 opt-einsum 3.3.0 optax 0.2.2 ordered-set 4.1.0 orjson 3.10.3 packaging 24.0 pandas 1.5.3 param 2.1.0 parso 0.8.4 partd 1.4.2 patsy 0.5.6 pexpect 4.9.0 pickleshare 0.7.5 Pillow 9.4.0 pip 24.0 pkginfo 1.10.0 platformdirs 4.2.2 ply 3.11 poetry 1.8.3 poetry-core 1.9.0 poetry-plugin-export 1.8.0 progressbar2 4.4.2 prompt-toolkit 3.0.43 protobuf 4.23.3 psutil 5.9.0 ptyprocess 0.7.0 pure-eval 0.2.2 pycparser 2.22 pyct 0.5.0 pydantic 2.1.1 pydantic_core 2.4.0 pygam 0.9.1 Pygments 2.18.0 PyJWT 2.8.0 pynndescent 0.5.12 pyparsing 3.0.9 pyproject_hooks 1.1.0 PyQt5 5.15.10 PyQt5-sip 12.13.0 pyro-api 0.1.2 pyro-ppl 1.9.0+f02dfb9 PySocks 1.7.1 python-dateutil 2.9.0.post0 python-editor 1.0.4 python-multipart 0.0.9 python-utils 3.8.2 pytorch-lightning 2.2.2 pytz 2024.1 pywavelets 1.5.0 PyYAML 6.0.1 pyzmq 25.1.2 rapidfuzz 3.9.3 rdflib 7.0.0 readchar 4.1.0.dev3 requests 2.32.2 requests-toolbelt 1.0.0 rich 13.7.1 s3transfer 0.10.1 scanpy 1.10.1 scikit-image 0.20.0 scikit-learn 1.4.2 scikit-misc 0.1.4 scipy 1.13.0 scvelo 0.3.2 scvi-tools 1.1.2 seaborn 0.13.2 SecretStorage 3.3.3 session-info 1.0.0 setuptools 69.5.1 shellingham 1.5.4 sip 6.7.12 six 1.16.0 sniffio 1.3.1 soupsieve 2.5 sparse 0.15.4 stack-data 0.6.2 starlette 0.37.2 starsessions 1.3.0 statsmodels 0.14.2 stdlib-list 0.10.0 sympy 1.12 tensorboard 2.16.2 tensorboard-data-server 0.7.0 termcolor 2.4.0 texttable 1.7.0 threadpoolctl 3.5.0 tifffile 2020.6.3 tomli 2.0.1 tomlkit 0.12.5 toolz 0.12.1 torch 2.2.2 torch_geometric 2.5.2 torchaudio 2.2.2 torchmetrics 1.4.0.post0 torchvision 0.15.2a0 tornado 6.3.3 tqdm 4.66.4 traitlets 5.14.3 trimesh 4.4.0 trove-classifiers 2024.5.22 typer 0.12.3 typer-slim 0.12.3 types-python-dateutil 2.9.0.20240316 typing_extensions 4.11.0 ujson 5.10.0 umap-learn 0.5.5 unicodedata2 15.1.0 urllib3 2.2.1 uvicorn 0.30.0 virtualenv 20.26.2 wcwidth 0.2.13 websocket-client 1.8.0 websockets 12.0 Werkzeug 3.0.3 wheel 0.43.0 widgetsnbextension 4.0.11 wrapt 1.16.0 xarray 2024.3.0 xlrd 1.2.0 yarl 1.9.3 zipp 3.17.0

Starlitnightly commented 4 months ago

When installing dependencies, omicverse requires ‘scipy>=1.8, <1.12’ in pyproject.toml. How did you manage to install to scipy==1.13, is there any function of the package that scipy must be at 1.13 to run? If so can you conveniently let me know?

Starlitnightly commented 4 months ago

In my environment, scipy is version 1.10, I hope this helps. As for what 1.13 changed, I'll go further and test it in future releases

looppy95 commented 4 months ago

When installing dependencies, omicverse requires ‘scipy>=1.8, <1.12’ in pyproject.toml. How did you manage to install to scipy==1.13, is there any function of the package that scipy must be at 1.13 to run? If so can you conveniently let me know?

Hello, I followed the tutorial to reinstall: conda create -n omicverse python=3.10 conda activate omicverse (CPU only) conda install pytorch torchvision torchaudio cpuonly -c pytorch

The issue arises at this step: conda install pyg -c pyg It installs scipy==1.13. 微信图片_20240603121032

Then I continued to install: conda install omicverse -c conda-forge The installation of omicverse was successful. Running import omicverse as ov was successful.

After I installed pip install scipy==1.10, an error occurred. 微信图片_20240603123540 I proceeded to manually install as per the version requirements. Then I continued installing pip install -U scvelo within the omicverse environment, which installed scvelo (version 0.3.2). However, upon importing scvelo, I encountered an AttributeError: module 'chex' has no attribute 'warn_deprecated_function'. I had to repeatedly install various versions of optax, jax, and jaxlib until I eventually succeeded. My versions are as follows: scipy 1.10.0, jax 0.4.27, jaxlib 0.4.27, and optax 0.1.2.

Following up: ov.utils.cal_paga and ov.single.pyVIA are functioning normally, but there is an issue with v0.plot_trajectory_gams due to incompatibility with numpy-1.23.5 and chex 0.1.86. I am currently trying to resolve this problem, anyway, I greatly appreciate the development of OmicVerse; it has allowed me to successfully obtain usable Trajectory Inference.

Starlitnightly commented 4 months ago

@looppy95 , You can use pip uninstall omicverse -y; pip install -U omicverse to install all dependency.

Zehua