enrichplot
enrichplot copied to clipboard
weight edge widths in emapplot
Is it possible to weight the edge widths in emapplot so the term similarity is clearly visible? For example, the edges in the default plot below all look the same, but I would like the line widths to range from 0.2 to 1 (times the cex_line). So if the term similarity is 0.25 , it should be 1/4 the width of an edge connecting nodes with a term similarity=1
data(geneList)
de <- names(geneList)[abs(geneList) > 2]
edo <- enrichKEGG(de)
edo <- pairwise_termsim(edo)
emapplot(edo, cex_line=3)
The width of edges in emapplot
are not the same, they are proportional to the similarity of terms.
I think the widths should range from the min_edge or 0.2 to 1, but it's very difficult to tell which pairs of terms in the plot have 100% similarity compared to those with 80% or 40% or even 20% similarity. I thought 20% similarity should be 1/5 the size of lines with 100% similarity? Also, is there a way to make the term similarity more obvious, maybe a color scale for edges (light gray to black) or display the term similarity in the middle of the lines. I will also check ggraph and see if I can scale these lines any better.
This answer on StackOverflow might help and maybe all that's needed is the option to adjust the scale_edge_width?
library(ggraph)
library(igraph)
data=data.frame(w1=c(rep('apple', 4), 'pear', 'pear', 'peach'),
w2 = c('orange', 'pear','peach', 'banana', 'peach', 'banana', 'orange'),
weight= c(.2,.4,.5,.8, 1, .75, .25))
data %>%
graph_from_data_frame() %>%
ggraph(layout = "fr") +
geom_edge_link(alpha = .25,
aes(width = weight)) +
geom_node_point(color = "blue", size = 2) +
geom_node_text(aes(label = name), repel = TRUE)+
scale_edge_width(range = c(1,10)) +
theme_graph()

This looks much better but the legend does not make sense (4 to 6?).
emapplot(edo, cex_line=3) + scale_edge_width(range = c(1,10))