pangxie的个人博客分享 http://blog.sciencenet.cn/u/pangxie

博文

qiime2的richness指数

已有 2178 次阅读 2021-2-6 17:48 |个人分类:R语言|系统分类:科研笔记

#原文链接https://mp.weixin.qq.com/s/nB7cPb0ij0srVc_v_KG0AQ

otu_table.tsv

group.xls

rm(list=ls())

library(tidyverse)

library(magrittr)

library(ggsci)

library(ggpubr)

otu <- read.delim("otu_table.tsv",header = T,sep="\t",

                  check.names = F,row.names = 1)


richness <- NULL

for (i in seq_len(ncol(otu))) {

  richness <- c(richness,which(otu[,i] !=0) %>% length())

}


names(richness) <- otu %>% colnames() 


richness <- richness %<>% data.frame(sample= names(.),value = .)


richness

#p <- richness %<>% data.frame(names(.),.) %>% 

#  set_colnames(c("sample","value"))


group <- read.delim("group.xls",header = T,sep="\t",check.names = F)


colnames(richness)[1] <- colnames(group[1])


full_join(richness,group) %>%

  mutate(V4="richness") %>%

  ggplot(aes(group,value,fill=group))+

  scale_fill_nejm()+

  geom_violin(trim=FALSE)+

  geom_boxplot(width=0.1,fill="white")+

  facet_grid(. ~V4,scales = "free",space="free_x")+

  xlab(NULL)+ylab(NULL)+

  theme_bw()+

  theme(legend.position = "none",

        axis.text.x=element_text(angle =0,hjust=0.5,vjust=0.5,

                                 colour = "black",size=8),

        strip.text.x = element_text(colour ="black",size=13))+

  stat_compare_means(method = "anova",label.y =1000,label.x = 2,size=5)


Rplot08.png






https://blog.sciencenet.cn/blog-3448646-1270950.html

上一篇:alpha多样性指数绘图
下一篇:差异分析检验流程
收藏 IP: 125.210.251.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...
扫一扫,分享此博文

全部作者的其他最新博文

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-12-29 07:22

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部