From ddd8b5945f174efdfa983205aef1658a97681f2e Mon Sep 17 00:00:00 2001 From: ashleyshade Date: Wed, 21 May 2014 14:07:09 -0400 Subject: [PATCH] Remove file .Rapp.history --- SupplementalMaterials_Rscript/.Rapp.history | 114 -------------------- 1 file changed, 114 deletions(-) delete mode 100644 SupplementalMaterials_Rscript/.Rapp.history diff --git a/SupplementalMaterials_Rscript/.Rapp.history b/SupplementalMaterials_Rscript/.Rapp.history deleted file mode 100644 index 655ffde..0000000 --- a/SupplementalMaterials_Rscript/.Rapp.history +++ /dev/null @@ -1,114 +0,0 @@ -This is a script for detecting conditionally rare taxa in a dataset. # -#Written by A. Shade 30 May 2013, to accompany the #manuscript: "Conditional rarity drives temporal patterns of #microbial diversity." # -#This script comes with no warranty.# -#Questions? shade.ashley@gmail.com# -# -#Please install the required R packages: vegan, TSA# -library(vegan)# -library(TSA)# -# -#The input file for this script is: An OTU (taxa) table, with samples in columns and taxa in rows. The first row should include column names. The first column should have taxa (OTU) IDs. The first cell (row 1, col 1) should be empty. It is optional that the last column contains taxonomic assignments of each OTU. # -# -#The user can define the thresholds of the coefficient of bimodality (b_thresh, default = 0.005), and the relative abundance maximum (abund_thresh, default = 0.90). # -# -#This script will print the proportion of conditionally rare taxa detected in the dataset in the R console. It will also output a file of the OTU IDs, and, if provided, the taxonomic assignments of those OTUs, for the conditionally rare taxa.# -#The L4 English Channel dataset is provided as an example.# -# -#Place the input file and script in the same working directory to run this script.# -# -otu_fp="InputFile_EnglishChannel_L4.txt"# -rdp_lastcol=TRUE# -abund_thresh=0.005# -b_thresh=0.90# -# -o=SimpleRareToPrev.f(otu_fp,abund_thresh=0.005, b_thresh=0.90, rdp_lastcol=TRUE)# -#function to make relative abundance table - load into workspace# -makeRFtable.f=function(data){# - cSum1<-colSums(data)# - #define an empty matrix to put your RF values into# - newdata<-matrix(0,dim(data)[1], dim(data)[2])# - #Assign the same column and row names to the new matrix.# - colnames(newdata)<-colnames(data)# - rownames(newdata)<-rownames(data)# - #Each cell will be divided by the column sum.# - for (i in 1:length(data)){# - newdata[,i] <- data[,i]/cSum1[i]# - }# - return(newdata)# -}# -#### -#Rare to Prevalent OTUs# -SimpleRareToPrev.f=function(otu_fp,map_fp,abund_thresh = 0.005, b_thresh = 0.90, rdp_lastcol=TRUE){# - #Read in files# - otu=read.table(otu_fp, header=TRUE, check.names=FALSE, row.names=1, sep="\t")# - #If provided, remove rdp ids and save# - if(rdp_lastcol==TRUE){# - rdp=otu[,ncol(otu)]# - otu=otu[,-ncol(otu)]# - }# - #remove empty rows# - tmp=otu[rowSums(otu)>0,]# - no.otus=nrow(tmp)# - if(rdp_lastcol==TRUE){# - rdp2=rdp[rowSums(otu)>0]# - }# - #Remove singletons# - otu.nosigs=tmp[rowSums(tmp)>1,]# - if(rdp_lastcol==TRUE){# - rdp3=rdp2[rowSums(tmp)>1]# - }else{# - rdp3=NULL# - }# - #how many are left after singletons?# - no.sigs=nrow(otu.nosigs)# - #Make a rel abundance table - with the full dataset# - otu.rel=makeRFtable.f(tmp)# - #reduce the rel. abundance table to omit singletons# - otu.rel2=otu.rel[is.element(row.names(otu.rel), row.names(otu.nosigs)),]# - #loop for each OTU to calculate Coefficent of bimodality# - #For efficiency, loops through singleton-omitted dataset (singletons will not have rare-to-prevalent dynamics)# - out=NULL# - for(j in 1:nrow(otu.nosigs)){# - x=as.numeric(otu.nosigs[j,])# - k=kurtosis(x)# - s=skewness(x)# - #calculate the coefficient of bimodality for each OTU# - b=(1+(s^2))/(k+3)# - #determine whether OTU max and median relative abundance (based on full dataset, otu.rel)# - x2=as.numeric(otu.rel2[j,])# - mx.rel=max(x2)# - med.rel=median(x2)# - out=rbind(out,c(row.names(otu.nosigs)[j],b,mx.rel, med.rel))# - }# - #print(dim(out))# - #print(head(out))# - out=as.data.frame(out)# - colnames(out)=c("OTUID","CoefficientOfBimodality","MaxRel", "MedianRel")# - if(rdp_lastcol==TRUE){# - out=cbind(out, rdp3)# - colnames(out)[5]="TaxonomicAssignment"# - }# - #Filter 1: for at least one rel. abundance greater than abund_thresh (default = 0.005)# - out.filter=out[as.vector(out[,"MaxRel"]) >= abund_thresh,]# - print(dim(out.filter))# - #Filter 2: for coefficient of bimodality greater than b_thresh (default = 0.90)# - out.filter=out.filter[as.vector(out.filter[,"CoefficientOfBimodality"]) >= b_thresh,]# - print(dim(out.filter))# - write.table(out.filter, paste("ResultsFile_ConditionallyRareOTUID_", abund_thresh, "_", b_thresh, ".txt", sep=""), quote=FALSE, sep="\t", row.names=FALSE)# - print("No. conditionally rare OTUs")# - print(nrow(out.filter))# -# - print("No. total OTUs")# - print(no.otus)# -# - print("Proportion conditional rare / total OTUs")# - print(nrow(out.filter)/no.otus)# - print("No singleton OTUs")# - print(no.sigs)# - print("Proportion conditionally rare / non-singletonOTUs")# - print(nrow(out.filter)/no.sigs)# - return(out.filter)# -} -o -source("CRT_Functions.R") -SimpleRareToPrev.f(otu_fp="InputFile_EnglishChannel_L4.txt",abund_thresh=0.005, b_thresh=0.90, rdp_lastcol=TRUE)