enrichplot icon indicating copy to clipboard operation
enrichplot copied to clipboard

Use repel = TRUE when node_label= "category" for cnetplot.enrichResult

Open dpanyard opened this issue 3 years ago • 0 comments

This issue is really more like an enhancement request (apologies if I didn't mark it properly), but I noticed today that when using cnetplot, the spacing of the nodes for the categories in my data was not consistent when I changed the value for the node_label parameter.

Looking through cnetplot.enrichResult, I found what the difference was:

If node_label == "category", then repel is left to the default FALSE in the line that calls geom_node_text (lines 47-50).

if (node_label == "category") { p <- p + geom_node_text(aes_(label = ~name), data = p$data[1:n, ]) }

If node_label == "gene" or "all", then repel = TRUE (lines 51-57):

else if (node_label == "gene") { p <- p + geom_node_text(aes_(label = ~name), data = p$data[-c(1:n), ], repel = TRUE) } else if (node_label == "all") { p <- p + geom_node_text(aes_(label = ~name), repel = TRUE) }

The result of this discrepancy was that when I tried to use node_label = "category", my nodes overlapped and the figure looked worse. The only way I could get the labels to look spaced apart was to add labels to the genes too (which was way too much) or to remove labels entirely (also not helpful).

So, for consistency, I'd suggest adding "repel = TRUE" to line 49 for the node_label = "category" option.

But it's a minor request. Overall, this package is amazing and I'm very grateful for it!

dpanyard avatar May 05 '21 02:05 dpanyard