theislab / scvelo

RNA Velocity generalized through dynamical modeling
https://scvelo.org
BSD 3-Clause "New" or "Revised" License
410 stars 102 forks source link

another unknown error related to velocity_pseudotime analysis #166

Closed ziyangliu93 closed 4 years ago

ziyangliu93 commented 4 years ago

I have installed the latest release of scVelo (version 0.1.26) and I followed the tutorials to computed pseudotime, after I ran scv.tl.velocity_pseudotime(adata), an error pop up as the following:

'>=' not supported between instances of 'list' and 'int'

Is it a bug or I just miss some steps.

Also, is there a convenient way to specify root cells and can I set a group of cells or just one cell as the root.

VolkerBergen commented 4 years ago

Please send the whole error msg so that I can comprehend where the error comes from.

VolkerBergen commented 4 years ago

You can pass root cells as root='root_cells' if it is in .obs, or an array or pass an integer index.

ziyangliu93 commented 4 years ago

Thank you for your kindness and patience, the error message when performing velocity_pseudotime analysis was as follows:

TypeError Traceback (most recent call last)

in ----> 1 scv.tl.velocity_pseudotime(scmerge) /usr/local/lib/python3.7/site-packages/scvelo/tools/velocity_pseudotime.py in velocity_pseudotime(adata, vkey, groupby, groups, root, end, n_dcs, use_velocity_graph, save_diffmap, return_model, **kwargs) 174 data = adata.copy() if cell_subset is None else adata[cell_subset].copy() 175 if 'allow_kendall_tau_shift' not in kwargs: kwargs['allow_kendall_tau_shift'] = True --> 176 vpt = VPT(data, n_dcs=n_dcs, **kwargs) 177 178 if use_velocity_graph: /usr/local/lib/python3.7/site-packages/scanpy/tools/_dpt.py in __init__(self, adata, n_dcs, min_group_size, n_branchings, allow_kendall_tau_shift) 171 def __init__(self, adata, n_dcs=None, min_group_size=0.01, 172 n_branchings=0, allow_kendall_tau_shift=False): --> 173 super(DPT, self).__init__(adata, n_dcs=n_dcs) 174 self.flavor = 'haghverdi16' 175 self.n_branchings = n_branchings /usr/local/lib/python3.7/site-packages/scanpy/neighbors/__init__.py in __init__(self, adata, n_dcs) 492 def __init__(self, adata: AnnData, n_dcs: Optional[int] = None): 493 self._adata = adata --> 494 self._init_iroot() 495 # use the graph in adata 496 info_str = '' /usr/local/lib/python3.7/site-packages/scanpy/neighbors/__init__.py in _init_iroot(self) 891 # set iroot directly 892 if 'iroot' in self._adata.uns: --> 893 if self._adata.uns['iroot'] >= self._adata.n_obs: 894 logg.warning( 895 f'Root cell index {self._adata.uns["iroot"]} does not ' TypeError: '>=' not supported between instances of 'list' and 'int'
VolkerBergen commented 4 years ago

In adata.uns['iroot'] an integer index should be stored (e.g. 7), not an array. If you want to pass an array, you can either directly pass it, or have it in .obs.