sqjin / CellChat

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

Error in visualizing chord diagram #235

Open jojob123 opened 3 years ago

jojob123 commented 3 years ago

Hi, I'm getting errors when trying to plot the chord diagram in "Inference and analysis of cell-cell communication": par(mfrow=c(1,1)) netVisual_aggregate(cellchat, signaling = pathways.show, layout = "chord")

> Note: The first link end is drawn out of sector 'Inflam. FIB'.

It gives the error: Error: not enough space for cells at track index '2'

I tried: "netVisual_aggregate(cellchat, signaling = pathways.show, layout = "chord", labels_track_height = 0.1)", but it also didn't work.

Is there a way to solve this? Thanks

sqjin commented 3 years ago

@jojob123 You can reduce the parameter values of small.gap and big.gap. If still does not work, you can use netVisual_chord_cell and netVisual_chord_gene to control these parameters.

jojob123 commented 3 years ago

@sqjin I reduced the values, but now it says: Error: not enough space for bottom margin of cells at track index '2'.

Could you clarify what you mean by using netVisual_chord_cell and netVisual_chord_gene to control these parameters?

Thanks for the reply.

retropc66 commented 2 years ago

I received the same error (not enough space for cells at track index '1' in my case) when running CellChat in an R Notebook in RStudio. I was able to fix it by adding figure dimensions to the header of my code chunk (i.e. {r fig.height=5,fig.width=5} rather than just {r} after the three backticks).

BradBalderson commented 2 years ago

@sqjin I am also receiving the same error. I can plot when I make the figure size very big, but then the area covered by the actual chord plot is very small. Depicted below is the minimum plotting size I can get where it doesn't give me the error.

Some advice to get this working would be great appreciated :)

cellchat_GRN_TNFRSF1A_chord

xutongran commented 2 years ago

I am also receiving the same error.(Error: not enough space for cells at track index '1'.) Is there a way to solve this? thaks!

gogozyz commented 2 years ago

This error can be fixed by preseting canvas size. for instance

pdf(file ="cellchat.pdf", width = 20, height =16)
netVisual_aggregate()
dev.off()

Hope this can help you

reza2026131 commented 2 years ago

I have same issue with netVisual_aggregate(object.list[[i]], signaling = pathways.show, layout = "chord", signaling.name = paste(pathways.show, names(object.list)[i])) }

and get this error:Error: not enough space for cells at track index '1'.

Please share any solution if you have found. Thanks.

sqjin commented 2 years ago

@reza2026131 You can reduce the parameter values of small.gap and big.gap. This is the way I have done before

reza2026131 commented 2 years ago

Changing the values of the small.gap did not work for me!

VaiskiVemmel commented 1 year ago

if you are using PDF paste and the image is tiny, check what you have in par(mfrow=c(X,Y)). That line defines how many images should fit on the paper, even when there is only 1 picture. So (mfrow=c(4,6)) would always try to fit 4 rows and 6 columns of your pictures on the paper, while (mfrow=c(1,1)) will use all the paper to draw only 1 picutre.

hanguojun007 commented 1 year ago

try dev.off(), then plot

akakClavin commented 8 months ago

It works: pathways.show <- c("CXCL") pdf(file ="cellchat.pdf", width = 20, height =16)

p<-netVisual_aggregate(cellchat, signaling = pathways.show, layout = "chord") print(p) dev.off()

akakClavin commented 8 months ago

This error can be fixed by preseting canvas size. for instance可以通过预设画布大小来修复此错误。例如

pdf(file ="cellchat.pdf", width = 20, height =16)
netVisual_aggregate()
dev.off()

Hope this can help you希望这能帮到你 thank you,dude