theislab / cellrank

CellRank: dynamics from multi-view single-cell data
https://cellrank.org
BSD 3-Clause "New" or "Revised" License
344 stars 46 forks source link

ValueError: Encountered NaN values in pseudotime.when follow the CellRank beyond RNA velocity. #1041

Closed fanjiacheng-max closed 1 year ago

fanjiacheng-max commented 1 year ago
ValueError                                Traceback (most recent call last)
Input In [185], in <cell line: 3>()
      1 from cellrank.tl.kernels import CytoTRACEKernel
----> 3 ctk = CytoTRACEKernel(bdata).compute_cytotrace()

File ~/anaconda3/lib/python3.8/site-packages/cellrank/tl/kernels/_cytotrace_kernel.py:95, in CytoTRACEKernel.__init__(self, adata, backward, layer, aggregation, use_raw, compute_cond_num, check_connectivity, **kwargs)
     82 def __init__(
     83     self,
     84     adata: AnnData,
   (...)
     93     **kwargs: Any,
     94 ):
---> 95     super().__init__(
     96         adata,
     97         backward=backward,
     98         time_key=Key.cytotrace("pseudotime"),
     99         compute_cond_num=compute_cond_num,
    100         check_connectivity=check_connectivity,
    101         layer=layer,
    102         aggregation=aggregation,
    103         use_raw=use_raw,
    104         **kwargs,
    105     )
    106     self._time_key = Key.cytotrace("pseudotime")

File ~/anaconda3/lib/python3.8/site-packages/cellrank/tl/kernels/_pseudotime_kernel.py:58, in PseudotimeKernel.__init__(self, adata, backward, time_key, compute_cond_num, check_connectivity, **kwargs)
     49 def __init__(
     50     self,
     51     adata: AnnData,
   (...)
     56     **kwargs: Any,
     57 ):
---> 58     super().__init__(
     59         adata,
     60         backward=backward,
     61         time_key=time_key,
     62         compute_cond_num=compute_cond_num,
     63         check_connectivity=check_connectivity,
     64         **kwargs,
     65     )
     66     self._time_key = time_key

File ~/anaconda3/lib/python3.8/site-packages/cellrank/tl/kernels/_base_kernel.py:965, in Kernel.__init__(self, adata, backward, compute_cond_num, check_connectivity, **kwargs)
    954 def __init__(
    955     self,
    956     adata: AnnData,
   (...)
    960     **kwargs: Any,
    961 ):
    962     super().__init__(
    963         adata, backward, op_name=None, compute_cond_num=compute_cond_num, **kwargs
    964     )
--> 965     self._read_from_adata(check_connectivity=check_connectivity, **kwargs)

File ~/anaconda3/lib/python3.8/site-packages/cellrank/tl/kernels/_cytotrace_kernel.py:120, in CytoTRACEKernel._read_from_adata(self, time_key, layer, aggregation, use_raw, **kwargs)
    108 def _read_from_adata(
    109     self,
    110     time_key: str,
   (...)
    116     **kwargs: Any,
    117 ) -> None:
    118     self.compute_cytotrace(layer=layer, aggregation=aggregation, use_raw=use_raw)
--> 120     super()._read_from_adata(time_key=time_key, **kwargs)

File ~/anaconda3/lib/python3.8/site-packages/cellrank/tl/kernels/_pseudotime_kernel.py:79, in PseudotimeKernel._read_from_adata(self, time_key, **kwargs)
     76     self._pseudotime = np.max(self.pseudotime) - self.pseudotime
     78 if np.any(np.isnan(self._pseudotime)):
---> 79     raise ValueError("Encountered NaN values in pseudotime.")

ValueError: Encountered NaN values in pseudotime.

i want to know how to update my version 1.5.1 to '1.5.1+g49dbd8fd’

fanjiacheng-max commented 1 year ago

@michalk8

michalk8 commented 1 year ago

Hey @fanjiacheng-max , can you please run import cellrank as cr; print(cr.__full_version)?

fanjiacheng-max commented 1 year ago

@michalk8 --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Input In [191], in <cell line: 1>() ----> 1 print(cr.__full_version)

AttributeError: module 'cellrank' has no attribute '__full_version'

michalk8 commented 1 year ago

Sorry for the typo, meant import cellrank as cr; print(cr.__full_version__).

fanjiacheng-max commented 1 year ago

@michalk8 1.5.1

michalk8 commented 1 year ago

Can you try please installing the latest updates as pip install git+https://github.com/theislab/cellrank? There will be a 2.0 release shortly and I think I fixed some bugs in this kernel (would need to look the PR up).

ktpolanski commented 1 year ago

Can confirm that installing the package from GitHub has resolved the NaN issue.

As the code base seems to be a bit different relative to the tutorial for now, this was the required syntax at the time of writing:

from cellrank.kernels import CytoTRACEKernel

ctk = CytoTRACEKernel(adata)
ctk.compute_cytotrace()
Marius1311 commented 1 year ago

Amazing! Thanks for the feedback @ktpolanski. Closing this, and updated version of the tutorial can be found here: https://cellrank.readthedocs.io/en/latest/notebooks/tutorials/kernels/400_cytotrace.html