目的:统计多个样品中共有或独有的 OTU 数目
输入文件为每个样品聚类后的otu 文件,格式如下:
sp1 sp2 sp3 sp4
OTU_1 标准化后的count数
OTU_10
前期的数据处理这里不做详解,贴出重要的两部分
> head(dataT)
gROUP1 gROUP2
OTU_1 0.25636057 0.402061905 (同个组多个样本的平均值apply(a, 1, function(x) tapply(x, colnames(a), mean))
OTU_10 0.05238824 0.044303876
OTU_100 0.02537350 0.002034943
### 构建venn 图的输入文件
vennlist = list()
for (i in 1:ncol(dataT)) {
tmpcolname = row.names(dataT[dataT[,i]>0,])
vennlist[[colnames(dataT)[i]]] = tmpcolname
}
###plot
venn.diagram(vennlist, filename = output, height=5, width=5, resolution = 300, fill = mycolor[1:2], main="Venn 图" ,alpha = 0.80, cat.col = mycolor[1:2],ontfamily = "serif",fontface = "plain",cex = 1.5, cat.cex = 1.2, cat.default.pos = "outer", cat.dist = 0.05, margin = 0.1, lty = "blank",, lwd = 3, imagetype = "svg")