桑基图

作者: 白云梦_7 | 来源:发表于2021-04-23 11:26 被阅读0次

R包networkD3

示例

edges
nodes
edges$edgegroup = as.character(edges$from)
sankeyNetwork(
  Links = edges, Nodes = nodes, 
  Source = "from", Target = "to", 
  NodeID = "label", Value = "value",
  LinkGroup = "edgegroup",
  fontSize = 16, unit = "Letter(s)")
image.png

nodeID必须从0开始

R包ggplot2

file
library(ggalluvial)
library(ggplot2)

df<-read.table("sangji-GO.txt",header = T,sep = "\t")

ggplot(data =crc,aes(axis1=celltype,axis2=Description,weight=Count))+geom_stratum() +  #冲击图中的堆叠柱形图
    geom_flow(aes.flow = 'forward') + #连接线
    geom_text(stat = 'stratum', infer.label = TRUE, size = 4)+ #填充字体
    geom_alluvium(aes(fill = celltype))+ #填充颜色
    theme_bw()+theme(text = element_text(size=14),legend.position = "NULL",panel.background = element_blank(),line = element_blank(), axis.text.y = element_blank())+
    scale_x_continuous(limits=c(0.8,2.5))#调整x轴的显示
桑基图

相关文章

网友评论

      本文标题:桑基图

      本文链接:https://www.haomeiwen.com/subject/iiauektx.html