smorabit / hdWGCNA

High dimensional weighted gene co-expression network analysis
https://smorabit.github.io/hdWGCNA/
Other
316 stars 31 forks source link

How to repel labels in ModuleUMAPPlot() #18

Closed levinhein closed 2 months ago

levinhein commented 1 year ago

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

smorabit commented 1 year ago

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.

Desi0 commented 11 months ago

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

UEATTOOMUCH260 commented 11 months ago

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

smorabit commented 11 months ago

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.

Desi0 commented 11 months ago

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

UEATTOOMUCH260 commented 11 months ago

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!~

behyag commented 8 months ago

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!

smorabit commented 2 months ago

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.