hdWGCNA icon indicating copy to clipboard operation
hdWGCNA copied to clipboard

How to repel labels in ModuleUMAPPlot()

Open levinhein opened this issue 2 years ago • 1 comments

Hello, good day. May I ask how can I repel the labels of the genes here so that they are readable? Thank you!!!

ModuleUMAPPlot(
  seurat_obj,
  edge.alpha=0.25,
  sample_edges=TRUE,
  edge_prop=0.1, # proportion of edges to sample (20% here)
  label_hubs=5 ,# how many hub genes to plot per module?
  keep_grey_edges=FALSE) 

image

levinhein avatar May 31 '22 07:05 levinhein

HI,

Thanks for pointing this out, I am aware of this issue and am trying to figure out how to resolve it. To make these network plots I am currently using the package igraph, which doesn't seem to support repelling labels.

I am looking into other network plotting options aside from igraph, such as ggraph and ggnetwork, but I haven't had any success getting those packages to work. Hopefully I will have an update soon.

smorabit avatar Jun 01 '22 00:06 smorabit

Is there any update on this? I have the same problem and did not find a solution. Thanks!

Desi0 avatar Jun 05 '23 16:06 Desi0

I would also like to know how to repel labels in ModuleUMAPPlot(). Thanks!

UEATTOOMUCH260 avatar Jun 06 '23 10:06 UEATTOOMUCH260

Hi,

Currently it is not possible to repel labels with ModuleUMAPPlot. Adding this functionality will basically require me to re-write the function using a different plotting engine like ggraph or ggnetwork rather than igraph, which does not support label repelling. I have actually already started working on this over the last few weeks, but it's not done yet. Hopefully will be in an update very soon.

smorabit avatar Jun 06 '23 19:06 smorabit

Ok. Thanks for the fast reply and all the effort for this nice package :-)

Desi0 avatar Jun 07 '23 05:06 Desi0

Hi,

Currently it is not possible to repel labels with ModuleUMAPPlot. Adding this functionality will basically require me to re-write the function using a different plotting engine like ggraph or ggnetwork rather than igraph, which does not support label repelling. I have actually already started working on this over the last few weeks, but it's not done yet. Hopefully will be in an update very soon.

Thank you so much!~

UEATTOOMUCH260 avatar Jun 07 '23 05:06 UEATTOOMUCH260

hi, not an actual solution but just a workaround! run ModuleUMAPPlot() twice with the same seed (set.seed()), first choose the desired label numbers per module with label_hubs = n. then run again with the exact same seed but this time label_hubs = 0, to get a plot without labels. you can also get the list of labels as you run the function. then manually add them in a non-overlapping manner! it should be relatively easy if you don't have too many modules and don't choose too many labels per module!

behyag avatar Sep 08 '23 12:09 behyag

I finally have an update for this issue! In the latest version of hdWGCNA, we introduced a new part of the network visualization tutorial covering customized network plots.

For now we are leaving ModuleUMAPPlot as is, so it is still not able to repel the labels in that function. But if you want to make a very similar plot that can repel labels, and that you can customize much more easily, please try to follow from this example in the customized network plot tutorial.

smorabit avatar Feb 28 '24 17:02 smorabit