Open lizanyu opened 3 years ago
@lizanyu There is no error when I tested the example data. Could you run the source codes to figure out the reason? You can also share your object with me if you like.
@sqjin I shared my repository with you (also for issue #201) -- I assume I'm just not selecting the correct 'idents.use'?? Thanks for your help!
I think I find this reason in subsetCellChat. The error arises in the last step of building the CellChat object. The code for 'meta.subset' will be factor when the meta only have a col in 'meta.subset <- object@meta[cells.use.index, ]'. So I add One more step when to select the new meta.subset. The code like this.
if (ncol(object@meta)==1) { meta.subset <- data.frame(row.names = rownames(object@meta)[cells.use.index],xx = object@meta[cells.use.index,1]) colnames(meta.subset)[1] <- colnames(object@meta) }else{meta.subset <- object@meta[cells.use.index, ]}
@lizanyu
I encountered this problem as well in cellchat v 1.6.1.
I think it's caused by not subsetting the network components correctly that have a separate matrix for each pathway:
values.new <- values[group.existing.index, group.existing.index, drop = FALSE]
Should be the following, in order to do the same for all pathways:
values.new <- values[group.existing.index, group.existing.index, ,drop = FALSE]
The code block is here:
# cat("Update slot object@net...", '\n')
net <- object@net
for (net.j in names(net)) {
values <- net[[net.j]]
if (net.j %in% c("prob","pval")) {
values.new <- values[group.existing.index, group.existing.index, , drop = FALSE]
net[[net.j]] <- values.new
}
if (net.j %in% c("count","sum","weight")) {
values.new <- values[group.existing.index, group.existing.index, drop = FALSE]
net[[net.j]] <- values.new
}
}
net.subset <- net
Hi, may I check if this issue has been fixed in cellchat? I'm still getting Update slots object@images, object@net, object@netP in a single dataset... Error in values[group.existing.index, group.existing.index, drop = FALSE] : incorrect number of dimensions
I am also working with CellChat 1.6.1 and the code block from @rbatorsky solved the matrix dimension problem.
Another reason behind the incorrect number of dimensions
happens when using the cells.use
to subset the CellChat object, the level.use
will return a NULL since names(labels)
is NULL.
The solution for me was the following:
labels <- object@idents # This is a factor without names
names(labels) = colnames(object@data) # The new line to name the factor by cell id and fix the level.use is NULL issue
level.use0 <- levels(labels)
level.use = levels(labels)[levels(labels) %in% unique(as.character(labels[cells.use]))]
cells.use.index <- which(names(labels) %in% cells.use)
@TzuTingWei Thanks. I will fix this issue by using your solution.
line 827 in R/CellChat_class.R maybe missing a comma ,
should be:
values.new <- values[group.existing.index, group.existing.index, , drop = FALSE]
that's work for me!
Hello,
cellchat is a wonderful tool! I ran into the same issue with running subsetCellChat with my data.
code: cellchat_interface20_subset <- subsetCellChat( cellchat_interface20, cells.use = c('Cholangiocyte',"M.APOE"), idents.use = NULL, group.by = NULL, invert = FALSE, thresh = 0.05 )
error:
The subset of cell groups used for CellChat analysis are
Update slots object@images, object@net, object@netP in a single dataset...
Error in values[group.existing.index, group.existing.index, drop = FALSE] :
量度数目不对
I'm really at a loss as to how to proceed, and any guidance would be much appreciated! Thank you for your kind help!
Hello,
cellchat is a wonderful tool! I ran into the same issue with running subsetCellChat with my data.
code: cellchat_interface20_subset <- subsetCellChat( cellchat_interface20, cells.use = c('Cholangiocyte',"M.APOE"), idents.use = NULL, group.by = NULL, invert = FALSE, thresh = 0.05 )
error: The subset of cell groups used for CellChat analysis are Update slots object@images, object@net, object@netP in a single dataset... Error in values[group.existing.index, group.existing.index, drop = FALSE] : 量度数目不对
I'm really at a loss as to how to proceed, and any guidance would be much appreciated! Thank you for your kind help!
@QianhuiXu Can you share me your CellChat object so that I can replicate your error?
I have sent my CellChat object to your email, Thank you very much!
I have sent my CellChat object to your email, Thank you very much!
Received it. will take into it later today.
Hi,
I have three conditions and I created three cellchat objects to look communication between specific clusters at individual treatment level. BUT I am getting an error while using subsetCellChat:
subsetCellChat(object=cellchat, idents.use=c("T-cells","Myeloid")) The subset of cell groups used for CellChat analysis are T-cells Myeloid Update slots object@images, object@net, object@netP in a single dataset... Error in values[group.existing.index, group.existing.index, drop = FALSE] : incorrect number of dimensions
Would appreciate your help! Thank you in advance.
@apal6 No idea on this error except that I can replicate your error using your cellchat object.
@sqjin, sorry to bother but I am still getting the same error even when I ran the subset function on individual cellchat object (one object for one condition). I am happy to share my cellchat object if you need to debug? I highly appreciate your time. Thank you!
@apal6 You can find my email in the Description file.
@QianhuiXu, how were you able to debug? I got this error too. Thank you!
Hello! Thank you for creating such an awesome tool! I'm following the tutorial for Comparison Analysis of Multiple Datasets and would like to subset the merged cellchat object for ease of analysis. I am trying to use
subsetCellChat
using vectors identified fromcellchat@idents$joint
:I get the following error message:
How should I be identifying
idents.use
? Any help would be greatly appreciated!Thanks, Liz
Here is my sessionInfo: