Closed le-ander closed 4 years ago
With scv.get_df(adata, 'fit_diff_kinetics')
you obtain the clusters that display a diff. kinetic.
What do you get from
from scvelo.plotting.utils import groups_to_bool
groups_to_bool(adata, 'cluster_that_displays_diff_kinetic', 'louvain')
so with this command: scv.get_df(adata, 'fit_diff_kinetics')
, I see that there a couple of genes with differential kinetics in the dorsal neurons cluster.
groups_to_bool(adata, 'Dorsal Neurons', 'louvain')
gives:
array(['Dorsal Neurons'], dtype='<U14')
When I try to sum this, I get the exact error as above.
When I plug in the correct obs col name of my louvain groups:
groups_to_bool(adata, 'Dorsal Neurons', 'louvain_separate_fine')
gives:
array([False, False, False, ..., False, False, False])
Which can be used as input to np.sum without errors.
Solved it.
I need to specify the argument color='louvain_separate_fine'
when calling sc.pl.scatter.
If feasible it might be nice to provide a more informative error here I guess :)
But can be closed otherwise.
Hm, not quite sure if this one is directly related (apologies for posting it here if not):
When I want to recompute velocities with taking differential kinetics into account, the function expects a obs_column called 'clusters' which is not there in my adata:
scv.tl.velocity(adata, mode='dynamical', min_likelihood=.08, diff_kinetics=True)
computing velocities
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-29-89b3e97a629c> in <module>
----> 1 scv.tl.velocity(adata, mode='dynamical', min_likelihood=.08, diff_kinetics=True, groups_for_fit='louvain_separate_fine')
2 scv.tl.velocity_graph(adata)
~/.local/lib/python3.7/site-packages/scvelo/tools/velocity.py in velocity(data, vkey, mode, fit_offset, fit_offset2, filter_genes, groups, groupby, groups_for_fit, constrain_ratio, use_raw, use_latent_time, perc, min_r2, min_likelihood, r2_adjusted, diff_kinetics, copy, **kwargs)
280 if not isinstance(diff_kinetics, str): diff_kinetics = 'fit_diff_kinetics'
281 if diff_kinetics in adata.var.keys():
--> 282 clusters = adata.obs.clusters # store in .uns
283 for i, v in enumerate(adata.var[diff_kinetics].values):
284 if len(v) > 0:
/opt/python/lib/python3.7/site-packages/pandas/core/generic.py in __getattr__(self, name)
5272 if self._info_axis._can_hold_identifiers_and_holds_name(name):
5273 return self[name]
-> 5274 return object.__getattribute__(self, name)
5275
5276 def __setattr__(self, name: str, value) -> None:
AttributeError: 'DataFrame' object has no attribute 'clusters'
True, this was marked as todo - forgot to implement. Should be fixed now.
and color key is retrieved now correctly. Thanks for raising this!
Great stuff! Thanks a lot, Volker!
Hey Volker! I have some weird plotting issues for the differential kinetics results. Unfortunately this is not reproducible with your pancreas example (no error there).
Looks the the groups_to_bool() function produces some non numeric outpu here which numpy cannot sum. Have you seen something like this before?
Error
```pytb --------------------------------------------------------------------------- TypeError Traceback (most recent call last)Versions:
scvelo==0.2.0 scanpy==1.5.1 anndata==0.7.3 loompy==3.0.6 numpy==1.18.2 scipy==1.4.1 matplotlib==3.2.1 sklearn==0.22.2.post1 pandas==1.0.3