CellChat icon indicating copy to clipboard operation
CellChat copied to clipboard

Error with netAnalysis_signalingRole_heatmap

Open anaccsilva opened this issue 1 year ago • 6 comments

Hello,

I am having an issue with netAnalysis_signalingRole_heatmap. I have a control group in which some of the clusters have very few cells (I believe this is causing the issue, as I don't have problems with the other two affected groups).

When I run:

ht1 <- netAnalysis_signalingRole_heatmap(cellchat.neg, pattern = "outgoing",color.use = c("#CDD704","#A2C257","#8BA870", "#5EDA9E","#61B329","#3F9E4D", "#79A888", "#337147","#00C957", "#D4318C","#871F78","#FF83FA","#8B2252","#3B3178","#9B30FF","#4F2F4F", "#551A8B", "#9400D3","#8F5E99","#CDB5CD", "#72587F"))
ht2 <- netAnalysis_signalingRole_heatmap(cellchat.neg, pattern = "incoming",color.use = c("#CDD704","#A2C257","#8BA870", "#5EDA9E","#61B329","#3F9E4D", "#79A888", "#337147","#00C957", "#D4318C","#871F78","#FF83FA","#8B2252","#3B3178","#9B30FF","#4F2F4F", "#551A8B", "#9400D3","#8F5E99","#CDB5CD", "#72587F"))
ht1 + ht2

I get the following message: "There are 100 unique colors in the vector col and 100 unique values in matrix. Heatmap() will treat it as an exact discrete one-to-one mapping. If this is not what you want, slightly change the number of colors, e.g. by adding one more color or removing a color."

Then, I receive the error: "Error: Relative strength: cannot map colors to some of the levels: 0"

I am not sure how to fix that. If I run just ht2 ("incoming") I don't have issues.

I appreciate the help.

Thank you, Ana

anaccsilva avatar Dec 15 '23 04:12 anaccsilva

@anaccsilva For the cell group labels, do you have a label as "0"? This is not allowed in CellChat. Otherwise, I have no idea on it except that I can replicate your error. You can also run the source code of this function by copying these source codes from github.

sqjin avatar Dec 16 '23 03:12 sqjin

Thank you for the quick reply. As mentioned, ht2 works just fine, so I don't think it is a problem with the label. Is it possible that some levels have very few cells and cannot map outgoing interactions? If this is the case, is there a way to subset a cellchat object? Can I remove some levels that have few cells and try the code again? Thank you again!

anaccsilva avatar Dec 18 '23 17:12 anaccsilva

@anaccsilva This should be not the case. In the tutorial, we have a step to filter out the interactions when the number of cells within that cell group. You may can share me your CellChat object or you can subset the cellchat object using subsetCelChat function.

sqjin avatar Dec 29 '23 02:12 sqjin

Thank you once again. How can I share my object with you? Thank you.

anaccsilva avatar Dec 29 '23 15:12 anaccsilva

@anaccsilva You can share me a link of google drive or others.

sqjin avatar Jan 04 '24 13:01 sqjin

Hi @sqjin, I was able to figure out the problem. As I wanted to modify the colors, I added color.use. I am not sure why one of the codes worked with the colors and the other one did not, but all worked as soon as I carefully fixed the colors. Hope this helps for future inquiries. Thank you so much again! Excellent tool and support!

anaccsilva avatar Jan 04 '24 16:01 anaccsilva