==================================
P.copri abundance per cluster
==================================
clusters=read.table("microbiome_clustering/plots/MockData_species_PAM.txt",sep = "\t",header = T,stringsAsFactors = F)
clusters$sampleID=rownames(clusters)
> clusters
Cluster sampleID
Sample1 1 Sample1
Sample2 1 Sample2
cluster_plot=merge(clusters,dag3_species[,"Prevotella_copri",drop=F],by.x="sampleID",by.y = "row.names",all=F)
> cluster_plot
sampleID Cluster Prevotella_copri
1 Sample1 1 0.071806
2 Sample10 1 0.071623
cluster_plot=merge(clusters,dag3_species[,"Prevotella_copri",drop=F],by.x="sampleID",by.y = "row.names",all=F)
cluster_plot$Cluster=factor(cluster_plot$Cluster,levels = c("2","1"))
cluster_plot[cluster_plot==0]=NA
cluster_plot=na.omit(cluster_plot)
cluster_plot$Prevotella_copri=-log2(cluster_plot$Prevotella_copri)
cluster_plot[is.na(cluster_plot)]=0
g <- ggplot(cluster_plot, aes(x=Cluster, y=Prevotella_copri,fill=Cluster)) +
geom_violin()+
geom_boxplot(width=0.1, fill="white")+scale_fill_npg()+theme_classic()+ylab("Prevotella Copri, Norm. Rel. Abundance (-log2)")
print(g)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/925316fadbc38ce7324e3cffbb29501b.png#pic_center)