Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

How to re-label cell identity after the analysis was already done? #35

Open
ilcink opened this issue Aug 31, 2020 · 8 comments
Open

How to re-label cell identity after the analysis was already done? #35

ilcink opened this issue Aug 31, 2020 · 8 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@ilcink
Copy link

ilcink commented Aug 31, 2020

How to change a cell identity label without re-analysing the whole dataset?

I did
cellchat <- setIdent(cellchat, ident.use = "cell_type") # set "cell_type" as default cell identity (the new ones)
levels(cellchat@idents)
groupSize <- as.numeric(table(cellchat@idents))

it shows the right new idents, but the plots still show the initial cell annotation.

Thanks!

@sqjin
Copy link
Owner

sqjin commented Sep 1, 2020

Hi @natalkon , I just updated the package to support such action. You can re-label cells without re-doing computeCommunProb

@ilcink
Copy link
Author

ilcink commented Sep 1, 2020

Dear @sqjin ,

I tried to update the package simply by
devtools::install_github("sqjin/CellChat")

But I got
Error: Failed to install 'CellChat' from GitHub:
(converted from warning) installation of package ‘backports’ had non-zero exit status

How can I overcome it?

Thanks!

@ilcink
Copy link
Author

ilcink commented Sep 1, 2020

Dear @sqjin ,
I have manually deleted the "backports" folder from the library, downloaded the package "backports_1.1.9.zip" from CRAN https://cran.r-project.org/web/packages/backports/index.html and placed the new "backports" into the library.
After that updating the package with
devtools::install_github("sqjin/NMF")
devtools::install_github("sqjin/CellChat")
was no problem.

But after
identity = data.frame(group = sc_data$cell_type, row.names = names(sc_data$cell_type)) # create a dataframe consisting of the cell labels
unique(identity$group)
cellchat <- addMeta(cellchat, meta = identity, meta.name = "cell_type")
cellchat <- setIdent(cellchat, ident.use = "cell_type") # set "cell_type" as default cell identity
levels(cellchat@idents)
groupSize <- as.numeric(table(cellchat@idents))

Re-labelling worked for
CellChat::netVisual_aggregate(cellchat, signaling = c("TGFb"), layout = "circle", vertex.size = groupSize)

but still did not happen in
CellChat::netAnalysis_river(cellchat, pattern = "outgoing")
or in
CellChat::netAnalysis_dot(cellchat, pattern = "outgoing")

Do you know what could be the reason for that?

Thanks!

@sqjin
Copy link
Owner

sqjin commented Sep 3, 2020

@natalkon As I mentioned that "You can re-label cells without re-doing computeCommunProb", thus you need to re-run all the functions after computeCommunProb.

@sqjin sqjin closed this as completed Sep 3, 2020
@ilcink
Copy link
Author

ilcink commented Sep 3, 2020

@sqjin That is amazing! Thank you!!!

@ruohuchengxhe
Copy link

ruohuchengxhe commented Sep 26, 2020

@sqjin
Hi, I tried to change one label in both the metadata and idents:

levels(cellchat@meta$labels)[levels(cellchat@meta$labels) =='Mast cells' ] <- 'Mc 4'
levels(cellchat@idents)[levels(cellchat@idents) =='Mast cells' ] <- 'Mc 4'
table(cellchat@idents)

The label was changed successfuly.

And then I run the code after computeCommunProb, but when I try to plot, the label is still 'Mast cells', even for the CellChat::netVisual_aggregate function.

Could you please give advice?
Thanks!

@sqjin
Copy link
Owner

sqjin commented Sep 27, 2020

Hi @ruohuchengxhe , you should do it levels(cellchat@meta$labels)[levels(cellchat@meta$labels) =='Mast cells' ] <- 'Mc 4' cellchat <- setIdent(cellchat, ident.use = "cell_type") # set "cell_type" as default cell identity

@ruohuchengxhe
Copy link

Hi @ruohuchengxhe , you should do it levels(cellchat@meta$labels)[levels(cellchat@meta$labels) =='Mast cells' ] <- 'Mc 4' cellchat <- setIdent(cellchat, ident.use = "cell_type") # set "cell_type" as default cell identity

Sure! Didn't do this. Thanks!

@sqjin sqjin reopened this Oct 6, 2020
@sqjin sqjin added documentation Improvements or additions to documentation enhancement New feature or request labels Oct 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants