Open Xparx opened 5 years ago
Sorry about the slow response, I'll look into this early this week.
No worries, It's a minor issue of convenience. If I interpreted the missing keys correctly it's not to difficult to add them manually. There are two keys missing. The one I mentioned and one related to the branching of the tree which I'm unsure how to interpret. I added the following two lines to my script.
adata.obs['dpt_order_indices'] = adata.obs['dpt_pseudotime'].argsort()
adata.uns['dpt_changepoints'] = np.ones(adata.obs['dpt_order_indices'].shape[0] - 1)
Hi there, I am having the same issue as above. I have tried the fix that @Xparx has provided but it yields more problems. See the below error which I am now receiving:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
TypeError: float() argument must be a string or a number, not 'csc_matrix'
The above exception was the direct cause of the following exception:
ValueError Traceback (most recent call last)
<ipython-input-48-abf5bf78cb77> in <module>
----> 1 sc.pl.dpt_timeseries(adata_HVG)
~/.conda/envs/python3/lib/python3.8/site-packages/scanpy/plotting/_tools/__init__.py in dpt_timeseries(adata, color_map, show, save, as_heatmap)
159 if as_heatmap:
160 # plot time series as heatmap, as in Haghverdi et al. (2016), Fig. 1d
--> 161 timeseries_as_heatmap(
162 adata.X[adata.obs['dpt_order_indices'].values],
163 var_names=adata.var_names,
~/.conda/envs/python3/lib/python3.8/site-packages/scanpy/plotting/_utils.py in timeseries_as_heatmap(X, var_names, highlights_x, color_map)
197 _, ax = pl.subplots(figsize=(1.5 * 4, 2 * 4))
198 ax.imshow(
--> 199 np.array(X, dtype=np.float_),
200 aspect='auto',
201 interpolation='nearest',
ValueError: setting an array element with a sequence.
I thought that this might be something to do with the fact that the np.ones
object is a numpy array instead of a pandas series so I tried substituting this with the line adata.uns['dpt_changepoints'] = pd.Series(np.ones(adata.obs['dpt_order_indices'].shape[0] - 1))
instead, but this still yielded the same error.
Thanks in advance!
Update: I just tried to run this command having used `branching=1' in my analysis and not performing the above correction (even though I know it's inappropriate for my particular system, branching=0 is what I want to use) and it still yielded the same error. As such I think perhaps this could be something independent of the above issue.
@falexwolf This issue still persists in version 1.9.1. and the work around suggested by @Xparx results in the same error that @haskankaya has reported. Any advice on how to get around this or a potential fix?
I don't think this is fixed in the previous issue https://github.com/theislab/scanpy/issues/129.
If you run
sc.tl.dpt(adata)
it creates thedpt_pseudotime
property inobs
as expected. However using dpt in plotting functions fails likesc.pl.dpt_timeseries(adata)
. This is due to thedpt_order_indices
property not being created ifbranching=0
.