sankeywheel 绘制唯美桑基图
测试开头









测试结尾

点击上方关注老俊俊
1引言
分享一个包 sankeywheel 来绘制唯美的桑基图,横的和环形的皆可。这个包也是整合了 circlize, networkD3, 和 ggalluvial 三个强大的 R 包来进行可视化的。
2安装
devtools::install_github('czxa/sankeywheel', build_vignettes = TRUE)
# or just use git
devtools::install_git("https://github.com/czxa/sankeywheel.git", build_vignettes = TRUE)
# CRAN
install.packages("sankeywheel")
3使用
加载内置测试数据:
library(sankeywheel)
data(sankeydf)
# check
head(sankeydf,3)
# from to weight
# 1 Brazil Portugal 5
# 2 Brazil France 1
# 3 Brazil Spain 1
环形:
sankeywheel(from = sankeydf$from,
to = sankeydf$to,
weight = sankeydf$weight,
type = "dependencywheel",
width = "100%")

点击右边按钮可以下载:

横向:
sankeywheel(from = sankeydf$from,
to = sankeydf$to,
weight = sankeydf$weight,
type = "sankey",
width = "100%")

作者还给了多个不同的主题可以选择:
install.packages('manipulateWidget')
library(manipulateWidget)
combineWidgets(
sankeywheel(from = sankeydf$from,
to = sankeydf$to,
weight = sankeydf$weight,
type = "sankey",
width = "100%",
theme = "sunset",
title = "SUNSET"),
sankeywheel(from = sankeydf$from,
to = sankeydf$to,
weight = sankeydf$weight,
type = "dependencywheel",
width = "100%",
theme = "sunset",
title = "SUNSET"),
byrow = TRUE, ncol = 2, width = "100%", height = "300px"
)

其它参数:
sankeywheel(from = sankeydf$from,
to = sankeydf$to,
weight = sankeydf$weight,
type = "dependencywheel",
seriesName = "Random data: ",
width = "100%",
height = "400px",
theme = "sunset",
title = "SUNSET",
titleAlign = "center",
titleSize = "18px",
titleColor = "black",
subtitle = "czxa.top",
subtitleAlign = "center",
subtitleSize = "14px",
subtitleColor = "black")

4所有主题绘制
combineWidgets(
sankeywheel(from = sankeydf$from,
to = sankeydf$to,
weight = sankeydf$weight,
type = "dependencywheel",
width = "100%",
theme = "darkgreen",
title = "darkgreen"),
sankeywheel(from = sankeydf$from,
to = sankeydf$to,
weight = sankeydf$weight,
type = "dependencywheel",
width = "100%",
theme = "darkblue",
title = "darkblue"),
sankeywheel(from = sankeydf$from,
to = sankeydf$to,
weight = sankeydf$weight,
type = "dependencywheel",
width = "100%",
theme = "avocado",
title = "avocado"),
sankeywheel(from = sankeydf$from,
to = sankeydf$to,
weight = sankeydf$weight,
type = "dependencywheel",
width = "100%",
theme = "darkunica",
title = "darkunica"),
sankeywheel(from = sankeydf$from,
to = sankeydf$to,
weight = sankeydf$weight,
type = "dependencywheel",
width = "100%",
theme = "gray",
title = "gray"),
sankeywheel(from = sankeydf$from,
to = sankeydf$to,
weight = sankeydf$weight,
type = "dependencywheel",
width = "100%",
theme = "gridlight",
title = "gridlight"),
sankeywheel(from = sankeydf$from,
to = sankeydf$to,
weight = sankeydf$weight,
type = "dependencywheel",
width = "100%",
theme = "grid",
title = "grid"),
sankeywheel(from = sankeydf$from,
to = sankeydf$to,
weight = sankeydf$weight,
type = "dependencywheel",
width = "100%",
theme = "sandsignika",
title = "sandsignika"),
sankeywheel(from = sankeydf$from,
to = sankeydf$to,
weight = sankeydf$weight,
type = "dependencywheel",
width = "100%",
theme = "sunset",
title = "sunset"),
byrow = TRUE, ncol = 3, width = "100%", height = "800px"
)

那么你喜欢哪一个呢?


欢迎加入生信交流群。加我微信我也拉你进 微信群聊 老俊俊生信交流群
哦,数据代码已上传至QQ群,欢迎加入下载。
群二维码:
老俊俊微信:
知识星球:
所以今天你学习了吗?
今天的分享就到这里了,敬请期待下一篇!
最后欢迎大家分享转发,您的点赞是对我的鼓励和肯定!
如果觉得对您帮助很大,赏杯快乐水喝喝吧!
往期回顾
◀跟着 Cell Reports 学做图-CLIP-seq 数据可视化
◀m6A enrichment on peak center
◀m6A metagene distribution 纠正坐标
◀m6A metagene distribution 计算详解
◀...
请关注“恒诺新知”微信公众号,感谢“R语言“,”数据那些事儿“,”老俊俊的生信笔记“,”冷🈚️思“,“珞珈R”,“生信星球”的支持!