BiomedicalMachineLearning / stLearn

A novel machine learning pipeline to analyse spatial transcriptomics data
Other
190 stars 25 forks source link

st.spatial.trajectory.pseudotimespace_global() #254

Closed onionsci closed 11 months ago

onionsci commented 11 months ago

Hello, I have a confusion. I don't know why the error occurred.

st.spatial.trajectory.pseudotimespace_global(data,use_label="louvain",list_clusters=["1","2","3"]) Start to construct the trajectory: 3 -> 2 -> 1 Traceback (most recent call last): File "", line 1, in File "C:\Users\Administrator\miniconda3\envs\stlearn2\lib\site-packages\stlearn\spatials\trajectory\pseudotimespace.py", line 55, in pseudotimespace_global global_level( File "C:\Users\Administrator\miniconda3\envs\stlearn2\lib\site-packages\stlearn\spatials\trajectory\global_level.py", line 165, in global_level H_sub = nx.algorithms.tree.minimum_spanning_arborescence(H_sub) File "C:\Users\Administrator\miniconda3\envs\stlearn2\lib\site-packages\networkx\utils\backends.py", line 412, in call return self.orig_func(*args, *kwargs) File "C:\Users\Administrator\miniconda3\envs\stlearn2\lib\site-packages\networkx\algorithms\tree\branchings.py", line 1310, in minimum_spanning_arborescence B = minimal_branching( File "C:\Users\Administrator\miniconda3\envs\stlearn2\lib\site-packages\networkx\utils\backends.py", line 412, in call return self.orig_func(args, **kwargs) File "C:\Users\Administrator\miniconda3\envs\stlearn2\lib\site-packages\networkx\algorithms\tree\branchings.py", line 1237, in minimal_branching if w > max_weight: TypeError: '<' not supported between instances of 'float' and 'NoneType' print(data.obs.louvain.cat.categories) Index(['0', '1', '2', '3', '4', '5', '6'], dtype='object') data.uns["louvain_index_dict"] {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6}

duypham2108 commented 11 months ago

Can you check if there is any issue with the adata.obs['sub_cluster_labels']. And also check the global graph here:

from stlearn.utils import _read_graph
G = _read_graph(adata, "global_graph")
print(G.nodes)
print(G.edges)

If you test with 2 clusters, will it run normally?

onionsci commented 11 months ago

Hello, thank you for your response. I tried the methods you provided, but I'm still encountering the following error.

data.obs['sub_cluster_labels'] AAACCTAAGCAGCCGG-1 0 AAACGAGACGGTTGAT-1 1 AAACTGCTGGCTCCAA-1 1 AAAGGCTCTCGCGCCG-1 2 AAAGGGATGTAGCAAG-1 3 .. TTGTGGCCCTGACAGT-1 9 TTGTGTATGCCACCAA-1 42 TTGTGTTTCCCGAAAG-1 11 TTGTTCAGTGTGCTAC-1 9 TTGTTGTGTGTCAAGA-1 9 Name: sub_cluster_labels, Length: 821, dtype: category Categories (43, object): ['0', '1', '2', '3', ..., '39', '40', '41', '42'] from stlearn.utils import _read_graph G = _read_graph(data, "global_graph") print(G.nodes) [0, 1, 2, 3, 4, 5, 21, 11, 9, 8, 15, 7] print(G.edges) [(0, 4), (0, 5), (0, 21), (0, 11), (0, 9), (0, 8), (1, 4), (1, 5), (1, 21), (1, 11), (1, 9), (1, 8), (2, 4), (2, 5), (2, 21), (2, 11), (2, 9), (2, 8), (3, 4), (3, 5), (3, 21), (3, 11), (3, 9), (3, 8), (4, 5), (4, 21), (4, 11), (4, 9), (4, 8), (4, 15), (4, 7), (5, 21), (5, 11), (5, 9), (5, 15), (5, 7), (21, 9), (21, 8), (21, 15), (21, 7), (11, 9), (11, 8), (11, 15), (11, 7), (9, 8), (9, 15), (9, 7), (8, 15), (8, 7)] st.spatial.trajectory.pseudotimespace_global(data,use_label="louvain",list_clusters=["5","3"]) Start to construct the trajectory: 5 -> 3 Traceback (most recent call last): File "", line 1, in File "C:\Users\Administrator\miniconda3\envs\stlearn2\lib\site-packages\stlearn\spatials\trajectory\pseudotimespace.py", line 55, in pseudotimespace_global global_level( File "C:\Users\Administrator\miniconda3\envs\stlearn2\lib\site-packages\stlearn\spatials\trajectory\global_level.py", line 165, in global_level H_sub = nx.algorithms.tree.minimum_spanning_arborescence(H_sub) File "C:\Users\Administrator\miniconda3\envs\stlearn2\lib\site-packages\networkx\utils\backends.py", line 412, in call return self.orig_func(*args, *kwargs) File "C:\Users\Administrator\miniconda3\envs\stlearn2\lib\site-packages\networkx\algorithms\tree\branchings.py", line 1310, in minimum_spanning_arborescence B = minimal_branching( File "C:\Users\Administrator\miniconda3\envs\stlearn2\lib\site-packages\networkx\utils\backends.py", line 412, in call return self.orig_func(args, **kwargs) File "C:\Users\Administrator\miniconda3\envs\stlearn2\lib\site-packages\networkx\algorithms\tree\branchings.py", line 1237, in minimal_branching if w > max_weight: TypeError: '<' not supported between instances of 'float' and 'NoneType' print(data.obs.louvain.cat.categories) Index(['0', '1', '2', '3', '4', '5'], dtype='object')

duypham2108 commented 11 months ago

It seems don't have any issue. Did you recently install the package? I need to test it again due to the new version of anndata and scanpy as the dependencies of stlearn. You can downgrade these packages' versions to see if anything changes. Also I will try to test it soon

onionsci commented 11 months ago

Ok, I have recently started using stlearn , and below are the versions of different packages in my environment. I will also try downgrading anndata and scanpy to resolve the issue, and I look forward to your response.

packages in environment at C:\Users\Administrator\miniconda3\envs\stlearn2:

#

Name Version Build Channel

_tflow_select 2.3.0 mkl absl-py 2.0.0 pyhd8ed1ab_0 conda-forge aiohttp 3.8.5 py39h2bbff1b_0 aiosignal 1.3.1 pyhd8ed1ab_0 conda-forge anndata 0.10.2 pyhd8ed1ab_0 conda-forge aom 3.5.0 h63175ca_0 conda-forge array-api-compat 1.4 pyhd8ed1ab_0 conda-forge asttokens 2.0.5 pyhd3eb1b0_0 astunparse 1.6.3 pyhd8ed1ab_0 conda-forge async-timeout 4.0.3 pyhd8ed1ab_0 conda-forge attrs 23.1.0 pyh71513ae_1 conda-forge backcall 0.2.0 pyhd3eb1b0_0 blinker 1.6.3 pyhd8ed1ab_0 conda-forge blosc 1.21.5 hdccc3a2_0 conda-forge bokeh 3.3.0 pyhd8ed1ab_0 conda-forge brotli 1.0.9 ha925a31_2 brotli-python 1.0.9 py39h99910a6_9 conda-forge bzip2 1.0.8 h8ffe710_4 conda-forge ca-certificates 2023.08.22 haa95532_0 cached-property 1.5.2 hd8ed1ab_1 conda-forge cached_property 1.5.2 pyha770c72_1 conda-forge cachetools 5.3.1 pyhd8ed1ab_0 conda-forge certifi 2023.7.22 py39haa95532_0 cffi 1.16.0 py39ha55989b_0 conda-forge cfitsio 3.470 h2bbff1b_7 charls 2.2.0 h6c2663c_0 charset-normalizer 3.3.1 pyhd8ed1ab_0 conda-forge click 8.1.7 win_pyh7428d3b_0 conda-forge cloudpickle 3.0.0 pyhd8ed1ab_0 conda-forge colorama 0.4.6 pyhd8ed1ab_0 conda-forge contourpy 1.1.1 py39h1f6ef14_1 conda-forge cryptography 38.0.4 py39h58e9bdb_0 conda-forge cycler 0.12.1 pyhd8ed1ab_0 conda-forge cytoolz 0.12.2 py39ha55989b_1 conda-forge dask-core 2023.10.0 pyhd8ed1ab_0 conda-forge dav1d 1.2.1 hcfcfb64_0 conda-forge decorator 5.1.1 pyhd3eb1b0_0 exceptiongroup 1.1.3 pyhd8ed1ab_0 conda-forge executing 0.8.3 pyhd3eb1b0_0 flatbuffers 23.5.26 h63175ca_1 conda-forge fonttools 4.43.1 py39ha55989b_0 conda-forge freetype 2.12.1 hdaf720e_2 conda-forge frozenlist 1.4.0 py39ha55989b_1 conda-forge fsspec 2023.10.0 pyhca7485f_0 conda-forge gast 0.4.0 pyh9f0ad1d_0 conda-forge giflib 5.2.1 h64bf75a_3 conda-forge glpk 5.0 h8ffe710_0 conda-forge google-auth 2.23.3 pyhca7485f_0 conda-forge google-auth-oauthlib 0.4.1 py_2 conda-forge google-pasta 0.2.0 pyh8c360ce_0 conda-forge grpcio 1.42.0 py39hc60d5dd_0 h5py 3.9.0 nompi_py39h9c8e182_100 conda-forge hdf5 1.14.0 nompi_h97a5375_103 conda-forge icu 58.2 ha925a31_3 idna 3.4 pyhd8ed1ab_0 conda-forge igraph 0.10.7 h0e101eb_1 conda-forge imagecodecs 2023.1.23 py39h6c6a46e_0 imageio 2.31.5 pyh8c1a49c_0 conda-forge importlib-metadata 6.8.0 pyha770c72_0 conda-forge importlib-resources 6.1.0 pypi_0 pypi importlib_metadata 6.8.0 hd8ed1ab_0 conda-forge intel-openmp 2023.2.0 h57928b3_50496 conda-forge jedi 0.18.1 py39haa95532_1 jinja2 3.1.2 pyhd8ed1ab_1 conda-forge joblib 1.3.2 pyhd8ed1ab_0 conda-forge jpeg 9e hcfcfb64_3 conda-forge keras 2.10.0 py39haa95532_0 keras-preprocessing 1.1.2 pyhd8ed1ab_0 conda-forge kiwisolver 1.4.5 py39h1f6ef14_1 conda-forge krb5 1.20.1 h6609f42_0 conda-forge lazy_loader 0.3 pyhd8ed1ab_0 conda-forge lcms2 2.15 ha5c8aab_0 conda-forge leidenalg 0.10.1 py39haa4e2bd_0 conda-forge lerc 3.0 hd77b12b_0 libaec 1.1.2 h63175ca_1 conda-forge libavif 0.11.1 ha7b97ba_2 conda-forge libblas 3.9.0 19_win64_mkl conda-forge libbrotlicommon 1.0.9 hcfcfb64_9 conda-forge libbrotlidec 1.0.9 hcfcfb64_9 conda-forge libbrotlienc 1.0.9 hcfcfb64_9 conda-forge libcblas 3.9.0 19_win64_mkl conda-forge libcurl 7.88.1 h68f0423_1 conda-forge libdeflate 1.17 h2bbff1b_1 libhwloc 2.9.3 default_haede6df_1009 conda-forge libiconv 1.17 h8ffe710_0 conda-forge liblapack 3.9.0 19_win64_mkl conda-forge libleidenalg 0.11.1 h91493d7_0 conda-forge libpng 1.6.39 h19919ed_0 conda-forge libprotobuf 3.20.3 h12be248_0 conda-forge libssh2 1.10.0 hcd4344a_2 libtiff 4.5.1 hd77b12b_0 libwebp 1.3.2 hcfcfb64_1 conda-forge libwebp-base 1.3.2 hcfcfb64_0 conda-forge libxml2 2.11.5 hc3477c8_1 conda-forge libzlib 1.2.13 hcfcfb64_5 conda-forge libzopfli 1.0.3 h0e60522_0 conda-forge llvmlite 0.40.1 py39hd28a505_0 conda-forge locket 1.0.0 pyhd8ed1ab_0 conda-forge louvain 0.8.1 py39haa4e2bd_0 conda-forge lz4-c 1.9.4 hcfcfb64_0 conda-forge m2w64-gcc-libgfortran 5.3.0 6 conda-forge m2w64-gcc-libs 5.3.0 7 conda-forge m2w64-gcc-libs-core 5.3.0 7 conda-forge m2w64-gmp 6.1.0 2 conda-forge m2w64-libwinpthread-git 5.0.0.4634.697f757 2 conda-forge markdown 3.5 pyhd8ed1ab_0 conda-forge markupsafe 2.1.3 py39ha55989b_1 conda-forge matplotlib 3.5.3 pypi_0 pypi matplotlib-inline 0.1.6 py39haa95532_0 mkl 2023.2.0 h6a75c08_50496 conda-forge mpir 3.0.0 he025d50_1002 conda-forge msys2-conda-epoch 20160418 1 conda-forge multidict 6.0.4 py39ha55989b_1 conda-forge munkres 1.1.4 pyh9f0ad1d_0 conda-forge natsort 8.4.0 pyhd8ed1ab_0 conda-forge networkx 3.2 pyhd8ed1ab_0 conda-forge numba 0.57.1 py39hadaa1c4_0 conda-forge numpy 1.21.6 py39h6331f09_0 conda-forge oauthlib 3.2.2 pyhd8ed1ab_0 conda-forge openjpeg 2.5.0 ha2aaf27_2 conda-forge openssl 1.1.1w h2bbff1b_0 opt_einsum 3.3.0 pyhc1e730c_2 conda-forge packaging 23.2 pyhd8ed1ab_0 conda-forge pandas 2.0.3 py39h1679cfb_1 conda-forge parso 0.8.3 pyhd3eb1b0_0 partd 1.4.1 pyhd8ed1ab_0 conda-forge patsy 0.5.3 pyhd8ed1ab_0 conda-forge pickleshare 0.7.5 pyhd3eb1b0_1003 pillow 10.0.1 py39h045eedc_0 pip 23.3 py39haa95532_0 prompt-toolkit 3.0.36 py39haa95532_0 protobuf 3.20.3 py39hcbf5309_1 conda-forge pthreads-win32 2.9.1 hfa6e2cd_3 conda-forge pure_eval 0.2.2 pyhd3eb1b0_0 pyasn1 0.5.0 pyhd8ed1ab_0 conda-forge pyasn1-modules 0.3.0 pyhd8ed1ab_0 conda-forge pycparser 2.21 pyhd8ed1ab_0 conda-forge pygments 2.15.1 py39haa95532_1 pyjwt 2.8.0 pyhd8ed1ab_0 conda-forge pynndescent 0.5.10 pyh1a96a4e_0 conda-forge pyopenssl 23.2.0 pyhd8ed1ab_1 conda-forge pyparsing 3.1.1 pyhd8ed1ab_0 conda-forge pysocks 1.7.1 pyh0701188_6 conda-forge python 3.9.18 h6244533_0 python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge python-flatbuffers 23.5.26 pyhd8ed1ab_0 conda-forge python-igraph 0.11.2 py39he170af6_0 conda-forge python-tzdata 2023.3 pyhd8ed1ab_0 conda-forge python_abi 3.9 2_cp39 conda-forge pytz 2023.3.post1 pyhd8ed1ab_0 conda-forge pyu2f 0.1.5 pyhd8ed1ab_0 conda-forge pywavelets 1.4.1 py39hc266a54_0 conda-forge pyyaml 6.0.1 py39ha55989b_1 conda-forge requests 2.31.0 pyhd8ed1ab_0 conda-forge requests-oauthlib 1.3.1 pyhd8ed1ab_0 conda-forge rsa 4.9 pyhd8ed1ab_0 conda-forge scanpy 1.9.5 pyhd8ed1ab_0 conda-forge scikit-image 0.20.0 py39h3513d60_0 scikit-learn 1.2.2 py39hfa9d973_2 conda-forge scipy 1.8.1 py39hfbf2dce_3 conda-forge seaborn 0.13.0 hd8ed1ab_0 conda-forge seaborn-base 0.13.0 pyhd8ed1ab_0 conda-forge session-info 1.0.0 pyhd8ed1ab_0 conda-forge setuptools 68.0.0 py39haa95532_0 six 1.16.0 pyh6c4a22f_0 conda-forge snappy 1.1.10 hfb803bf_0 conda-forge sqlite 3.41.2 h2bbff1b_0 stack_data 0.2.0 pyhd3eb1b0_0 statsmodels 0.14.0 py39hbaa61f9_1 conda-forge stdlib-list 0.8.0 pyhd8ed1ab_0 conda-forge stlearn 0.4.12 pyhd8ed1ab_0 conda-forge tbb 2021.10.0 h91493d7_2 conda-forge tensorboard 2.10.0 py39haa95532_0 tensorboard-data-server 0.6.1 py39haa95532_0 tensorboard-plugin-wit 1.8.1 pyhd8ed1ab_0 conda-forge tensorflow 2.10.0 mkl_py39ha510bab_0 tensorflow-base 2.10.0 mkl_py39h6a7f48e_0 tensorflow-estimator 2.10.0 py39haa95532_0 termcolor 2.3.0 pyhd8ed1ab_0 conda-forge texttable 1.7.0 pyhd8ed1ab_0 conda-forge threadpoolctl 3.2.0 pyha21a80b_0 conda-forge tifffile 2023.4.12 pyhd8ed1ab_0 conda-forge tk 8.6.13 hcfcfb64_0 conda-forge toolz 0.12.0 pyhd8ed1ab_0 conda-forge tornado 6.3.3 py39ha55989b_1 conda-forge tqdm 4.66.1 pyhd8ed1ab_0 conda-forge traitlets 5.7.1 py39haa95532_0 typing-extensions 4.8.0 hd8ed1ab_0 conda-forge typing_extensions 4.8.0 pyha770c72_0 conda-forge tzdata 2023c h04d1e81_0 ucrt 10.0.22621.0 h57928b3_0 conda-forge umap-learn 0.5.4 py39hcbf5309_0 conda-forge unicodedata2 15.1.0 py39ha55989b_0 conda-forge urllib3 2.0.7 pyhd8ed1ab_0 conda-forge vc 14.2 h21ff451_1 vc14_runtime 14.36.32532 hdcecf7f_17 conda-forge vs2015_runtime 14.36.32532 h05e6639_17 conda-forge wcwidth 0.2.5 pyhd3eb1b0_0 werkzeug 3.0.0 pyhd8ed1ab_0 conda-forge wheel 0.41.2 py39haa95532_0 win_inet_pton 1.1.0 pyhd8ed1ab_6 conda-forge wrapt 1.15.0 py39ha55989b_1 conda-forge xyzservices 2023.10.0 pyhd8ed1ab_0 conda-forge xz 5.4.2 h8cc25b3_0 yaml 0.2.5 h8ffe710_2 conda-forge yarl 1.9.2 py39ha55989b_1 conda-forge zfp 1.0.0 h63175ca_4 conda-forge zipp 3.17.0 pyhd8ed1ab_0 conda-forge zlib 1.2.13 hcfcfb64_5 conda-forge zstd 1.5.5 h12be248_0 conda-forge

yandouwahhh commented 11 months ago

Hi, I also have the same error when running this step, may I ask if you have solved it

duypham2108 commented 11 months ago

This is the python 3.10 issue with the type. I will try to solve it soon. But one quick solution now is using python3.8

duypham2108 commented 11 months ago

I just updated the master branch of the repo. Please uninstall the old version and install with the master branch. I will try to publish a new version soon on the next few days

yandouwahhh commented 11 months ago

Many thanks for your replying.

onionsci commented 11 months ago

I just updated the master branch of the repo. Please uninstall the old version and install with the master branch. I will try to publish a new version soon on the next few days

Thank you for your positive reply and look forward to your update.