富集结果桑基图展示
suppressMessages({
library(tidyverse)
library(ggsankey)
library(cols4all)
#BiocManager::install("dittoSeq")
library(dittoSeq)
library(argparser)})
argv <- arg_parser('')
argv <- add_argument(argv,"--stat", help="the stat file")
argv <- add_argument(argv,"--type", help="the plot type")
argv <- add_argument(argv,"--prefix", help="the prefix of outfile")
argv <- parse_args(argv)
stat <- argv$stat
type <- argv$type
prefix <- argv$prefix
stat_frame <- read.delim(stat,head=TRUE,sep='\t',quote='')
if (type=='GO') {
data <- dplyr::select(stat_frame, geneName, Description)%>%
separate_rows(geneName, sep = '/')
colnames(data) <- c('gene', 'pathway')
}
if (type=='KEGG') {
data <- dplyr::select(stat_frame, geneName, Description)%>%
separate_rows(geneName, sep = '/')
colnames(data) <- c('gene', 'pathway')
}
data2 <- make_long(data, gene, pathway )
p <- ggplot(data2, aes(x = x,
next_x= next_x,
node= node,
next_node= next_node,
fill= node,
label= node)) +
geom_sankey(flow.fill="#DFDFDF",
flow.color="grey60",
node.fill=dittoColors()[1:length(unique(data2$node))],
width=0.15) +
geom_sankey_text(size = 4,
color= 'black',
hjust=1) +
theme_void()
pdf(file=paste(prefix,'.pdf',sep=''))
p
dev.off()
svg(filename=paste(prefix,'.svg',sep=''))
p
dev.off()
ggsave(file=paste(prefix,'.png',sep=''),type='cairo-png',plot=p)
展示图
右图为文献中的图,可以将左图与结果中气泡图结合在一起,复现右图