setwd("~/TTU Research/JakeLeys/2018_microbiomepaper/190128_analyses") library(vegan) library(plyr) library(dplyr) library(ggplot2) library(rcompanion) library(car) library(gridExtra) citation("vegan") citation("plyr") citation("dplyr") citation("ggplot2") citation("rcompanion") citation("car") citation("gridExtra") ################################################################################################# #Beta diversity - test to determine if skin, soil, water is predictive of the microbiome######### ################################################################################################# #read in complete dataframe including skin, soil, water samples env.skin.dat <- read.csv("170912_LEYS_SHARED_SUB_INCLUDES_FACTORS_SupplementalFile1.csv", header=T, row.names=NULL) #use this function to count any desired OTU read number in sample source (e.g. indicator taxa) aggregate(Otu26160 ~ sample.source, data = env.skin.dat, sum) #create supplemental table of study design sup.table<-rename(count(env.skin.dat, species, state, tn.ecoregion, ecomode, Oo), Freq = n) write.csv(sup.table, file='supplemental_table_samplecounts.csv') #counting sample numbers for methods section sup.table2<-rename(count(env.skin.dat, species, Oo), Freq = n) write.csv(sup.table2, file='temp.csv') count(env.skin.dat, tn.ecoregion) #create otus dataframe for skin, soil, water samples env.skin.dat.otus <- env.skin.dat[15:16026] #create factors for skin, soil, water sample source samplesource <- as.factor(env.skin.dat$sample.source) #permanova to test if skin, soil, water is predictive of the microbiome bray.env.skin.dat.otus <- vegdist(env.skin.dat.otus, method="bray",na.rm=TRUE) adonis(bray.env.skin.dat.otus~samplesource, data=env.skin.dat.otus, permutations = 999, method='bray') #run NMDS and plot in ggplot2 samplesource.nmds<-metaMDS(env.skin.dat.otus, distance = "bray", k=2, try=20, trymax=999) data.scores <- as.data.frame(scores(samplesource.nmds)) #Using the scores function from vegan to extract the site scores (rows) and convert to a data.frame data.scores data.scores$site <- rownames(data.scores) # create a column of site names, from the rownames of data.scores data.scores$Sample <- samplesource # add factor data for graphing purposes head(data.scores) #look at the data tail(data.scores) species.scores <- as.data.frame(scores(samplesource.nmds, "species")) #Using the scores function from vegan to extract the species scores and convert to a data.frame species.scores$species <- rownames(species.scores) # create a column of species, from the rownames of species.scores head(species.scores) f1<-ggplot() + geom_text(data=species.scores,aes(x=NMDS1,y=NMDS2,label=species),alpha=0.5) # add the species labels f1<-ggplot()+geom_point(data=data.scores,aes(x=NMDS1,y=NMDS2, shape=Sample, colour=Sample),size=2) # add the point markers #f1<-f1+geom_text(data=data.scores,aes(x=NMDS1,y=NMDS2,label=samplesource),size=4,vjust=1) # add the site labels f1<-f1+scale_shape_manual(values=c(15,17,3)) f1 #theme(axis.text.x = element_blank(), # remove x-axis text #axis.text.y = element_blank(), # remove y-axis text #axis.ticks = element_blank(), # remove axis ticks #axis.title.x = element_text(size=18), # remove x-axis labels #axis.title.y = element_text(size=18), # remove y-axis labels f1<-f1+theme(panel.background = element_blank(), panel.grid.major = element_blank(), #remove major-grid labels panel.grid.minor = element_blank(), #remove minor-grid labels plot.background = element_blank()) f1 ################################################################################################ #Since sample source is predictive of the skin microbiome####################################### #Use indicator analysis to select OTUs indicative of the snake skin microbiome################## ################################################################################################ #indicator analysis performed in mothur using cutoff criteria p < 0.005, Indicator value > 30 skin.dat.indicator <- select(env.skin.dat, sample, sample.source, species, Oo, state, site, tn.ecoregion, month, year, ct, copy.number, ecomode, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) skin.dat.indicator.otus <- select(skin.dat.indicator, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) write.csv(skin.dat.indicator, file='skin.dat.indicator.csv') #remove rows that have OTU relative abundances that sum to zero skin.dat.indicator.removezeros<-skin.dat.indicator[as.logical(rowSums(skin.dat.indicator.otus != 0)), ] #Didn't remove a single sample. Interesting. #So, even if the OTU is predictive of the skin, it still occurs in the soil #Ran Venn diagrams in mothur to depict this relationship ################################################################################################ #MACROSCALE COMPARISONS ACROSS STATES########################################################### #Using indicator OTUs########################################################################### ################################################################################################ #create dataframe of only skin samples skinonly.dat.indicator <- select(env.skin.dat, sample, species, sample.source, Oo, state, site, tn.ecoregion, month, year, ct, copy.number, ecomode, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) skinonly2.dat.indicator <- subset(skinonly.dat.indicator, sample.source=="skin") skinonly2.dat.indicator.otus <- select(skinonly2.dat.indicator, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) #create factors for macroscale skin analysis species <- as.factor(skinonly2.dat.indicator$species) state <- as.factor(skinonly2.dat.indicator$state) month <- as.factor(skinonly2.dat.indicator$month) year <- as.factor(skinonly2.dat.indicator$year) ecomode <- as.factor(skinonly2.dat.indicator$ecomode) oo.status <- as.factor(skinonly2.dat.indicator$Oo) #permanova to test factors species*state*month*year*Oo status are predictive of the skin microbiome bray.skinonly2.dat.indicator.otus <- vegdist(skinonly2.dat.indicator.otus, method="bray",na.rm=TRUE) adonis(bray.skinonly2.dat.indicator.otus~species*state*month*year*oo.status, data=skinonly2.dat.indicator.otus, permutations = 999, method='bray') #Removing interactions from model that are not significant adonis(bray.skinonly2.dat.indicator.otus~species+state+month+year+oo.status+species:state+species:month+state:month+species:year+month:year+month:oo.status+species:month:oo.status, data=skinonly2.dat.indicator.otus, permutations = 999, method='bray') #Removing interactions from model that are not significant adonis(bray.skinonly2.dat.indicator.otus~species+state+month+year+oo.status+species:state+species:month+state:month+species:year+month:oo.status+species:month:oo.status, data=skinonly2.dat.indicator.otus, permutations = 999, method='bray') ##permanova to test factors ecomode*Oo status are predictive of the skin microbiome (swap out species for lifehistory "ecomode") adonis(bray.skinonly2.dat.indicator.otus~ecomode*oo.status, data=skinonly2.dat.indicator.otus, permutations = 999, method='bray') #betadisper to determine homogeneity of ecomode groups visualized by nmds macro.betadisper <- with(skinonly2.dat.indicator, betadisper(bray.skinonly2.dat.indicator.otus, ecomode)) macro.betadisper permutest(macro.betadisper) TukeyHSD(macro.betadisper) plot(macro.betadisper, label = F, hull = F, ellipse = T) boxplot(macro.betadisper) #run NMDS and plot in ggplot2 #Stress value is 0.23 - not great but there's a pattern when graphing ecomode skinonly2.dat.indicator.nmds<-metaMDS(skinonly2.dat.indicator.otus, distance = "bray", k=2, try=20, trymax=999) data.scores2 <- as.data.frame(scores(skinonly2.dat.indicator.nmds)) #Using the scores function from vegan to extract the site scores (rows) and convert to a data.frame data.scores2 data.scores2$site <- rownames(data.scores2) # create a column of site names, from the rownames of data.scores data.scores2$Species <- species # add factor data for graphing purposes data.scores2$Month <- month # add factor data for graphing purposes data.scores2$State <- state # add factor data for graphing purposes data.scores2$Ecomode <- ecomode # add factor data for graphing purposes data.scores2$Oo.status <- oo.status # add factor data for graphing purposes head(data.scores2) #look at the data tail(data.scores2) species.scores2 <- as.data.frame(scores(skinonly2.dat.indicator.nmds, "species")) #Using the scores function from vegan to extract the species scores and convert to a data.frame species.scores2$species <- rownames(species.scores2) # create a column of species, from the rownames of species.scores head(species.scores2) macro1<-ggplot() + geom_text(data=species.scores2,aes(x=NMDS1,y=NMDS2,label=species),alpha=0.5) # add the species labels macro1<-ggplot()+geom_point(data=data.scores2,aes(x=NMDS1,y=NMDS2, colour=Ecomode),size=2) # add the point markers macro1<-macro1+theme_classic() macro1<-macro1+theme(legend.position="none") #remove this line if you want a legend - did this for multipanel figure macro1<-macro1+ggtitle("Macroscale - Southeastern USA") + theme(plot.title = element_text(hjust = 0.5)) macro1 ############################# ####DISEASE - MACROSCALE##### #Using indictors for Ophidiomyces state create dataframe of only skin samples at the MACROSCALE ############################# macro.sfd <- select(env.skin.dat, sample, species, sample.source, Oo, state, site, tn.ecoregion, month, year, ct, copy.number, ecomode, Otu00597, Otu00628, Otu00149, Otu00450, Otu00034, Otu00452, Otu00316, Otu00125, Otu00127, Otu00124, Otu00056, Otu00389, Otu00066, Otu00258, Otu00021, Otu00006) macro2.sfd <- subset(macro.sfd, sample.source=="skin") macro2.sfd.otus <- select(macro2.sfd, Otu00597, Otu00628, Otu00149, Otu00450, Otu00034, Otu00452, Otu00316, Otu00125, Otu00127, Otu00124, Otu00056, Otu00389, Otu00066, Otu00258, Otu00021, Otu00006) #dbRDA using capscale function in vegan to model OTU data on continuous variable of Ophidiomyces copy number plotNormalHistogram(macro2.sfd$copy.number) #Data are right skewed macro.copy.number.sfd.cubed <- sign(macro2.sfd$copy.number) * abs(macro2.sfd$copy.number)^(1/3) #cubed root transform plotNormalHistogram(macro.copy.number.sfd.cubed) #plot - a little better but still skewed plotNormalHistogram(macro2.sfd.otus) #data are right skewed macro2.sfd.otus.cubed <- sign(macro2.sfd.otus) * abs(macro2.sfd.otus)^(1/3) #cubed root transform plotNormalHistogram(macro2.sfd.otus.cubed) #plot - a little better but still skewed macro.sfd.capscale <- capscale(macro2.sfd.otus.cubed ~ macro.copy.number.sfd.cubed, macro2.sfd, dist="bray") macro.sfd.capscale plot(macro.sfd.capscale) anova(macro.sfd.capscale) permutest(macro.sfd.capscale) #DISEASE- MACROSCALE - plot capscale results with ggplot2 macro.smry <- summary(macro.sfd.capscale) macro.smry macro.df1 <- data.frame(macro.smry$sites[,1:2]) # CAP1 and MDS1 macro.oo <- as.factor(macro2.sfd$Oo) #create factor to graph macro.df1$Ophidiomyces <- macro.oo macro.df2 <- data.frame(macro.smry$species[,1:2]) # loadings for CAP1 and MDS1 macro.df1 macro.df2 macro.cap.plot <- ggplot(macro.df1, aes(x=CAP1, y=MDS1, colour=Ophidiomyces)) + geom_point(aes(label=rownames(macro.df1)),size=2) + geom_hline(yintercept=0, linetype="dotted") + geom_vline(xintercept=0, linetype="dotted") + xlim(-3,4)+ ylim(-2,3) #coord_fixed() macro.cap.plot macro.cap.plot<-macro.cap.plot+theme_classic() macro.cap.plot macro.cap.biplot <- macro.cap.plot + geom_text(data=macro.df2, aes(x=CAP1,y=MDS1,label=rownames(macro.df2), hjust=0.5*(1-sign(CAP1)),vjust=0.5*(1-sign(MDS1))), color="black", size=2) macro.cap.biplot<-macro.cap.biplot+theme(legend.position="none") #remove this line if you want a legend - did this for multipanel figure macro.cap.biplot<-macro.cap.biplot+ggtitle("Macroscale - Southeastern USA") + theme(plot.title = element_text(hjust = 0.5)) macro.cap.biplot ####################################### #MACROSCALE - assessing ALPHA DIVERSITY #Using indicator taxa for skin ####################################### #create dataframe of only skin samples skinonly.dat.indicator <- select(env.skin.dat, sample, species, sample.source, Oo, state, site, tn.ecoregion, month, year, ct, copy.number, ecomode, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) skinonly2.dat.indicator <- subset(skinonly.dat.indicator, sample.source=="skin") skinonly2.dat.indicator.otus <- select(skinonly2.dat.indicator, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) macro.invsimp <- diversity(skinonly2.dat.indicator.otus, "inv") hist(macro.invsimp, main="Inverse Simpson", xlab="", breaks=10) #visualize distribution shapiro.test(macro.invsimp) #test for normalcy statistically - run the Shapiro-Wilk test of normality. #test alpha for SPECIES - MACROSCALE kruskal.test(macro.invsimp ~ species, data=skinonly2.dat.indicator) #species is statistically significant #Create 1x1 plot environment par(mfrow = c(1, 1)) #Plot boxplot(macro.invsimp ~ species, data=skinonly2.dat.indicator, ylab="Inverse Simpson", las=2, cex.axis=0.8) #test alpha for ECOMODE - MACROSCALE kruskal.test(macro.invsimp ~ ecomode, data=skinonly2.dat.indicator) #ecomode is statistically significant #Create 1x1 plot environment par(mfrow = c(1, 1)) #Plot boxplot(macro.invsimp ~ ecomode, data=skinonly2.dat.indicator, ylab="Inverse Simpson", las=2, cex.axis=0.8) #test alpha for Ophidiomyces presence - MACROSCALE kruskal.test(macro.invsimp ~ Oo, data=skinonly2.dat.indicator) #Ophidiomyces presence is NOT statistically significant #Create 1x1 plot environment par(mfrow = c(1, 1)) #Plot boxplot(macro.invsimp ~ Oo, data=skinonly2.dat.indicator, ylab="Inverse Simpson", las=2, cex.axis=0.8) ################################################################################################ #MESOSCALE COMPARISONS ACROSS ECOREGIONS OF TENNESSEE########################################### #Using indicator OTUs########################################################################### ################################################################################################ #create dataframe of only skin samples for Tennessee tn.skinonly.dat.indicator <- select(env.skin.dat, sample, species, sample.source, Oo, state, site, tn.ecoregion, month, year, ct, copy.number, ecomode, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) tn.skinonly2.dat.indicator <- subset(tn.skinonly.dat.indicator, sample.source=="skin") tn.skinonly3.dat.indicator <- subset(tn.skinonly2.dat.indicator, state=="TN") tn.skinonly3.dat.indicator.otus <- select(tn.skinonly3.dat.indicator, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) #create factors for mesoscale skin analysis tn.species <- as.factor(tn.skinonly3.dat.indicator$species) tn.ecoregion <- as.factor(tn.skinonly3.dat.indicator$tn.ecoregion) tn.month <- as.factor(tn.skinonly3.dat.indicator$month) tn.year <- as.factor(tn.skinonly3.dat.indicator$year) tn.ecomode <- as.factor(tn.skinonly3.dat.indicator$ecomode) tn.oo.status <- as.factor(tn.skinonly3.dat.indicator$Oo) #permanova to test factors species*ecoregion*month*year*Oo status are predictive of the skin microbiome in Tennessee bray.tn.skinonly3.dat.indicator.otus <- vegdist(tn.skinonly3.dat.indicator.otus, method="bray",na.rm=TRUE) adonis(bray.tn.skinonly3.dat.indicator.otus~tn.species*tn.ecoregion*tn.month*tn.year*tn.oo.status, data=tn.skinonly3.dat.indicator.otus, permutations = 999, method='bray') #Remove non significant interaction factors from the model adonis(bray.tn.skinonly3.dat.indicator.otus~tn.species+tn.ecoregion+tn.month+tn.year+tn.oo.status+tn.species:tn.ecoregion+tn.species:tn.month+tn.month:tn.year+tn.species:tn.oo.status, data=tn.skinonly3.dat.indicator.otus, permutations = 999, method='bray') #Remove non significant interaction factors from the model adonis(bray.tn.skinonly3.dat.indicator.otus~tn.species+tn.ecoregion+tn.month+tn.year+tn.oo.status+tn.species:tn.ecoregion+tn.species:tn.month+tn.species:tn.oo.status, data=tn.skinonly3.dat.indicator.otus, permutations = 999, method='bray') #permanova to test factors ecomode*Oo status are predictive of the skin microbiome in Tennessee (swapping ecomode in for species) adonis(bray.tn.skinonly3.dat.indicator.otus~tn.ecomode*tn.oo.status, data=tn.skinonly3.dat.indicator.otus, permutations = 999, method='bray') #betadisper to determine homogeneity of ecomode groups visualized by nmds meso.betadisper <- with(tn.skinonly3.dat.indicator, betadisper(bray.tn.skinonly3.dat.indicator.otus, tn.ecomode)) meso.betadisper permutest(meso.betadisper) TukeyHSD(meso.betadisper) plot(meso.betadisper, label = F, hull = F, ellipse = T) boxplot(meso.betadisper) #run NMDS and plot in ggplot2 #Stress value is 0.22 tn.skinonly3.dat.indicator.nmds<-metaMDS(tn.skinonly3.dat.indicator.otus, distance = "bray", k=2, try=20, trymax=3000) data.scores3 <- as.data.frame(scores(tn.skinonly3.dat.indicator.nmds)) #Using the scores function from vegan to extract the site scores (rows) and convert to a data.frame data.scores3 data.scores3$site <- rownames(data.scores3) # create a column of site names, from the rownames of data.scores data.scores3$Species <- tn.species # add factor data for graphing purposes data.scores3$Month <- tn.month # add factor data for graphing purposes data.scores3$Ecoregion <- tn.ecoregion # add factor data for graphing purposes data.scores3$Ecomode <- tn.ecomode # add factor data for graphing purposes head(data.scores3) #look at the data tail(data.scores3) species.scores3 <- as.data.frame(scores(tn.skinonly3.dat.indicator.nmds, "species")) #Using the scores function from vegan to extract the species scores and convert to a data.frame species.scores3$species <- rownames(species.scores3) # create a column of species, from the rownames of species.scores head(species.scores3) meso<-ggplot() + geom_text(data=species.scores3,aes(x=NMDS1,y=NMDS2,label=species),alpha=0.5) # add the species labels meso<-ggplot()+geom_point(data=data.scores3,aes(x=NMDS1,y=NMDS2, colour=Ecomode),size=2) # add the point markers meso<-meso+theme_classic() meso<-meso+theme(legend.position="none") #remove this line if you want a legend - did this for multipanel figure meso<-meso+ggtitle("Mesoscale - Tennessee Ecoregion") + theme(plot.title = element_text(hjust = 0.5)) meso ############################# ####DISEASE - MESOSCALE###### #Using indictors for Ophidiomyces state create dataframe of only skin samples at the MACROSCALE ############################# meso.sfd <- select(env.skin.dat, sample, species, sample.source, Oo, state, site, tn.ecoregion, month, year, ct, copy.number, ecomode, Otu01032, Otu00206, Otu00684, Otu00149, Otu00597, Otu00022, Otu00571, Otu00124, Otu00452, Otu00316,Otu00162,Otu00125,Otu00066,Otu00075,Otu00258,Otu00021,Otu00006) meso2.sfd <- subset(meso.sfd, sample.source=="skin") meso3.sfd <- subset(meso2.sfd, state=="TN") meso3.sfd.otus <- select(meso3.sfd, Otu01032, Otu00206, Otu00684, Otu00149, Otu00597, Otu00022, Otu00571, Otu00124, Otu00452, Otu00316,Otu00162,Otu00125,Otu00066,Otu00075,Otu00258,Otu00021,Otu00006) #remove rows that have OTU relative abundances that sum to zero meso3.sfd.removezeros<-meso3.sfd[as.logical(rowSums(meso3.sfd.otus!= 0)),] #dbRDA using capscale function in vegan to model OTU data on continuous variable of Ophidiomyces copy number plotNormalHistogram(meso3.sfd$copy.number) #Data are right skewed meso.copy.number.sfd.cubed <- sign(meso3.sfd $copy.number) * abs(meso3.sfd $copy.number)^(1/3) #cubed root transform plotNormalHistogram(meso.copy.number.sfd.cubed) #plot - a little better but still skewed plotNormalHistogram(meso3.sfd.otus) #data are right skewed meso3.sfd.otus.cubed <- sign(meso3.sfd.otus) * abs(meso3.sfd.otus)^(1/3) #cubed root transform plotNormalHistogram(meso3.sfd.otus.cubed) #plot - a little better but still skewed meso.sfd.capscale <- capscale(meso3.sfd.otus.cubed ~ meso.copy.number.sfd.cubed, meso3.sfd, dist="bray") meso.sfd.capscale plot(meso.sfd.capscale) #uncertain why OTU labels aren't printing onto the plot anova(meso.sfd.capscale) #DISEASE- MESOSCALE - plot capscale results with ggplot2 meso.smry <- summary(meso.sfd.capscale) meso.smry meso.df1 <- data.frame(meso.smry$sites[,1:2]) # CAP1 and MDS1 meso.oo <- as.factor(meso3.sfd$Oo) #create factor to graph meso.df1$Ophidiomyces <- meso.oo meso.df2 <- data.frame(meso.smry$species[,1:2]) # loadings for CAP1 and MDS1 meso.df1 meso.df2 meso.cap.plot <- ggplot(meso.df1, aes(x=CAP1, y=MDS1, colour=Ophidiomyces)) + geom_point(aes(label=rownames(meso.df1)),size=2) + geom_hline(yintercept=0, linetype="dotted") + geom_vline(xintercept=0, linetype="dotted") + xlim(-3.3,4)+ ylim(-2,3) #coord_fixed() meso.cap.plot meso.cap.biplot <- meso.cap.plot + geom_text(data=meso.df2, aes(x=CAP1,y=MDS1,label=rownames(meso.df2), hjust=0.5*(1-sign(CAP1)),vjust=0.5*(1-sign(MDS1))), color="black", size=2) meso.cap.biplot<-meso.cap.biplot+theme_classic() meso.cap.biplot<-meso.cap.biplot+theme(legend.position="none") #remove this line if you want a legend - did this for multipanel figure meso.cap.biplot<-meso.cap.biplot+ggtitle("Mesoscale - Tennessee Ecoregion") + theme(plot.title = element_text(hjust = 0.5)) meso.cap.biplot ####################################### #MESOSCALE - assessing ALPHA DIVERSITY #Using indicator taxa for skin ####################################### #create dataframe of only skin samples for Tennessee tn.skinonly.dat.indicator <- select(env.skin.dat, sample, species, sample.source, Oo, state, site, tn.ecoregion, month, year, ct, copy.number, ecomode, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) tn.skinonly2.dat.indicator <- subset(tn.skinonly.dat.indicator, sample.source=="skin") tn.skinonly3.dat.indicator <- subset(tn.skinonly2.dat.indicator, state=="TN") tn.skinonly3.dat.indicator.otus <- select(tn.skinonly3.dat.indicator, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) meso.invsimp <- diversity(tn.skinonly3.dat.indicator.otus, "inv") hist(meso.invsimp, main="Inverse Simpson", xlab="", breaks=10) #visualize distribution shapiro.test(meso.invsimp) #test for normalcy - not normally distributed #test alpha for SPECIES - MESOSCALE kruskal.test(meso.invsimp ~ species, data=tn.skinonly3.dat.indicator) #species is statistically significant #Create 1x1 plot environment par(mfrow = c(1, 1)) #Plot boxplot(meso.invsimp ~ species, data=tn.skinonly3.dat.indicator, ylab="Inverse Simpson", las=2, cex.axis=0.8) #test alpha for ECOMODE - MESOSCALE kruskal.test(meso.invsimp ~ ecomode, data=tn.skinonly3.dat.indicator) #ecomode is statistically significant #Create 1x1 plot environment par(mfrow = c(1, 1)) #Plot boxplot(meso.invsimp ~ ecomode, data=tn.skinonly3.dat.indicator, ylab="Inverse Simpson", las=2, cex.axis=0.8) #test alpha for Ophidiomyces presence - MESOSCALE kruskal.test(meso.invsimp ~ Oo, data=tn.skinonly3.dat.indicator) #Ophidiomyces presence is NOT statistically significant #Create 1x1 plot environment par(mfrow = c(1, 1)) #Plot boxplot(meso.invsimp ~ Oo, data=tn.skinonly3.dat.indicator, ylab="Inverse Simpson", las=2, cex.axis=0.8) ################################################################################################ #MICROSCALE COMPARISONS ACROSS THE INTERIOR PLATEAU ECOREGION OF TENNESSEE###################### #Using indicator OTUs########################################################################### ################################################################################################ #create dataframe of only skin samples for Interior plateau of Tennessee interior.skinonly.dat.indicator <- select(env.skin.dat, sample, species, sample.source, Oo, state, site, tn.ecoregion, month, year, ct, copy.number, ecomode, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) interior.skinonly2.dat.indicator <- subset(interior.skinonly.dat.indicator, sample.source=="skin") interior.skinonly3.dat.indicator <- subset(interior.skinonly2.dat.indicator, tn.ecoregion=="Interior plateau") interior.skinonly3.dat.indicator.otus <- select(interior.skinonly3.dat.indicator, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) #create factors for Interior plateau skin analysis interior.species <- as.factor(interior.skinonly3.dat.indicator$species) interior.site <- as.factor(interior.skinonly3.dat.indicator$site) interior.month <- as.factor(interior.skinonly3.dat.indicator$month) interior.year <- as.factor(interior.skinonly3.dat.indicator$year) interior.ecomode <- as.factor(interior.skinonly3.dat.indicator$ecomode) interior.oo <- as.factor(interior.skinonly3.dat.indicator$Oo) #permanova to test factors species*site*month*year*Oo status are predictive of the skin microbiome in the Interior plateau of Tennessee bray.interior.skinonly3.dat.indicator.otus <- vegdist(interior.skinonly3.dat.indicator.otus, method="bray",na.rm=TRUE) adonis(bray.interior.skinonly3.dat.indicator.otus~interior.species*interior.month*interior.site*interior.oo*interior.year, data=interior.skinonly3.dat.indicator.otus, permutations = 999, method='bray') #Remove non significant interaction terms adonis(bray.interior.skinonly3.dat.indicator.otus~interior.species+interior.month+interior.site+interior.oo+interior.year+interior.species:interior.month+interior.month:interior.oo, data=interior.skinonly3.dat.indicator.otus, permutations = 999, method='bray') #Remove non significant interaction terms adonis(bray.interior.skinonly3.dat.indicator.otus~interior.species+interior.month+interior.site+interior.oo+interior.year+interior.species:interior.month, data=interior.skinonly3.dat.indicator.otus, permutations = 999, method='bray') #Ecomode * Oo.status adonis(bray.interior.skinonly3.dat.indicator.otus~interior.ecomode*interior.oo, data=interior.skinonly3.dat.indicator.otus, permutations = 999, method='bray') #betadisper to determine homogeneity of ecomode groups visualized by nmds interior.betadisper <- with(interior.skinonly3.dat.indicator, betadisper(bray.interior.skinonly3.dat.indicator.otus, interior.ecomode)) interior.betadisper permutest(interior.betadisper) TukeyHSD(interior.betadisper) plot(interior.betadisper, label = F, hull = F, ellipse = T) boxplot(interior.betadisper) #run NMDS and plot in ggplot2 #Stress value is 0.20 interior.skinonly3.dat.indicator.nmds<-metaMDS(interior.skinonly3.dat.indicator.otus, distance = "bray", k=2, try=20, trymax=999) data.scores4 <- as.data.frame(scores(interior.skinonly3.dat.indicator.nmds)) #Using the scores function from vegan to extract the site scores (rows) and convert to a data.frame data.scores4 data.scores4$site <- rownames(data.scores4) # create a column of site names, from the rownames of data.scores data.scores4$Species <- interior.species # add factor data for graphing purposes data.scores4$Month <- interior.month # add factor data for graphing purposes data.scores4$Ecomode <- interior.ecomode # add factor data for graphing purposes head(data.scores4) #look at the data tail(data.scores4) species.scores4 <- as.data.frame(scores(interior.skinonly3.dat.indicator.nmds, "species")) #Using the scores function from vegan to extract the species scores and convert to a data.frame species.scores4$species <- rownames(species.scores4) # create a column of species, from the rownames of species.scores head(species.scores4) #ggplot interior<-ggplot() + geom_text(data=species.scores4,aes(x=NMDS1,y=NMDS2,label=species),alpha=0.5) # add the species labels interior<-ggplot()+geom_point(data=data.scores4,aes(x=NMDS1,y=NMDS2, colour=Ecomode),size=2) # add the point markers interior<-interior+theme_classic() interior<-interior+theme_classic() interior<-interior+theme(legend.position="none") #remove this line if you want a legend - did this for multipanel figure interior<-interior+ggtitle("Microscale - Interior Plateau") + theme(plot.title = element_text(hjust = 0.5)) interior ####################################### ####DISEASE - INTERIOR PLATEAU, TN##### #Using indictors for Ophidiomyces state create dataframe of only skin samples for INTERIOR PLATEAU of Tennessee ###################################### interior.sfd <- select(env.skin.dat, sample, species, sample.source, Oo, state, site, tn.ecoregion, month, year, ct, copy.number, ecomode, Otu00190,Otu00071,Otu00354,Otu00597,Otu00045,Otu00233,Otu00452,Otu00039,Otu00026,Otu00316,Otu00258,Otu00006) interior2.sfd <- subset(interior.sfd, sample.source=="skin") interior3.sfd <- subset(interior2.sfd, tn.ecoregion=="Interior plateau") interior3.sfd.otus <- select(interior3.sfd, Otu00190,Otu00071,Otu00354,Otu00597,Otu00045,Otu00233,Otu00452,Otu00039,Otu00026,Otu00316,Otu00258,Otu00006) interior3.sfd.otus.removezeros<-interior3.sfd[as.logical(rowSums(interior3.sfd.otus != 0)), ] interior3.sfd.otus.removezeros.otus<-interior3.sfd.otus.removezeros[13:24] #dbRDA using capscale function in vegan to model OTU data on continuous Ophidiomyces copy number variable plotNormalHistogram(interior3.sfd.otus.removezeros$copy.number) #Data are right skewed interior3.sfd.copy.number.cubed <- sign(interior3.sfd.otus.removezeros$copy.number) * abs(interior3.sfd.otus.removezeros$copy.number)^(1/3) #cubed root transform plotNormalHistogram(interior3.sfd.copy.number.cubed) #plot - a little better than square root transformation plotNormalHistogram(interior3.sfd.otus.removezeros.otus) #data is right skewed interior3.sfd.otus.cubed <- sign(interior3.sfd.otus.removezeros.otus) * abs(interior3.sfd.otus.removezeros.otus)^(1/3) #cubed root transform plotNormalHistogram(interior3.sfd.otus.cubed) interior.sfd.capscale <- capscale(interior3.sfd.otus.cubed ~ interior3.sfd.copy.number.cubed, interior3.sfd.otus.removezeros, dist="bray") interior.sfd.capscale plot(interior.sfd.capscale) anova(interior.sfd.capscale) #DISEASE- INTERIOR - plot capscale results with ggplot2 smry <- summary(interior.sfd.capscale) smry df1 <- data.frame(smry$sites[,1:2]) # CAP1 and MDS1 interior.oo <- as.factor(interior3.sfd.otus.removezeros$Oo) df1$Ophidiomyces <- interior.oo df2 <- data.frame(smry$species[,1:2]) # loadings for CAP1 and MDS1 df1 df2 cap.plot <- ggplot(df1, aes(x=CAP1, y=MDS1, colour=Ophidiomyces)) + geom_point(aes(label=rownames(df1)),size=2) + geom_hline(yintercept=0, linetype="dotted") + geom_vline(xintercept=0, linetype="dotted") + xlim(-3,4)+ ylim(-2,3) #coord_fixed() cap.plot cap.biplot <- cap.plot + geom_text(data=df2, aes(x=CAP1,y=MDS1,label=rownames(df2), hjust=0.5*(2-sign(CAP1)),vjust=0.5*(1-sign(MDS1))), color="black", size=2) cap.biplot<-cap.biplot+theme_classic() cap.biplot<-cap.biplot+theme(legend.position="none") #remove this line if you want a legend - did this for multipanel figure cap.biplot<-cap.biplot+ggtitle("Microscale - Interior Plateau") + theme(plot.title = element_text(hjust = 0.5)) cap.biplot ####################################### #MICROSCALE INTERIOR PLATEAU, TN - assessing ALPHA DIVERSITY #Using indicator taxa for skin ####################################### #create dataframe of only skin samples for Interior plateau of Tennessee interior.skinonly.dat.indicator <- select(env.skin.dat, sample, species, sample.source, Oo, state, site, tn.ecoregion, month, year, ct, copy.number, ecomode, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) interior.skinonly2.dat.indicator <- subset(interior.skinonly.dat.indicator, sample.source=="skin") interior.skinonly3.dat.indicator <- subset(interior.skinonly2.dat.indicator, tn.ecoregion=="Interior plateau") interior.skinonly3.dat.indicator.otus <- select(interior.skinonly3.dat.indicator, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) interior.invsimp <- diversity(interior.skinonly3.dat.indicator.otus, "inv") hist(interior.invsimp, main="Inverse Simpson", xlab="", breaks=10) #visualize distribution shapiro.test(interior.invsimp) #test for normalcy - normally distributed so run anova or t-test #test alpha for SPECIES - INTERIOR kruskal.test(interior.invsimp ~ species, data=interior.skinonly3.dat.indicator) #Ophidiomyces presence is NOT statistically significant #Create 1x1 plot environment par(mfrow = c(1, 1)) #Plot boxplot(interior.invsimp ~ species, data=interior.skinonly3.dat.indicator, ylab="Inverse Simpson", las=2, cex.axis=0.8) #test alpha for ECOMODE - INTERIOR kruskal.test(interior.invsimp ~ ecomode, data=interior.skinonly3.dat.indicator) #Ophidiomyces presence is NOT statistically significant #Create 1x1 plot environment par(mfrow = c(1, 1)) #Plot boxplot(interior.invsimp ~ ecomode, data=interior.skinonly3.dat.indicator, ylab="Inverse Simpson", las=2, cex.axis=0.8) #test alpha for Ophidiomyces presence - INTERIOR kruskal.test(interior.invsimp ~ Oo, data=interior.skinonly3.dat.indicator) #Ophidiomyces presence is NOT statistically significant #Create 1x1 plot environment par(mfrow = c(1, 1)) #Plot boxplot(interior.invsimp ~ Oo, data=interior.skinonly3.dat.indicator, ylab="Inverse Simpson", las=2, cex.axis=0.8) ################################################################################################ #MICROSCALE COMPARISONS ACROSS THE Southwestern Appalachians ECOREGION OF TENNESSEE############# #Using indicator OTUs########################################################################### ################################################################################################ #create dataframe of only skin samples for Southwestern Appalachians of Tennessee apps.skinonly.dat.indicator <- select(env.skin.dat, sample, species, sample.source, Oo, state, site, tn.ecoregion, month, year, ct, copy.number, ecomode, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) apps.skinonly2.dat.indicator <- subset(apps.skinonly.dat.indicator, sample.source=="skin") apps.skinonly3.dat.indicator <- subset(apps.skinonly2.dat.indicator, tn.ecoregion=="Southwestern Appalachians") apps.skinonly3.dat.indicator.otus <- select(apps.skinonly3.dat.indicator, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) #create factors for Southwestern Appalachians skin analysis apps.species <- as.factor(apps.skinonly3.dat.indicator$species) apps.site <- as.factor(apps.skinonly3.dat.indicator$site) apps.month <- as.factor(apps.skinonly3.dat.indicator$month) apps.year <- as.factor(apps.skinonly3.dat.indicator$year) apps.ecomode <- as.factor(apps.skinonly3.dat.indicator$ecomode) apps.oo <- as.factor(apps.skinonly3.dat.indicator$Oo) #permanova to test factors species*site*month*year*Oo status are predictive of the skin microbiome in the Southwestern Appalachians of Tennessee bray.apps.skinonly3.dat.indicator.otus <- vegdist(apps.skinonly3.dat.indicator.otus, method="bray",na.rm=TRUE) adonis(bray.apps.skinonly3.dat.indicator.otus~apps.species*apps.month*apps.site*apps.year*apps.oo, data=apps.skinonly3.dat.indicator.otus, permutations = 999, method='bray') #Remove ALL interaction tests adonis(bray.apps.skinonly3.dat.indicator.otus~apps.species+apps.month+apps.site+apps.year+apps.oo, data=apps.skinonly3.dat.indicator.otus, permutations = 999, method='bray') #ecomode*Oo.status adonis(bray.apps.skinonly3.dat.indicator.otus~apps.ecomode*apps.oo, data=apps.skinonly3.dat.indicator.otus, permutations = 999, method='bray') #ecomode+Oo.status - no significant interaction between ecomode and oo status adonis(bray.apps.skinonly3.dat.indicator.otus~apps.ecomode+apps.oo, data=apps.skinonly3.dat.indicator.otus, permutations = 999, method='bray') #betadisper to determine homogeneity of ecomode groups visualized by nmds #only two points for Arboreal factor - unbalanced sampling design skews the results - shouldn't be used in conclusions apps.betadisper <- with(apps.skinonly3.dat.indicator, betadisper(bray.apps.skinonly3.dat.indicator.otus, apps.ecomode)) apps.betadisper permutest(apps.betadisper) plot(apps.betadisper, label = F, hull = F, ellipse = T) boxplot(apps.betadisper) TukeyHSD(apps.betadisper) #run NMDS with ecomode as factor and plot in ggplot2 #Stress value is 0.18 apps.skinonly3.dat.indicator.nmds<-metaMDS(apps.skinonly3.dat.indicator.otus, distance = "bray", k=2, try=20, trymax=999) data.scores5 <- as.data.frame(scores(apps.skinonly3.dat.indicator.nmds)) #Using the scores function from vegan to extract the site scores (rows) and convert to a data.frame data.scores5 data.scores5$site <- rownames(data.scores5) # create a column of site names, from the rownames of data.scores data.scores5$Species <- apps.species # add factor data for graphing purposes data.scores5$Month <- apps.month # add factor data for graphing purposes data.scores5$Ecomode <- apps.ecomode # add factor data for graphing purposes head(data.scores5) #look at the data tail(data.scores5) species.scores5 <- as.data.frame(scores(apps.skinonly3.dat.indicator.nmds, "species")) #Using the scores function from vegan to extract the species scores and convert to a data.frame species.scores5$species <- rownames(species.scores5) # create a column of species, from the rownames of species.scores head(species.scores5) apps<-ggplot() + geom_text(data=species.scores5,aes(x=NMDS1,y=NMDS2,label=species),alpha=0.5) # add the species labels apps<-ggplot()+geom_point(data=data.scores5,aes(x=NMDS1,y=NMDS2, colour=Ecomode),size=2) # add the point markers apps<-apps+theme_classic() apps<-apps+theme(legend.position="none") #remove this line if you want a legend - did this for multipanel figure apps<-apps+ggtitle("Microscale - Southwestern Appalachians") + theme(plot.title = element_text(hjust = 0.5)) apps ################################################ ####DISEASE - SOUTHWESTERN APPALACHIANS, TN##### #Using indictors for Ophidiomyces state create dataframe of only skin samples for Southwestern Appalachians of Tennessee ############################################### apps.skinonly.dat.indicator.sfd <- select(env.skin.dat, sample, species, sample.source, Oo, state, site, tn.ecoregion, month, year, ct, copy.number, ecomode, Otu00554,Otu01591,Otu14287,Otu00035,Otu10700,Otu26160,Otu00467,Otu00258,Otu00193,Otu00146,Otu00111,Otu00108) apps.skinonly2.dat.indicator.sfd <- subset(apps.skinonly.dat.indicator.sfd, sample.source=="skin") apps.skinonly3.dat.indicator.sfd <- subset(apps.skinonly2.dat.indicator.sfd, tn.ecoregion=="Southwestern Appalachians") apps.skinonly3.dat.indicator.otus.sfd <- select(apps.skinonly3.dat.indicator.sfd, Otu00554,Otu01591,Otu14287,Otu00035,Otu10700,Otu26160,Otu00467,Otu00258,Otu00193,Otu00146,Otu00111,Otu00108) #remove rows that have OTU relative abundances that sum to zero apps.skinonly3.dat.indicator.sfd.removezeros<-apps.skinonly3.dat.indicator.sfd[as.logical(rowSums(apps.skinonly3.dat.indicator.otus.sfd != 0)), ] apps.skinonly3.dat.indicator.otus.sfd <- select(apps.skinonly3.dat.indicator.sfd.removezeros, Otu00554,Otu01591,Otu14287,Otu00035,Otu10700,Otu26160,Otu00467,Otu00258,Otu00193,Otu00146,Otu00111,Otu00108) #dbRDA using capscale function in vegan to model OTU data on continuous Ophidiomyces copy number variable copy.number.sfd.cubed <- sign(apps.skinonly3.dat.indicator.sfd.removezeros$copy.number) * abs(apps.skinonly3.dat.indicator.sfd.removezeros$copy.number)^(1/3) #cubed root transform plotNormalHistogram(copy.number.sfd.cubed) #plot - a little better than square root transformation plotNormalHistogram(apps.skinonly3.dat.indicator.otus.sfd) #data is right skewed apps.skinonly3.dat.indicator.otus.sfd.cubed <- sign(apps.skinonly3.dat.indicator.otus.sfd) * abs(apps.skinonly3.dat.indicator.otus.sfd)^(1/3) #cubed root transform plotNormalHistogram(apps.skinonly3.dat.indicator.otus.sfd.cubed) apps.sfd.capscale <- capscale(apps.skinonly3.dat.indicator.otus.sfd.cubed ~ copy.number.sfd.cubed, apps.skinonly3.dat.indicator.sfd.removezeros, dist="bray" ) apps.sfd.capscale plot(apps.sfd.capscale) anova(apps.sfd.capscale) #DISEASE- SOUTHWESTERN APPALACHIANS - plot capscale results with ggplot2 apps.smry <- summary(apps.sfd.capscale) apps.smry apps.df1 <- data.frame(apps.smry$sites[,1:2]) # CAP1 and MDS1 apps.oo <- as.factor(apps.skinonly3.dat.indicator.sfd.removezeros$Oo) #create factor to graph apps.df1$Ophidiomyces <- apps.oo apps.df2 <- data.frame(apps.smry$species[,1:2]) # loadings for CAP1 and MDS1 apps.df1 apps.df2 apps.cap.plot <- ggplot(apps.df1, aes(x=CAP1, y=MDS1, colour=Ophidiomyces)) + geom_point(aes(label=rownames(apps.df1)),size=2) + geom_hline(yintercept=0, linetype="dotted") + geom_vline(xintercept=0, linetype="dotted") + xlim(-3.5,4.5)+ ylim(-2,3) #coord_fixed() apps.cap.plot apps.cap.biplot <- apps.cap.plot + geom_text(data=apps.df2, aes(x=CAP1,y=MDS1,label=rownames(apps.df2), hjust=0.5*(1-sign(CAP1)),vjust=0.5*(1-sign(MDS1))), color="black", size=2) apps.cap.biplot<-apps.cap.biplot+theme_classic() apps.cap.biplot<-apps.cap.biplot+theme(legend.position="none") #remove this line if you want a legend - did this for multipanel figure apps.cap.biplot<-apps.cap.biplot+ggtitle("Microscale - Southwestern Appalachians") + theme(plot.title = element_text(hjust = 0.5)) apps.cap.biplot ####################################### #MICROSCALE SOUTHWESTERN APPALACHIANS, TN - assessing ALPHA DIVERSITY #Using indicator taxa for skin ####################################### #create dataframe of only skin samples for Southwestern Appalachians of Tennessee apps.skinonly.dat.indicator <- select(env.skin.dat, sample, species, sample.source, Oo, state, site, tn.ecoregion, month, year, ct, copy.number, ecomode, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) apps.skinonly2.dat.indicator <- subset(apps.skinonly.dat.indicator, sample.source=="skin") apps.skinonly3.dat.indicator <- subset(apps.skinonly2.dat.indicator, tn.ecoregion=="Southwestern Appalachians") apps.skinonly3.dat.indicator.otus <- select(apps.skinonly3.dat.indicator, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) apps.invsimp <- diversity(apps.skinonly3.dat.indicator.otus, "inv") hist(apps.invsimp, main="Inverse Simpson", xlab="", breaks=10) #visualize distribution shapiro.test(apps.invsimp) #test for normalcy - normally distributed so run anova or t-test apps.invsimp #test alpha for SPECIES - SOUTHWESTERN APPALACHIANS, TN kruskal.test(apps.invsimp ~ species, data=apps.skinonly3.dat.indicator) #Create 1x1 plot environment par(mfrow = c(1, 1)) #Plot boxplot(apps.invsimp ~ species, data=apps.skinonly3.dat.indicator, ylab="Inverse Simpson", las=2, cex.axis=0.8) #test alpha for ECOMODE - SOUTHWESTERN APPALACHIANS, TN kruskal.test(apps.invsimp ~ ecomode, data=apps.skinonly3.dat.indicator) #Create 1x1 plot environment par(mfrow = c(1, 1)) #Plot boxplot(apps.invsimp ~ ecomode, data=apps.skinonly3.dat.indicator, ylab="Inverse Simpson", las=2, cex.axis=0.8) #test alpha for Ophidiomyces presence - SOUTHWESTERN APPALACHIANS, TN kruskal.test(apps.invsimp ~ Oo, data=apps.skinonly3.dat.indicator) #Create 1x1 plot environment par(mfrow = c(1, 1)) #Plot boxplot(apps.invsimp ~ Oo, data=apps.skinonly3.dat.indicator, ylab="Inverse Simpson", las=2, cex.axis=0.8) ################################################################################################ #MICROSCALE COMPARISONS ACROSS THE Blue Ridge Mountains ECOREGION OF TENNESSEE############# #Using indicator OTUs########################################################################### ################################################################################################ #create dataframe of only skin samples for Blue Ridge Mountains of Tennessee blue.skinonly.dat.indicator <- select(env.skin.dat, sample, species, sample.source, Oo, state, site, tn.ecoregion, month, year, ct, copy.number, ecomode, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) blue.skinonly2.dat.indicator <- subset(blue.skinonly.dat.indicator, sample.source=="skin") blue.skinonly3.dat.indicator <- subset(blue.skinonly2.dat.indicator, tn.ecoregion=="Blue Ridge Mountains") blue.skinonly3.dat.indicator.otus <- select(blue.skinonly3.dat.indicator, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) #create factors for Blue Ridge Mountains skin analysis blue.species <- as.factor(blue.skinonly3.dat.indicator$species) blue.site <- as.factor(blue.skinonly3.dat.indicator$site) blue.month <- as.factor(blue.skinonly3.dat.indicator$month) blue.year <- as.factor(blue.skinonly3.dat.indicator$year) blue.ecomode <- as.factor(blue.skinonly3.dat.indicator$ecomode) blue.oo <- as.factor(blue.skinonly3.dat.indicator$Oo) #only a single record of Oo in this ecoregion. Do not model for disease as in other spatial comparisons blue.oo #permanova to test factors species*site*month*year are predictive of the skin microbiome in the Blue Ridge Mountains of Tennessee bray.blue.skinonly3.dat.indicator.otus <- vegdist(blue.skinonly3.dat.indicator.otus, method="bray",na.rm=TRUE) adonis(bray.blue.skinonly3.dat.indicator.otus~blue.species*blue.month*blue.site*blue.year, data=blue.skinonly3.dat.indicator.otus, permutations = 999, method='bray') #no significant interaction between any factors - drop from the model and run independently adonis(bray.blue.skinonly3.dat.indicator.otus~blue.species+blue.month+blue.site+blue.year, data=blue.skinonly3.dat.indicator.otus, permutations = 999, method='bray') #permanova to test factors ecomode*site*month are predictive of the skin microbiome in the Blue Ridge Mountains of Tennessee (swapping ecomode for species) adonis(bray.blue.skinonly3.dat.indicator.otus~blue.ecomode*blue.month*blue.site, data=blue.skinonly3.dat.indicator.otus, permutations = 999, method='bray') #no significant interactions - run ecomode by itself #ecomode Blue Ridge Mountains adonis(bray.blue.skinonly3.dat.indicator.otus~blue.ecomode, data=blue.skinonly3.dat.indicator.otus, permutations = 999, method='bray') #run NMDS and plot in ggplot2 #Stress value is 0.15 blue.skinonly3.dat.indicator.nmds<-metaMDS(blue.skinonly3.dat.indicator.otus, distance = "bray", k=2, try=20, trymax=999) data.scores6 <- as.data.frame(scores(blue.skinonly3.dat.indicator.nmds)) #Using the scores function from vegan to extract the site scores (rows) and convert to a data.frame data.scores6 data.scores6$site <- rownames(data.scores6) # create a column of site names, from the rownames of data.scores data.scores6$Species <- blue.species # add factor data for graphing purposes data.scores6$Month <- blue.month # add factor data for graphing purposes data.scores6$Ecomode <- blue.ecomode # add factor data for graphing purposes head(data.scores6) #look at the data tail(data.scores6) species.scores6 <- as.data.frame(scores(blue.skinonly3.dat.indicator.nmds, "species")) #Using the scores function from vegan to extract the species scores and convert to a data.frame species.scores6$species <- rownames(species.scores6) # create a column of species, from the rownames of species.scores head(species.scores6) #ggplot blue<-ggplot() + geom_text(data=species.scores6,aes(x=NMDS1,y=NMDS2,label=species),alpha=0.5) # add the species labels blue<-ggplot()+geom_point(data=data.scores6,aes(x=NMDS1,y=NMDS2, colour=Ecomode),size=2) # add the point markers blue<-blue+theme_classic() blue<-blue+ggtitle("Microscale - Blue Ridge Mtns") + theme(plot.title = element_text(hjust = 0.5)) blue ####################################### #MICROSCALE - BLUE RIDGE MOUNTAINS, TN - assessing ALPHA DIVERSITY #Using indicator taxa for skin ####################################### #create dataframe of only skin samples for Blue Ridge Mountains of Tennessee blue.skinonly.dat.indicator <- select(env.skin.dat, sample, species, sample.source, Oo, state, site, tn.ecoregion, month, year, ct, copy.number, ecomode, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) blue.skinonly2.dat.indicator <- subset(blue.skinonly.dat.indicator, sample.source=="skin") blue.skinonly3.dat.indicator <- subset(blue.skinonly2.dat.indicator, tn.ecoregion=="Blue Ridge Mountains") blue.skinonly3.dat.indicator.otus <- select(blue.skinonly3.dat.indicator, Otu00169, Otu00318, Otu00557, Otu00279, Otu01239, Otu00355, Otu01976, Otu00192, Otu00278, Otu00058, Otu00467, Otu00142, Otu00097, Otu00149, Otu00094, Otu00573, Otu00178, Otu00259, Otu00073, Otu00193, Otu00116, Otu00160, Otu00098, Otu00571, Otu00389, Otu00022, Otu00066, Otu00124, Otu00258, Otu00043, Otu00226, Otu00309, Otu00105, Otu00089, Otu00075, Otu00392, Otu00191, Otu00083, Otu00235, Otu00049, Otu00125, Otu00099, Otu00120, Otu00021, Otu00146, Otu00048, Otu00046, Otu00029, Otu00041, Otu00031, Otu00011, Otu00019, Otu00012, Otu00111, Otu00007, Otu00006) blue.invsimp <- diversity(blue.skinonly3.dat.indicator.otus, "inv") hist(blue.invsimp, main="Inverse Simpson", xlab="", breaks=10) #visualize distribution shapiro.test(blue.invsimp) #test for normalcy - normally distributed so run anova or t-test #test alpha for SPECIES - BLUE RIDGE MOUNTAINS, TN kruskal.test(blue.invsimp ~ species, data=blue.skinonly3.dat.indicator) #Create 1x1 plot environment par(mfrow = c(1, 1)) #Plot boxplot(blue.invsimp ~ species, data=blue.skinonly3.dat.indicator, ylab="Inverse Simpson", las=2, cex.axis=0.8) #test alpha for ECOMODE - BLUE RIDGE MOUNTAINS, TN kruskal.test(blue.invsimp ~ ecomode, data=blue.skinonly3.dat.indicator) #Create 1x1 plot environment par(mfrow = c(1, 1)) #Plot boxplot(blue.invsimp ~ ecomode, data=blue.skinonly3.dat.indicator, ylab="Inverse Simpson", las=2, cex.axis=0.8) #test alpha for Ophidiomyces presence - BLUE RIDGE MOUNTAINS, TN #Do not test - only 1 record of Ophidiomyces in this region #multiplot ecomode nmds figure in ggplot grid.arrange(macro1, meso, apps, interior, blue, ncol =2) #multiplot capscale analysis figure in ggplot grid.arrange(macro.cap.biplot, meso.cap.biplot, apps.cap.biplot, cap.biplot, nrow=2)