sqjin / CellChat

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

Comparison analysis of two tumor databsets #129

Closed BeyondMyPast228 closed 3 years ago

BeyondMyPast228 commented 3 years ago

Hi, I have two datasets of tumor tissue. Their cells are made up of similar components, but also different components.The similar ones are non-tumor cells, and the different components are tumor cells . The first tumor cell types are : [1] "tumor-4" "Endothelial cells"
[4] "Oligodendrocyte-like tumor cells" "tumor-0" "tumor-10"
[7] "Microglia" "tumor-1" "Astrocytes"
[10] "Unknown" "tumor-2" "Proliferation-associated tumor-8" [13] "Oligodendrocytes" , "tumor-7" , "tumor-5"
[16] "tumor-3" ,"Proliferation-associated tumor-6" ,"tumor-9"
[19] "Unknown-1" "Microglia-2" "Macrophages"
[22] "Pericytes" The second tumor cell types are : [1] "Oligodendrocytes" , "tumor-4_2"
[3] "Microglia" , "Unknown"
[5] "tumor-0_2" ,"Astrocytes"
[7] "tumor-3_2" , "Inhibitory neuron"
[9] tumor-6_2 ”
[11] "Microglia-2" "tumor-1_2"
[13] "Endothelial cells" "Ependymal cells"
[15] "Pericytes"
[17] "tumor-5_2" "Macrophages"
[19] "Unknown-mito"

In this two datasets, the similar components are Pericytes, Microglia,Endothelial cell, Macrophages, Oligodendrocyte, Astrocyte, The different components are tumor cells , So, Which tutorial should I use to compare the differences in their cell communication? I sincerely hope to get your kind reply.

sqjin commented 3 years ago

@BeyondMyPast228 You can use the tutorial on the slightly different compositions and lift the cell groups up to the same levels. For the second tutorial on the vastly different compositions, there are just several functions that are not applicable.

BeyondMyPast228 commented 3 years ago

@sqjin Maybe I didn't make myself understood. The two datasets have different tumor compositions. I can't tell their real identity, can only use tumor- instead. The first tumor-1 is different from the second tumor-1_2. Not quite clear if lift the cell groups up to the same levels, which dataset should I use as a benchmark. Is there a clear standard? Thanks for your kind help.

sqjin commented 3 years ago

@BeyondMyPast228 You can combine all cell identities together from the two conditions. group.new = union(levels(cellchat1@idents), levels(cellchat2@idents))

BeyondMyPast228 commented 3 years ago

@sqjin ,When I try to combine all the cell identities, I don't know how to interpret the results. In the picture, red (or blue) represents increased (or decreased) signaling in the second dataset compared to the first one. But in my second dataset, I didn't include all the cell identities. So what explains the differential expression of these cell types that don't share much in common? In addtion, For some cell types in common, are their differentially expressed results plausible when other cell identities are introduced? 1611985279(1)

BeyondMyPast228 commented 3 years ago

The other thing is whether you can just compare these cells that are common to the two datasets, or just show the changes in the communication patterns of these cells that are common

sqjin commented 3 years ago

Hi @BeyondMyPast228 , the differential analysis here only performs minus operation between the two datasets. Thus, if one cell group is missing in the second dataset, you should see all blue links associated with this cell group.

You can try to define 'sources.use' and 'targets.use' in netVisual_diffInteraction to select the common cell types.

BeyondMyPast228 commented 3 years ago

@sqjin Hi, When I merge the two databases and run the following code, an error occurs. Code : netVisual_diffInteraction(cellchat,weight.scale = T,sources.use = "Microglia",targets.use = "Endothelia")

Error : Error in quantile.default(abs(net), probs = 1 - top) : missing values and NaN's not allowed if 'na.rm' is FALSE

Another question is when the same type of cell is compared in two databases for cellular communication patterns.Whether the increase or decrease is for comparison of the cell's interactions with all other cells in different databases, or only for comparison of the cell's interactions with cell types common to both databases. In addition, Whether this increase or decrease is standardized or simply a comparison in terms of the number of interactions.

Thanks for your help.

sqjin commented 3 years ago

@BeyondMyPast228 I just updated the package and the error should go away. It is just direct comparison of the number of interactions between the same cell pairs across two datasets.

LiesMinn commented 3 years ago

Hi, Thanks for creating this extremely useful tool!

Related to the comment above: I believe there is a bug in the liftCellChat when lifting up cellchat objects when using group.new = union(levels(cellchat1@idents), levels(cellchat2@idents)).

By taking the union, group.new will contain first the cell types that intersect between the two cellchat objects and at the end it contains the remaining cell types. With the liftCellChat function as it is currently in the source code, the indexes in group.existing.index are ranked numerically, where in fact the order of the indices should be maintained in order to provide the correct values.new matrix later on in the function. When using the current liftCellChat code, I ran into the issue that my cell type labels were shifted due to this. I noticed it when the 2D plots of the merged object did not match the 2D plots produced by running cellchat on the individual objects.

I managed to get it working by changing two lines in the code: changing lines 375 and 468 from: group.existing.index <- which(group.max %in% group.existing)

to : group.existing.index <- unlist(lapply(group.i, function(x) which(group.max %in% x)))

Could you verify this change in the code and, if fine, implement it accordingly so that this issue is solved?

Thanks!

mms100 commented 3 years ago

@sqjin using the 1.1.3 cellchat version I still facing the same error as @BeyondMyPast228

Error : Error in quantile.default(abs(net), probs = 1 - top) : missing values and NaN's not allowed if 'na.rm' is FALSE

by specifying the targets and sources in netVisual_diffInteraction

Looking forward to having your helpful feedback.

Thanks!

laijen000 commented 1 year ago

I am also still having the issue Error in quantile.default(abs(net), probs = 1 - top): missing values and NaN's not allowed if 'na.rm' is FALSE

when I try to specify sources and targets for netVisual_diffInteraction() . @mms100 , @BeyondMyPast228 have you found a solution? thank you!

sqjin commented 1 year ago

@laijen000 Can you try to re-install the package and see if it works now.