- 读取各个数据集的差异分析结果。
GSE1 <- read.csv('diffSig.csv', header = T, row.names = 1)
GSE1 $Gene <- rownames(GSE1 )
GSE1 $GSE <- 'GSE1 '
colnames(GSE1 )
GSE1 <- subset(GSE1 select = c("Gene", "GSE", "logFC") )
head(GSE1 )
- 将读取的差异分析结果合并,并将其分为上调和下调两个数据集
# --------------------------------------------------------
# --------------------------------------------------------
data <- rbind(dt1, dt2, dt3....)
table(data$GSE)
data1 <- subset(data, data$logFC > 0)
data2 <- subset(data, data$logFC < 0)
data1$logFC <-NULL
data2$logFC <-NULL
dt1 <- as.data.frame(table(data1$GSE))
dt1$sig <- 'Up-regulation'
dt2 <- as.data.frame(table(data2$GSE))
dt2$Freq <- -(dt2$Freq)
dt2$sig <- 'Down-regulation'
- 绘图
p <- ggplot()
geom_bar(data = dt1, aes(x=Var1, y=Freq, fill=sig),stat = "identity",position = 'dodge')
geom_text(data = dt1, aes(x=Var1, y=Freq, label=Freq, vjust=-0.25))
geom_bar(data = dt2, aes(x=Var1, y=Freq, fill=sig),stat = "identity",position = 'dodge')
geom_text(data = dt2, aes(x=Var1, y=Freq, label=Freq, vjust=-0.25))
scale_fill_manual(values=c("#0072B5","#BC3C28"))
theme(axis.text.x = element_text(angle = 45, hjust = 0.5, vjust=0.5)) xlab('') ylab('')
pdf(file = "deg_show.pdf",width=6,height=6)
p
dev.off()
基于此,就可以得到一张专门展示多个数据集差异分析结果统计的图,红色为每个数据集上调的基因数目。绿色为下调的基因数目。