||
#根据OTU算top100菌群相对丰度值
#library(tidyverse)
rm(list = ls())
df<-read.csv("1.csv",header = TRUE,row.names = 1,
stringsAsFactors = FALSE)
sample<-colnames(df)[sapply(df,is.numeric)]
sample
temp<-df[,sample]
df$sum <-rowSums(temp,na.rm = T)
df<-df[order(df$sum,decreasing = T),]
df1<-df[1:100,]
df1<-na.omit(df1)
df2<-df[100+1:nrow(df),]
df1["Others",]<-colSums(df2,na.rm = T)
df_per<-sweep(df1,2,colSums(df),"/")
df_per1<-df_per*100
write.csv(df_per1,"top100.csv")
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-11-23 11:19
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社