然后使用如下代码进行作图
infile <- "draw_pre_violin_heatmap.txt"
data <- read.table(infile,header=TRUE,sep="\t")
data$group <- factor(data$group,levels=c("WT","TG","M"),ordered=TRUE)
data$pathway <- factor(data$pathway,levels=unique(data$pathway))
data$type <- factor(data$type,levels=c("inflammatory"),ordered=TRUE)
p <- ggplot(data,aes(x=group,y=exp_mean)) +
geom_violin(fill="#C7B3E5",color="#C7B3E5",trim=F,alpha=0.2,width=0.8) +
geom_segment(aes(x=x,xend=xend,y=y,yend=yend,color=pathway),size=0.5) +
geom_point(aes(fill=pathway),shape=21,size=2,color="black") +
ylim(-0.5,0.4) +
theme_bw() +
scale_fill_manual(values=c(colorRampPalette(brewer.pal(9,"Reds")[c(4,6)])(7)
)) +
scale_color_manual(values=c(colorRampPalette(brewer.pal(9,"Reds")[c(4,6)])(7)
)) +
ylab("GSVA Enrichment Score") +xlab("Sample Group")
ggsave("violin_filter.pdf",p,height=5,width=10)
p2 <- p +theme(legend.position="none")
ggsave("violin_filter_nolab.pdf",p2,height=5,width=4)