CellChat icon indicating copy to clipboard operation
CellChat copied to clipboard

netVisual_diffInteraction for specific source & targets

Open Tomer9w opened this issue 3 years ago • 6 comments

Hi I want to show the differential number of interactions for specific clusters in my dataset. I've tried to choose clusters with the 'netVisual_diffInteraction' function but i get this error message:

netVisual_diffInteraction(cellchat, weight.scale = T, measure = "weight", sources.use = 5, targets.use = 4) Error in quantile.default(abs(net), probs = 1 - top) : missing values and NaN's not allowed if 'na.rm' is FALSE

I noticed that this issue has come up before but never really solved. I'm using CellChat v1.3.0.

Hope you can help with this Thanks! Tomer

Tomer9w avatar Feb 15 '22 14:02 Tomer9w

Hi I want to show the differential number of interactions for specific clusters in my dataset. I've tried to choose clusters with the 'netVisual_diffInteraction' function but i get this error message:

netVisual_diffInteraction(cellchat, weight.scale = T, measure = "weight", sources.use = 5, targets.use = 4) Error in quantile.default(abs(net), probs = 1 - top) : missing values and NaN's not allowed if 'na.rm' is FALSE

I noticed that this issue has come up before but never really solved. I'm using CellChat v1.3.0.

Hope you can help with this Thanks! Tomer

I found that the NA data could be generated from line 47-48. Add net[is.na(net)] <- 0 behind them could solve this problem.

sdzxzh avatar Feb 17 '22 04:02 sdzxzh

Thanks @sdzxzh I added your suggestion after lines 47-48 and it did fixed the issue. However, this is not a fixed solution to the problem so I'm leaving this issue open.

Tomer9w avatar Feb 17 '22 13:02 Tomer9w

@Tomer9w @sdzxzh Thanks for pointing it out. Adding net[is.na(net)] <- 0 fixed the issue. I have updated this.

sqjin avatar Feb 18 '22 12:02 sqjin

Hi all, can you explain how you added "net[is.na(net)] <- 0" to your code to get it to work? I can't figure out how to fit it to my own.

cells <- "Microglia" par(mfrow = c(1,2), xpd=TRUE) netVisual_diffInteraction(cellchatM, weight.scale = T, sources.use = cells)

luxhexmaster avatar Sep 21 '22 16:09 luxhexmaster

Fix it now in github.

On Thu, Sep 22, 2022 at 12:16 AM luxhexmaster @.***> wrote:

Hi all, can you explain how you added "net[is.na(net)] <- 0" to your code to get it to work? I can't figure out how to fit it to my own.

cells <- "Microglia" par(mfrow = c(1,2), xpd=TRUE) netVisual_diffInteraction(cellchatM, weight.scale = T, sources.use = cells)

— Reply to this email directly, view it on GitHub https://github.com/sqjin/CellChat/issues/371#issuecomment-1253932596, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHXF63AD6RD3JMZAD67K3D3V7MYEDANCNFSM5OOU4CUQ . You are receiving this because you commented.Message ID: @.***>

sqjin avatar Sep 21 '22 23:09 sqjin

Hi @sqjin,

I updated to the latest CellChat version (v1.5.0), but the error is still occurring.

Doing netVisual_diffInteraction works as long as I do it for all cell populations:

par(mfrow = c(1,2), xpd=TRUE) netVisual_diffInteraction(cellchatM, weight.scale = T) netVisual_diffInteraction(cellchatM, weight.scale = T, measure = "weight")

However, when I specify targets and/or sources (like in the example below), I get the error people have described previously:

cells <- "Microglia" par(mfrow = c(1,2), xpd=TRUE) netVisual_diffInteraction(cellchatM, weight.scale = T, sources.use = cells) netVisual_diffInteraction(cellchatM, weight.scale = T, measure = "weight", sources.use = cells)

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

luxhexmaster avatar Sep 22 '22 17:09 luxhexmaster