處理數(shù)據(jù)list
library(VennDiagram)
#導入數(shù)據(jù),下調(diào)數(shù)據(jù)
1d <- read.table("...diff/1_DEseq2.DEG_down.xls", sep='\t', header=T)
2d <- read.table("...diff/2_DEseq2.DEG_down.xls", sep='\t', header=T)
3d <- read.table("...diff/3_DEseq2.DEG_down.xls", sep='\t', header=T)
4d <- read.table("...diff/4_DEseq2.DEG_down.xls", sep='\t', header=T)
類似地,導入 #上調(diào)數(shù)據(jù) #全部數(shù)據(jù)
然后可以做成表,寫出數(shù)據(jù)后分別查看1U2,1U2U3集合內(nèi)容
#做成表
input_down <-list(1d$gene_id,2d$gene_id,3d$gene_id,4d$gene_id)
Table_down<-calculate.overlap(input_down)
input_up <-list(1d$gene_id,2d$gene_id,3d$gene_id,4d$gene_id)
Table_up<-calculate.overlap(input_up)
#寫出投加共同上調(diào)or下調(diào)的表格
write.table(Table_down$“你需要的組合”, file = "mutually down-DESeq2.csv", sep = ",", col.names = NA,qmethod = "double")
繪制Venn圖
#繪制Venn圖
up<-venn.diagram(input_up,NULL, main.cex = 2,
category = c("1d", "2d", "3d","4d"),fill = c("dodgerblue", "green", "orange", "darkorchid4"),
alpha=0.3, cex=1.5, cat.fontface=2, cat.cex = 1, cat.col= c("dodgerblue", "green", "orange", "darkorchid4"), imagetype = "tiff", ext.line.lty = "dotted", lty = "dotted",
ext.line.lwd = 0.5,force.unique = F, lwd = 1, main.fontfamily="serif", main = "Up-regulated") #, filename = "Vennup.tif"
down<-venn.diagram(input_down,main.cex = 2,
category = c("1d", "2d", "3d","4d"),fill = c("dodgerblue", "green", "orange", "darkorchid4"),
alpha=0.3, cex=1.5, cat.fontface=2, cat.cex = 1, cat.col= c("dodgerblue", "green", "orange", "darkorchid4"), imagetype = "tiff", ext.line.lty = "dotted", lty = "dotted",
ext.line.lwd = 0.5,force.unique = F, lwd = 1, main.fontfamily="serif", main = "Down-regulated", filename = "Venndown.tif")
分別得到一張上調(diào)Venn圖和一張下調(diào)Venn圖,用grid.draw()命令可以查看效果
使用pheatmap繪制heatmap
library(pheatmap)
x<-read.table("Union_for_cluster.xls", sep = "\t", header=T, row.names = 1)
x<-pheatmap(x, clustering_distance_rows = "euclidean", clustering_distance_cols = "euclidean"
,annotation_row = NA, cellwidth = 15,show_rownames = F, drop_levels = F
,clustering_method = "average", scale = "row")
#the agglomeration method should be one of "ward.D", "ward.D2", "single","complete", "average" (= UPGMA), "mcquitty" (= WPGMA), "median" (= WPGMC) or "centroid" (= UPGMC).
把兩張Venn圖和一張heatmap圖組合在一起
這件事費了我好大功夫啊……本來想看看Y叔有什么神奇的辦法,因為自己是個半吊子,但是看了聽說你還不會畫heatmap以后也沒學會,Y叔說可以用cowplot包,plot_grid這個函數(shù)可以拼一切基于grid的圖。pheatmap是可以,但是VennDiagram生成對象是gList,用plot_grid()這個命令沒辦法處理gList,不停報錯(差點掀桌),沒辦法,只好自己慢慢啃呲(誰讓我是半瓶水呢)。
grid.newpage()
pushViewport(plotViewport(layout=grid.layout(2, 2,just = "centre")))
pushViewport(plotViewport(layout.pos.row=1, layout.pos.col=1))
grid.draw(up)
popViewport()
pushViewport(plotViewport(layout.pos.row=2, layout.pos.col=1, clip="on"))
grid.draw(down)
popViewport()
pushViewport(plotViewport(layout.pos.col=2, clip="inherit"))
grid.draw(x$gtable)
popViewport()

image.png
好了,因為用了自己的數(shù)據(jù)所以只能傳一張高糊圖片,總之最終效果就是左邊2張Venn右邊1張heatmap