add a Convex Hull with module

有的文章会在模块化的群落里加上Convex Hull ,类似这样,如何实现呢,可以借助ggforce的geom_mark_hul 比如我们的示例代码稍作修改 library(ggforce) 主要是加了最后一行,的geom_mark_hull...

有的文章会在模块化的群落里加上Convex Hull ,类似这样,如何实现呢,可以借助ggforce的geom_mark_hul

attachments-2024-07-ROSxaUsG668f32107c132.png


比如我们的示例代码稍作修改

# add a Convex Hull 
library(ggforce)  # for geom_mark_hull or geom_encircle

p1 <- ggraph(g, layout = "fr") + 
  geom_edge_link(aes(color = type, width = abs(as.double(correlation))), alpha = 0.9, show.legend = TRUE) + 
  geom_node_point(aes(size = as.double(node.mean.abundance), fill = node.sub.module), alpha = 0.9, color = "#000000", show.legend = TRUE, shape = 21) +   
  scale_size(range = c(2, 6), name = "degree") +  
  scale_fill_manual(values = myColor, name = "module") +
  scale_edge_width_continuous(range = c(0.1, 0.3), name = "abs(correlation)") +  
  scale_edge_colour_manual(name = "type", values = c(positive = "#e41a1c", negative = "#377eb8")) +
  theme_void() +
  geom_mark_hull(aes(x = x, y = y, group = node.sub.module, fill = node.sub.module), concavity = 1, expand = unit(5, "mm"), alpha = 0.1)  # Adjust parameters as needed

p1

主要是加了最后一行,的geom_mark_hull这个参数

得到的结果如下

其他参数可以看帮助调节


attachments-2024-07-WnJI02cE668f336bcb9ce.png
  • 发表于 2024-07-11 09:20
  • 阅读 ( 422 )

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
xun
xun

电路元件工程师

76 篇文章

作家榜 »

  1. omicsgene 691 文章
  2. 安生水 340 文章
  3. Daitoue 167 文章
  4. 生物女学霸 120 文章
  5. 红橙子 78 文章
  6. xun 76 文章
  7. rzx 74 文章
  8. CORNERSTONE 72 文章