sqjin / CellChat

R toolkit for inference, visualization and analysis of cell-cell communication from single-cell data
GNU General Public License v3.0
632 stars 144 forks source link

Error in liftCellChat function #313

Open molliec1177 opened 2 years ago

molliec1177 commented 2 years ago

Hey cellchat team, thanks for the great package! I have analyzed my single cell datasets separately and now am trying to compare two conditions with the merge cell chat features. I am following the directions according to the Comparison analysis of multiple datasets with different cell type compositions vignette. My two objects have the same # of cell identities, and only one identity differs between the two groups. Every time I run the liftCellChat function, I get the following error:

"Error in values.new[group.existing.index, group.existing.index, ] <- values : number of items to replace is not a multiple of replacement length"

Here is my code:

Identities in the cellchatnst3605 are [1] "Tumor Cells" "Monocytes"
[3] "BMDM" "CD4 T-cells"
[5] "CD8 T-cells" "Microglia"
[7] "DC" "Proliferating Tumor Cells" [9] "Proliferating TAMs" "B-cells"
[11] "Proliferating T-cells" "Endothelial"

Identities in the cellchatqpp7 are [1] "Tumor Cells" "Monocytes"
[3] "BMDM" "CD4 T-cells"
[5] "CD8 T-cells" "Microglia"
[7] "DC" "Proliferating Tumor Cells" [9] "Proliferating TAMs" "B-cells"
[11] "Endothelial" "NK cells"

group.new = levels(cellchatqpp7@idents) cellchatnst3605_lifted <- liftCellChat(cellchatnst3605, group.new)

The CellChat object will be lifted up using the cell labels Tumor Cells, Monocytes, BMDM, CD4 T-cells, CD8 T-cells, Microglia, DC, Proliferating Tumor Cells, Proliferating TAMs, B-cells, Endothelial, NK cells

Update slots object@net, object@netP, object@idents in a single dataset...

Error in values.new[group.existing.index, group.existing.index, ] <- values : number of items to replace is not a multiple of replacement length

Thanks in advance!

sqjin commented 2 years ago

@molliec1177 You need to use the joint set of the identities group.new = union(levels( cellchatnst3605), levels(cellchatqpp7@idents)). You can also give an order of these identities.