Closed QuinceyLv closed 1 year ago
I will try to fix this problem (poorly designed function before). For now, I think you can create another column and change your custom cell type to this type:
adata.obs["celltype_num"] = adata.obs["celltype"].copy()
num_cat = list(range(0,len(adata.obs["celltype_num"].cat.categories)))
adata.obs["celltype_num"].cat.categories = list(map(lambda x: str(x),num_cat))
Then you can run with the newly created label
I will try to fix this problem (poorly designed function before). For now, I think you can create another column and change your custom cell type to this type:
adata.obs["celltype_num"] = adata.obs["celltype"].copy() num_cat = list(range(0,len(adata.obs["celltype_num"].cat.categories))) adata.obs["celltype_num"].cat.categories = list(map(lambda x: str(x),num_cat))
Then you can run with the newly created label
Thanks for reply. I tried the code and got an error:
adata_SME.obs["celltype_num"] = adata_SME.obs["celltype"].copy() num_cat = list(range(0,len(adata_SME.obs["celltype_num"].cat.categories))) num_cat [0, 1, 2, 3, 4, 5] adata_SME.obs["celltype_num"].cat.categories = list(map(lambda x: str(x),num_cat)) Traceback (most recent call last): File "
", line 1, in File "foo/bar/envs/stlearn/lib/python3.8/site-packages/pandas/core/base.py", line 178, in setattr object.setattr(self, key, value) File "foo/bar/envs/stlearn/lib/python3.8/site-packages/pandas/core/accessor.py", line 99, in _setter return self._delegate_property_set(name, new_values) File "foo/bar/envs/stlearn/lib/python3.8/site-packages/pandas/core/arrays/categorical.py", line 2460, in _delegate_property_set return setattr(self._parent, name, new_values) AttributeError: can't set attribute
I'm using stlearn == 0.4.12 and pandas == 2.0.1.
Besides, if I run with label "celltype_num", how could I put corresponding celltype label on plots instead of the numbers?
Can you set adata_SME.obs["celltype_num"].cat.categories
to the list of numbers (string type) that corresponds to the number of your cluster?
It will be a problem if you want to plot directly the label. I will try to fix it soon, hopefully within this week. A quick solution is that you export to pdf and replace the number with your label by illustrator.
Can you set
adata_SME.obs["celltype_num"].cat.categories
to the list of numbers (string type) that corresponds to the number of your cluster?It will be a problem if you want to plot directly the label. I will try to fix it soon, hopefully within this week. A quick solution is that you export to pdf and replace the number with your label by illustrator.
Great help. Really appreciated.
@duypham2108 Hello, I tried to plot trajectory tree using st.pl.trajectory.tree_plot():
st.pl.trajectory.tree_plot(adata_SME, use_label="leiden")
I expected to get plots like the tutorial:
While I got:
We removed that option. You can downgrade to the version 0.4.8
to plot it. We may bring it back in the next version.
Hello, I'm trying to do trajectory analysis with stlearn. When I looked into stlearn/plotting/trajectory/pseudotime_plot.py, line 130: https://github.com/BiomedicalMachineLearning/stLearn/blob/e22bc1fa50c91667a7f364f2091155f5e4633610/stlearn/plotting/trajectory/pseudotime_plot.py#L130
It seems that I can't use customly defined celltype (e.g. Celltype_A, Celltype_B).
So what should I do if I hope to use celltypes?
Thanks in advance.