CellChat
CellChat copied to clipboard
How to rename the sample and cluster names in CellChat object?
Hi,
I have cellchat objects as object.list (three samples) and the merged cellchat object as cellchats.merged. It takes more than 12hours to run the pipeline.
As I want to update the names of the clusters, how to update all cluster names in all slots, etc in CellChat object.
@micosacak Please check the function updateClusterLabels
But this function will re-run; computeCommunProbPathway(object) which takes the same time as running the pipeline from scratch. What I want to do, I have 133 clusters and after re-naming, I will still have the same cluster number but just re-naming some cluster names based on new markers. For instance, I have a cluster named Neuron1, I want to re-name it as MotorNeuron (or MN).
Did you find any solution to this? I also would like to just change the cluster names without re-running the analysis.
@erikagucciardo You can manually update the cell group names as follows labels.new <- plyr::mapvalues(object@idents, from = old.cluster.name, to = new.cluster.name) object@meta[[new.cluster.metaname]] <- labels.new object <- setIdent(object, ident.use = new.cluster.metaname, display.warning = FALSE)
dimnames(object@netP$prob) <- dimnames(object@net$prob) dimnames(object@net$count) <- dimnames(object@net$prob) dimnames(object@net$weight <- dimnames(object@net$prob)
But you do need to re-run 'object <-netAnalysis_computeCentrality(object, slot.name = "netP")'
Thanks! I was able to rename the clusters in the individual objects!