查看原文
其他

sankeywheel 绘制唯美桑基图

JunJunLab 老俊俊的生信笔记 2022-08-15

点击上方关注老俊俊

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,


老俊俊微信:


知识星球:



今天的分享就到这里了,敬请期待下一篇!

最后欢迎大家分享转发,您的点赞是对我的鼓励肯定

如果觉得对您帮助很大,赏杯快乐水喝喝吧!



  





ggplot 绘制小提琴图+箱线图+统计检验

Ribo-seq 数据上游分析

关于序列提取的问题思考

跟着 Cell Reports 学做图-CLIP-seq 数据可视化

m6A enrichment on peak center

m6A metagene distribution 纠正坐标

ggplot 绘制箱线图

python 查找字符串

tornadoplot 绘制富集热图

m6A metagene distribution 计算详解

◀...

您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存