dynamo-release
dynamo-release copied to clipboard
Is there a detailed tutorial of Lineage tree of hematopoiesis?
Hello Dynamo, I'm wondering whether we have a detailed tutorial for plotting lineage tree of hematopoiesis (https://dynamo-release.readthedocs.io/en/latest/notebooks/tutorial_hsc_dynamo_megakaryocytes_appearance/tutorial_hsc_dynamo_megakaryocytes_appearance.html). Thanks! Best, YJ
I did like this.
dyn.pd.tree_model(adata, group='cell_type', progenitor='HSC', terminators=["Meg", "Ery", "Bas", 'Mon', 'Neu'], basis='umap', n_neighbors=30)
dyn.pl.state_graph(adata, group='cell_type', transition_threshold=0.001, keep_only_one_direction=True, edge_scale=1, basis='umap', color='cell_type', show_legend='on data', frontier= False,
save_show_or_return='show')
dyn.pl.state_graph(adata, group='cell_type', transition_threshold=0.001, keep_only_one_direction=True, edge_scale=1, basis='umap', color='cell_type', show_legend='on data', frontier= False,
save_show_or_return='save', save_kwargs={"prefix": 'state_graph', "ext": 'pdf', "transparent": True, "close": True, "verbose": True})
but the results look like this
not
Then, I followed the example in https://dynamo-release.readthedocs.io/en/latest/_autosummary/dynamo.pd.tree_model.html#dynamo.pd.tree_model, but got errors.
dyn.pd.state_graph(adata, group='cell_type', basis='umap')
res = dyn.pd.tree_model(adata, group='cell_type', progenitor='HSC', terminators=["Meg", "Ery", "Bas", 'Mon', 'Neu'], basis='umap', n_neighbors=30)
adata.obs['cell_type2'] = adata.obs['cell_type'].copy()
adata.uns['cell_type2_graph'] = adata.uns['cell_type_graph'].copy()
adata.uns['cell_type2_graph']['group_graph'] = res
dyn.pl.state_graph(adata, group='cell_type2', transition_threshold=None, keep_only_one_direction=False, edge_scale=1, basis='umap', color='cell_type2', show_legend='on data', frontier= False,
save_show_or_return='show')
KeyError Traceback (most recent call last)
File ~\anaconda3\envs\dynamo\lib\site-packages\pandas\core\indexes\base.py:3621, in Index.get_loc(self, key, method, tolerance)
3620 try:
-> 3621 return self._engine.get_loc(casted_key)
3622 except KeyError as err:
File ~\anaconda3\envs\dynamo\lib\site-packages\pandas\_libs\index.pyx:136, in pandas._libs.index.IndexEngine.get_loc()
File ~\anaconda3\envs\dynamo\lib\site-packages\pandas\_libs\index.pyx:163, in pandas._libs.index.IndexEngine.get_loc()
File pandas\_libs\hashtable_class_helper.pxi:5198, in pandas._libs.hashtable.PyObjectHashTable.get_item()
File pandas\_libs\hashtable_class_helper.pxi:5206, in pandas._libs.hashtable.PyObjectHashTable.get_item()
KeyError: (0, 0)
The above exception was the direct cause of the following exception:
KeyError Traceback (most recent call last)
Input In [76], in <cell line: 1>()
----> 1 dyn.pl.state_graph(adata, group='cell_type2', transition_threshold=None, keep_only_one_direction=False, edge_scale=1, basis='umap', color='cell_type2', show_legend='on data', frontier= False,
2 save_show_or_return='show')
File ~\anaconda3\envs\dynamo\lib\site-packages\dynamo\plot\state_graph.py:241, in state_graph(adata, group, transition_threshold, keep_only_one_direction, edge_scale, state_graph, edgecolor, facecolor, graph_alpha, basis, x, y, color, layer, highlights, labels, values, theme, cmap, color_key, color_key_cmap, background, ncols, pointsize, figsize, show_legend, use_smoothed, show_arrowed_spines, ax, sort, frontier, save_show_or_return, save_kwargs, s_kwargs_dict, **kwargs)
238 facecolor = "k" if facecolor is None else facecolor
239 graph_alpha = 0.8 if graph_alpha is None else graph_alpha
--> 241 arrows = create_edge_patches_from_markov_chain(
242 Pl, group_median, edgecolor=edgecolor, facecolor=facecolor, alpha=graph_alpha, tol=0.01, node_rad=15
243 )
244 if type(axes_list) == list:
245 for i in range(len(axes_list)):
File ~\anaconda3\envs\dynamo\lib\site-packages\dynamo\plot\state_graph.py:54, in create_edge_patches_from_markov_chain(P, X, width, node_rad, tol, connectionstyle, facecolor, edgecolor, alpha, **kwargs)
52 for i in range(P.shape[0]):
53 for j in range(P.shape[0]):
---> 54 if P[i, j] > tol:
55 if type(facecolor) == str:
56 fc = facecolor
File ~\anaconda3\envs\dynamo\lib\site-packages\pandas\core\frame.py:3505, in DataFrame.__getitem__(self, key)
3503 if self.columns.nlevels > 1:
3504 return self._getitem_multilevel(key)
-> 3505 indexer = self.columns.get_loc(key)
3506 if is_integer(indexer):
3507 indexer = [indexer]
File ~\anaconda3\envs\dynamo\lib\site-packages\pandas\core\indexes\base.py:3623, in Index.get_loc(self, key, method, tolerance)
3621 return self._engine.get_loc(casted_key)
3622 except KeyError as err:
-> 3623 raise KeyError(key) from err
3624 except TypeError:
3625 # If we have a listlike key, _check_indexing_error will raise
3626 # InvalidIndexError. Otherwise we fall through and re-raise
3627 # the TypeError.
3628 self._check_indexing_error(key)
KeyError: (0, 0)
I met the same question too. Have you find the fuction that is needed? Thanks in advance.
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 14 days