# This script helps to identify in which group there is the maximal abundance of each OTU, and relocate OTUs, in this case, based on the sample type: breading sites, larvae or adults. "shared" is referred to the table containing all OTUs common to the three sample types (BsLA). otu1<-shared mx1<-apply(otu1,2,max) n<-nrow(otu1) mxx1<-do.call("rbind", replicate(n,mx1,simplify=FALSE)) xxx1<-ifelse(otu1==mxx1,1,0) names(env) otu1<-as.data.frame(as.matrix(xxx1)) class <- NULL for (i in 1:length(names(otu1))){ if(sum(subset(otu1[,i],subset=env$Samp_type == 'BS'))>0) class[i]<-"BSmax" else if (sum(subset(otu1[,i], subset=env$Samp_type == 'Larva'))>0) class[i]<-'Larvamax' else if (sum(subset(otu1[,i], subset=env$Samp_type == 'Adult'))>0) class[i]<-'Adultmax' else class[i]<-'Other' }