Closed Qotov closed 2 years ago
Thanks for using scFates and raising this issue!
Indeed the strategy to color the edges has been changed and should be much more robust from version v0.2.4, as it uses the soft assignment matrix (denoted R in the code) between cells and nodes of the principal graph to perform weighted average of a given feature. This is calculated per node and then edge value is calculated as the mean of the two nodes that compose it.
The first error tells that one or more node don't seem to be assigned to any cells, which shouldn't happen normally. Could you tell me which method did you used for building the graph, ppt or elpigraph? When running pl.graph
, does the graph look in one piece? As for the second error, this looks less clear to me but I would think that this is a similar issue related to the tree, which is affecting the edge indexing.
For both errors I would suggest to re-run tl.tree
with different parameter in order to avoid any broken tree or lonely nodes. To verify that the nodes all are assigned to any cells, I would check if the following is True:
all(adata.uns["graph"]["R"].sum(axis=0)>0)
In any case I would also be happy to have a look myself at your two datasets if you could send me anonymised versions of these, so that I can reproduce an debug these errors!
I assume the issue as been resolved, I close it!
Hello,
I keep running into an error when I try to run this function. This is the message I am getting:
IndexError Traceback (most recent call last) Cell In[142], line 2 1 for c in slide.var["cluters"].unique(): ----> 2 scf.pl.trends(slide,features=slide.varnames[slide.var['cluters']==c], 3 basis="pca", save = f'cluster{c}_trends', n_features = 15)
File /nfs/turbo/umms-ukarvind/vravik/cell2loc/lib/python3.9/site-packages/scFates/plot/features.py:210, in trends(adata, features, cluster, highlight_features, n_features, root_milestone, milestones, module, branch, annot, title, feature_cmap, pseudo_cmap, plot_emb, plot_heatmap, wspace, show_segs, basis, heatmap_space, offset_names, fontsize, style, ordering, ord_thre, figsize, axemb, show, output_mean, save, return_genes, **kwargs) 205 order = order + np.array(allpaths[i])[~np.isin(allpaths[i], order)].tolist() 207 order = np.array(order)[1:] 209 order = pd.Series(graph["milestones"].keys(), index=graph["milestones"].values())[ --> 210 np.array(img.vs["name"])[order].astype(int) 211 ] 212 to_mil = graph["pp_seg"].loc[adata.obs.seg.cat.categories.astype(int), "to"] 213 seg_order = pd.Series(range(len(adata.obs.seg.cat.categories)), index=to_mil)[ 214 order[order.index.isin(to_mil)].index 215 ].values
IndexError: arrays used as indices must be of integer (or boolean) type
Could you please tell me what might be going on?
Hello, thanks for your lib, it is very useful.
Starting from v.0.2.2 I get several errors when I try to use
scf.pl.trends
.The function works well for the same datasets on v.0.2.0
First error:
Second: