sys_home<-Sys.getenv("HOME") if(sys_home=="/Users/prosikie"){home_path<-"/Users/prosikie/Desktop/new_december"} if(sys_home=="/home/mrosikie"){home_path<-"/home/mrosikie"} project_path<-file.path(home_path,"documentation","meta_suez") setwd(project_path) annot_table<-read.csv(file.path(project_path,"annotations","meta_suez_annot_table_all.csv"),as.is=T) rownames(annot_table)<-annot_table[,1] ############ #results of global_search function 2_97 output_folder<-file.path(project_path,"vsearch_data_November2017","OTU_tables_vsearch_centr_min2_97") OTU_folder_2_97<-file.path(project_path,"vsearch_data_November2017","meta_suez_search_table_vsearch_centr_min2_97") #list to read in results OTU_search_data_list_2_97<-list() #samples read in for(xx in 1:nrow(annot_table)){ OTU_search_data_list_2_97[[xx]]<-read.table(file.path(OTU_folder_2_97,paste(annot_table[xx,1],"_vsearch_search_table_min2_97.txt",sep="")),as.is=T,sep="\t") } #getting names of all otus OTU_search_names_2_97<-OTU_search_data_list_2_97[[1]][,1] for (xx in 2:length(OTU_search_data_list_2_97)){ OTU_search_names_2_97<-union(OTU_search_names_2_97,OTU_search_data_list_2_97[[xx]][,1]) } #table merging OTU_search_table_2_97<-matrix(ncol=length(OTU_search_data_list_2_97),nrow=length(OTU_search_names_2_97)) rownames(OTU_search_table_2_97)<-OTU_search_names_2_97 colnames(OTU_search_table_2_97)<-annot_table[,1] for (xx in 1:length(OTU_search_data_list_2_97)){ OTU_search_table_2_97[OTU_search_data_list_2_97[[xx]][,1],xx]<-OTU_search_data_list_2_97[[xx]][,2] } #removing NA OTU_search_table_2_97[is.na(OTU_search_table_2_97)]<-0 output_folder<-file.path(project_path,"vsearch_data_November2017","OTU_tables_vsearch_centr_min2_97") write.table(OTU_search_table_2_97, file=file.path(output_folder, "meta_suez_OTU_search_table_centr_2_97.txt"),sep="\t",quote=F) write.csv(OTU_search_table_2_97,file=file.path(output_folder,"meta_suez_OTU_search_table_centr_2_97.csv"),quote=F) save(OTU_search_table_2_97,file=file.path(output_folder,"meta_suez_OTU_search_table_centr_2_97.RData"))