Setup

options(knitr.duplicate.label = "allow")
#library(dada2)
library(phyloseq)
library(vegan)
## Loading required package: permute
## Loading required package: lattice
## This is vegan 2.7-0
library(ggplot2)
library(tidyr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(pheatmap)
library(GUniFrac)
## Registered S3 method overwritten by 'rmutil':
##   method         from
##   print.response httr
#library(metagMisc)
#library(raster)
library(pals)
library(RColorBrewer)
library(ragg)
library(ggpubr)

#Set theme
theme_set(theme_bw() + theme(
              plot.title = element_text(size=20, color="black"),
              axis.text.x = element_text(size=15, color="black"),
              axis.text.y = element_text(size=15, color="black"),
              axis.title.x = element_text(size=15),
              axis.title.y = element_text(size=15),
              legend.text = element_text(size=12),
              legend.title = element_text(size=15),
            #  legend.position = "bottom",
            #  legend.key=element_blank(),
            #  legend.key.size = unit(0.5, "cm"),
            #  legend.spacing.x = unit(0.1, "cm"),
            #  legend.spacing.y = unit(0.1, "cm"),
              panel.background = element_blank(), 
              #panel.border = element_rect(colour = "black", fill=NA, size=1),
              plot.background = element_blank()))

Statistical Analysis-Data Curation

FUNGI-ONLY ANALYSES. full dataset, not rarified

This is will produce the fungal community tables and statistics on fungal diversity at Konza.

setwd('/Users/chunk/AIMS_Konza_synoptic_ITS_community/phyloseq_tabs/fall2023')

#Create phyloseq object
#read in files
asvtab <- read.table("practice09-15-2023.count_table", header=T, row.names=1,
                   check.names=F, sep="\t")

metadata_full <- read.csv("submetatab03102025.csv", row.names=1)

metadata_full$substrate <- as.factor(metadata_full$substrate)
metadata_full<-metadata_full[metadata_full$substrate!='W',]
metadata_full$burn_freq<-1/metadata_full$burn_interval

taxtab <- as.matrix(read.csv("final_fungi_tax_tab_kzsyn_09-15-2023.csv", header = T, row.names=1))

asvtab <- otu_table(asvtab, taxa_are_rows = FALSE)
taxtab <- tax_table(taxtab)
metadata <- sample_data(metadata_full)
#combine into phyloseq object
pseqtest <- phyloseq(asvtab, taxtab, metadata)
#extract easy-to-use sample data
samdftest <- data.frame(sample_data(pseqtest))

cured_asvs<- pseqtest@otu_table
summary(rowSums(cured_asvs))
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     352    7732   14898   17710   25982   60014
sum(rowSums(cured_asvs))
## [1] 2550213
ncol(cured_asvs)
## [1] 7829
##remove singletons, doubletons, and ASVs with less than 5 reads across all samples. 
cured_asvs <- cured_asvs[,colSums(cured_asvs)>5]
summary(rowSums(cured_asvs))
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     352    7706   14872   17680   25932   59985
#rowSums(cured_asvs)
pseqtest <- phyloseq(cured_asvs, taxtab, metadata)
#extract easy-to-use sample data
samdftest <- data.frame(sample_data(pseqtest))

sum(rowSums(cured_asvs))
## [1] 2545863
ncol(cured_asvs)
## [1] 6564
## Examine the read depths by substrate:
###Leaf
summary(rowSums(pseqtest@otu_table[pseqtest@sam_data$substrate=="L",]))
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    5333   23272   28730   29143   34079   59985
##L sample n
nrow(pseqtest@otu_table[pseqtest@sam_data$substrate=="L",])
## [1] 49
###Biofilm
summary(rowSums(pseqtest@otu_table[pseqtest@sam_data$substrate=="B",]))
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     352    3791    7724    9260   12873   31449
##B sample n
nrow(pseqtest@otu_table[pseqtest@sam_data$substrate=="B",])
## [1] 46
###Sediment
summary(rowSums(pseqtest@otu_table[pseqtest@sam_data$substrate=="S",]))
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    1747    7888   13105   14120   18670   39038
##S sample n
nrow(pseqtest@otu_table[pseqtest@sam_data$substrate=="S",])
## [1] 49
###

site characteristics

### subset selecting any one of three substrates to get one row of metadata per site
metadata_sitechars<-metadata_full[metadata_full$substrate=='S',]

### kmeans clustered (k=3) by annual percent wet clusters
metadata_sitechars
##         siteid  Sample substrate  Site  sticID wet_dry n_wet n_total
## 01m01_S  01M01 01m01_S         S 01m01 01M01_1     WET  4661   12197
## 01m02_S  01M02 01m02_S         S 01m02 01M02_1     WET  3720   26368
## 01m03_S  01M03 01m03_S         S 01m03 01M03_1     WET  2221   22615
## 01m04_S  01M04 01m04_S         S 01m04 01M04_2     WET  6218   33864
## 01m05_S  01M05 01m05_S         S 01m05 01M05_1     WET 18449   21654
## 01m06_S  01M06 01m06_S         S 01m06 01M06_1     WET  8747   33852
## 02m01_S  02M01 02m01_S         S 02m01 02M01_1     WET    48   12640
## 02m02_S  02M02 02m02_S         S 02m02 02M02_1     WET  3016   22615
## 02m03_S  02M03 02m03_S         S 02m03 02M03_1     WET  2826   22616
## 02m04_S  02M04 02m04_S         S 02m04 02M04_1     WET  1571   23611
## 02m05_S  02M05 02m05_S         S 02m05 02M05_1     WET  7074   12197
## 02m06_S  02M06 02m06_S         S 02m06 02M06_1     WET  7423   34630
## 02m07_S  02M07 02m07_S         S 02m07 02M07_1     WET 28515   34621
## 02m08_S  02M08 02m08_S         S 02m08 02M08_1     WET  2595   13798
## 02m09_S  02M09 02m09_S         S 02m09 02M09_1     WET  9912   34620
## 02m10_S  02M10 02m10_S         S 02m10 02M10_1     WET   454   11252
## 02m11_S  02M11 02m11_S         S 02m11 02M11_1     WET 21189   34813
## 04m01_S  04M01 04m01_S         S 04m01 04M01_1     WET 15003   23391
## 04m02_S  04M02 04m02_S         S 04m02 04M02_1     WET 15667   23393
## 04m03_S  04M03 04m03_S         S 04m03 04M03_1     WET  2928   11199
## 04m04_S  04M04 04m04_S         S 04m04 04M04_1     WET 19514   19514
## 04m05_S  04M05 04m05_S         S 04m05 04M05_1     WET 29056   34811
## 04m06_S  04M06 04m06_S         S 04m06 04M06_1     WET  1742   22648
## 04m07_S  04M07 04m07_S         S 04m07 04M07_1     WET  7690   34812
## 04m08_S  04M08 04m08_S         S 04m08 04M08_1     WET 33425   34810
## 04m09_S  04M09 04m09_S         S 04m09 04M09_1     WET  6014   34811
## 04m10_S  04M10 04m10_S         S 04m10 04M10_1     WET  5974   34812
## 04m11_S  04M11 04m11_S         S 04m11 04M11_1     WET  4154   34811
## 04m12_S  04M12 04m12_S         S 04m12 04M12_1     WET  7763   34839
## 04m13_S  04M13 04m13_S         S 04m13 04M13_1     DRY  1895   34812
## 04t01_S  04T01 04t01_S         S 04t01 04T01_1     DRY  1110   23408
## 04t02_S  04T02 04t02_S         S 04t02 04T02_1     WET  1737   14001
## 04w01_S  04W01 04w01_S         S 04w01 04W01_1     DRY  1406   22645
## 04w02_S  04W02 04w02_S         S 04w02 04W02_1     WET    49   10295
## 04w03_S  04W03 04w03_S         S 04w03 04W03_1     WET   387   12197
## 04w04_S  04W04 04w04_S         S 04w04 04W04_1     WET  2323   22459
## 20m01_S  20M01 20m01_S         S 20m01 20M01_1     DRY   973   22641
## 20m02_S  20M02 20m02_S         S 20m02 20M02_1     WET  1506   21644
## 20m03_S  20M03 20m03_S         S 20m03 20M03_1     DRY     0    2013
## 20m04_S  20M04 20m04_S         S 20m04 20M04_1     WET  1830   14951
## 20m05_S  20M05 20m05_S         S 20m05 20M05_1     WET  8275   34812
## sfm01_S  SFM01 sfm01_S         S sfm01 SFM01_1     WET  8770   22640
## sfm02_S  SFM02 sfm02_S         S sfm02 SFM02_1     WET  3133   22614
## sfm03_S  SFM03 sfm03_S         S sfm03 SFM03_1     WET  3041   24860
## sfm04_S  SFM04 sfm04_S         S sfm04 SFM04_1     WET  7628   34812
## sfm05_S  SFM05 sfm05_S         S sfm05 SFM05_1     WET  9405   22615
## sfm06_S  SFM06 sfm06_S         S sfm06 SFM06_1     WET  2591   12197
## sfm07_S  SFM07 sfm07_S         S sfm07 SFM07_1     WET  4344   34812
## Sft01_S  SFT01 Sft01_S         S Sft01 SFT01_1     WET  5492    9953
## Sft02_S  SFT02 Sft02_S         S Sft02 SFT02_1     WET  6166   19488
##         prc_missing     prc_wet tempC_mean LeafSpecies1 LeafSpecies2
## 01m01_S   0.7836529 0.382143150   6.984064          Elm          Elm
## 01m02_S   0.5322915 0.141080097  17.589772      Populus          Oak
## 01m03_S   0.5988612 0.098209153  16.937429       Locust          Elm
## 01m04_S   0.3993295 0.183616820  13.943160      Populus          Oak
## 01m05_S   0.6159072 0.851990394  17.020088          Elm          Elm
## 01m06_S   0.3995424 0.258389460  12.771854          Elm          Elm
## 02m01_S   0.7757951 0.003797468  10.924877          Oak          Oak
## 02m02_S   0.5988612 0.133362812  16.571000          Elm          Elm
## 02m03_S   0.5988435 0.124955784  16.688561      Populus          Elm
## 02m04_S   0.5811945 0.066536784   8.749176      Populus      Populus
## 02m05_S   0.7836529 0.579978683   7.051607          Elm          Elm
## 02m06_S   0.3857424 0.214351718  13.764280      Populus      Populus
## 02m07_S   0.3859021 0.823633055  12.515694          Elm      Populus
## 02m08_S   0.7552548 0.188070735  23.540365      Populus          Oak
## 02m09_S   0.3859198 0.286308492  13.351205          Oak          Oak
## 02m10_S   0.8004151 0.040348383  10.233446          Oak      Populus
## 02m11_S   0.3824964 0.608651940  13.726468         <NA>         <NA>
## 04m01_S   0.5850968 0.641400539  14.481234          Elm          Oak
## 04m02_S   0.5850613 0.669730261  14.260131          Oak          Oak
## 04m03_S   0.8013552 0.261451915  22.924203          Oak          Elm
## 04m04_S   0.6538659 1.000000000  17.398986          Oak          Elm
## 04m05_S   0.3825319 0.834678694  12.543450          Elm          Oak
## 04m06_S   0.5982759 0.076916284  15.710394          Elm      Populus
## 04m07_S   0.3825141 0.220900839  13.178269          Elm          Elm
## 04m08_S   0.3825496 0.960212583  12.652138        Sedge        Sedge
## 04m09_S   0.3825319 0.172761483  13.987895      Populus          Elm
## 04m10_S   0.3825141 0.171607492  13.181735          Elm      Populus
## 04m11_S   0.3825319 0.119330097  13.750683        Grass        Grass
## 04m12_S   0.3820352 0.222824995  13.046472        Grass        Grass
## 04m13_S   0.3825141 0.054435252  15.048048          Elm         Forb
## 04t01_S   0.5847952 0.047419686  16.858128          Elm          Elm
## 04t02_S   0.7516540 0.124062567  10.815149        Grass        Grass
## 04w01_S   0.5983291 0.062088761  18.465848      Populus      Populus
## 04w02_S   0.8173901 0.004759592   8.747003          Elm          Elm
## 04w03_S   0.7836529 0.031729114   8.024337   Elderberry         none
## 04w04_S   0.6016283 0.103432922   7.663201          Elm         none
## 20m01_S   0.5984001 0.042975134  17.689228          Oak          Oak
## 20m02_S   0.6160846 0.069580484  14.913436      Populus      Populus
## 20m03_S   0.9642939 0.000000000  20.307879          Elm          Elm
## 20m04_S   0.7348032 0.122399839  22.609106          Elm          Elm
## 20m05_S   0.3825141 0.237705389  14.597884       Rubrus      Populus
## sfm01_S   0.5984178 0.387367491  15.483584          Elm          Oak
## sfm02_S   0.5988790 0.138542496  16.544916          Elm      Populus
## sfm03_S   0.5590400 0.122325020   8.424775          Oak          Oak
## sfm04_S   0.3825141 0.219119844  12.655383          Oak          Oak
## sfm05_S   0.5988612 0.415874420  16.812533          Elm          Elm
## sfm06_S   0.7836529 0.212429286   8.022568          Oak          Oak
## sfm07_S   0.3825141 0.124784557  13.666626          Elm          Oak
## Sft01_S   0.8234564 0.551793429  21.420313          Elm          Elm
## Sft02_S   0.6543271 0.316399836  18.611745         <NA>         <NA>
##         LeafSpecies3 Elm Populus Oak Locust Graminales Elderberry Rubrus Forb
## 01m01_S          Oak   1       0   1      0          0          0      0    0
## 01m02_S          Oak   0       1   1      0          0          0      0    0
## 01m03_S          Oak   1       0   1      1          0          0      0    0
## 01m04_S          Elm   1       1   1      0          0          0      0    0
## 01m05_S          Oak   1       0   1      0          0          0      0    0
## 01m06_S          Elm   1       0   0      0          0          0      0    0
## 02m01_S          Oak   0       0   1      0          0          0      0    0
## 02m02_S          Elm   1       0   0      0          0          0      0    0
## 02m03_S          Elm   1       1   0      0          0          0      0    0
## 02m04_S      Populus   0       1   0      0          0          0      0    0
## 02m05_S          Elm   1       0   0      0          0          0      0    0
## 02m06_S      Populus   0       1   0      0          0          0      0    0
## 02m07_S      Populus   1       1   0      0          0          0      0    0
## 02m08_S          Oak   0       1   1      0          0          0      0    0
## 02m09_S          Oak   0       0   1      0          0          0      0    0
## 02m10_S      Populus   0       1   1      0          0          0      0    0
## 02m11_S         <NA>   0       0   0      0          0          0      0    0
## 04m01_S      Populus   1       1   1      0          0          0      0    0
## 04m02_S      Populus   0       1   1      0          0          0      0    0
## 04m03_S          Elm   1       0   1      0          0          0      0    0
## 04m04_S          Elm   1       0   1      0          0          0      0    0
## 04m05_S      Populus   1       1   1      0          0          0      0    0
## 04m06_S      Populus   1       1   0      0          0          0      0    0
## 04m07_S      Populus   1       1   0      0          0          0      0    0
## 04m08_S        Forbs   0       0   0      0          1          0      0    1
## 04m09_S      Unknown   1       1   0      0          0          0      0    0
## 04m10_S      Populus   1       1   0      0          0          0      0    0
## 04m11_S        Shrub   0       0   0      0          1          0      0    0
## 04m12_S          Elm   1       0   0      0          1          0      0    0
## 04m13_S        Grass   1       0   0      0          1          0      0    1
## 04t01_S        Grass   1       0   0      0          1          0      0    0
## 04t02_S          Elm   1       0   0      0          1          0      0    0
## 04w01_S          Oak   0       1   1      0          0          0      0    0
## 04w02_S      Populus   1       1   0      0          0          0      0    0
## 04w03_S         none   0       0   0      0          0          1      0    0
## 04w04_S         none   1       0   0      0          0          0      0    0
## 20m01_S          Oak   0       0   1      0          0          0      0    0
## 20m02_S      Populus   0       1   0      0          0          0      0    0
## 20m03_S          Elm   1       0   0      0          0          0      0    0
## 20m04_S          Elm   1       0   0      0          0          0      0    0
## 20m05_S          Elm   1       1   0      0          0          0      1    0
## sfm01_S          Oak   1       0   1      0          0          0      0    0
## sfm02_S          Oak   1       1   1      0          0          0      0    0
## sfm03_S      Populus   0       1   1      0          0          0      0    0
## sfm04_S          Elm   1       0   1      0          0          0      0    0
## sfm05_S          Oak   1       0   1      0          0          0      0    0
## sfm06_S      Populus   0       1   1      0          0          0      0    0
## sfm07_S          Oak   1       0   1      0          0          0      0    0
## Sft01_S          Oak   1       0   1      0          0          0      0    0
## Sft02_S         <NA>   0       0   0      0          0          0      0    0
##         Shrub Unknown Sediment.Texture.Description Percent.Rocks
## 01m01_S     0       0                        Sandy             5
## 01m02_S     0       0                        Sandy            80
## 01m03_S     0       0                 Sandy coarse            30
## 01m04_S     0       0      FBOM find sand and clay            15
## 01m05_S     0       0             FBOM coarse sand             5
## 01m06_S     0       0                    FBOM silt            20
## 02m01_S     0       0                         <NA>            50
## 02m02_S     0       0                         <NA>            60
## 02m03_S     0       0                         <NA>            85
## 02m04_S     0       0                         <NA>            60
## 02m05_S     0       0                         <NA>            85
## 02m06_S     0       0                         <NA>            80
## 02m07_S     0       0                         <NA>            85
## 02m08_S     0       0                         <NA>            85
## 02m09_S     0       0                         <NA>            80
## 02m10_S     0       0                         <NA>            75
## 02m11_S     0       0                         <NA>            92
## 04m01_S     0       0                         <NA>            NA
## 04m02_S     0       0                         <NA>            NA
## 04m03_S     0       0                         <NA>            NA
## 04m04_S     0       0                         <NA>            NA
## 04m05_S     0       0                         <NA>            NA
## 04m06_S     0       0                         <NA>            NA
## 04m07_S     0       0                         <NA>            NA
## 04m08_S     0       0                         <NA>            NA
## 04m09_S     1       0                         <NA>            NA
## 04m10_S     0       0                         <NA>            NA
## 04m11_S     1       0        Very silty and gravel            15
## 04m12_S     0       0             Sily clay gravel            40
## 04m13_S     0       0              Silty clay loam            50
## 04t01_S     0       0                   Silty clay            60
## 04t02_S     0       0            Sandy silt and OM            40
## 04w01_S     0       0             Sandy silty loam            90
## 04w02_S     0       0              Silty clay loam            60
## 04w03_S     0       0                        Sandy            80
## 04w04_S     0       0                         <NA>            NA
## 20m01_S     0       0                Clay and sand            NA
## 20m02_S     0       0                   Sandy clay            NA
## 20m03_S     0       0            Sandy gravel clay            96
## 20m04_S     0       0                         <NA>            70
## 20m05_S     0       0                         <NA>            92
## sfm01_S     0       0                  Gravel fine            NA
## sfm02_S     0       0                         <NA>            93
## sfm03_S     0       0                         <NA>            75
## sfm04_S     0       0                         <NA>            80
## sfm05_S     0       0              Silt and gravel            85
## sfm06_S     0       0                   More sandy            90
## sfm07_S     0       0                        Sandy            94
## Sft01_S     0       0                Silt and sand            30
## Sft02_S     0       0                         <NA>            NA
##         Percent.Leaf.Litter Percent.Sediment meanN2Ar  meanO2Ar   meanO2
## 01m01_S                  65               30 39.10763 17.400480 240.5808
## 01m02_S                   5               15 39.06296 15.942810 222.7925
## 01m03_S                   1               50 38.89556 18.615640 260.6771
## 01m04_S                   1               85 38.36237 18.353790 252.3483
## 01m05_S                   1               95 37.71366 20.699810 282.3224
## 01m06_S                   2               78 39.19682  8.391730 118.2369
## 02m01_S                   5               45 37.41552 19.713560 278.0889
## 02m02_S                  10               30 38.40148 19.559160 267.3011
## 02m03_S                   2               13 38.93042 18.647260 240.2760
## 02m04_S                  10               30 40.40274 16.808220 216.8560
## 02m05_S                   5               10 40.38089 18.725840 249.3837
## 02m06_S                   5               15 41.57071 19.564580 263.1396
## 02m07_S                   5               10 40.42192 18.300640 262.7113
## 02m08_S                   5               10 41.24604 16.580070 236.0363
## 02m09_S                   5               15 43.07667 14.044110 199.9340
## 02m10_S                   5               20 41.40282 16.478370 230.7487
## 02m11_S                   0                8 38.29022 19.139970 260.5252
## 04m01_S                  NA               NA 37.57460 18.989200 263.2088
## 04m02_S                  NA               NA 38.23949 20.460710 266.7046
## 04m03_S                  NA               NA 38.66996 21.090990 268.6730
## 04m04_S                  NA               NA 38.53184 19.752330 263.0540
## 04m05_S                  NA               NA 38.60799 17.753540 248.6051
## 04m06_S                  NA               NA 38.40265 17.471470 256.1535
## 04m07_S                  NA               NA 38.40001 19.283240 279.1496
## 04m08_S                  NA               NA 40.41111 10.877780 233.8889
## 04m09_S                  NA               NA 37.67970 20.823870 447.8220
## 04m10_S                  NA               NA 36.76538 17.605280 378.5998
## 04m11_S                  20               65 38.24263 21.433920 290.3476
## 04m12_S                   1               30 39.19880 15.232070 216.4251
## 04m13_S                   4               35       NA        NA       NA
## 04t01_S                   1               40       NA        NA       NA
## 04t02_S                  20               40 36.41330 20.440760 266.4446
## 04w01_S                   1               10       NA        NA       NA
## 04w02_S                   1               40 39.47468 13.027200 182.7960
## 04w03_S                   1               20 38.60776 17.655170 242.7429
## 04w04_S                  NA               NA 40.62702  8.231568 121.9809
## 20m01_S                  NA               NA       NA        NA       NA
## 20m02_S                  NA               NA       NA        NA       NA
## 20m03_S                   3                1       NA        NA       NA
## 20m04_S                  15               15 37.82488 18.272930 257.9912
## 20m05_S                   1                7 37.49003 20.545300 284.1714
## sfm01_S                  NA               NA 37.84584 17.725240 248.7184
## sfm02_S                   2                5 37.37885 19.135270 257.8768
## sfm03_S                  10               15 39.56851 17.270260 236.4955
## sfm04_S                   1               19 41.10526 16.296770 229.6165
## sfm05_S                   1               15 39.02887 18.860440 267.3889
## sfm06_S                   1                9 38.29906 18.485370 255.1875
## sfm07_S                   5                1 40.03592 20.560300 269.5654
## Sft01_S                  40               30 39.00162 16.347990 223.8743
## Sft02_S                  NA               NA 38.93783 17.121400 237.3192
##         project     date rType rep sublocation month time_cst sub_watershed
## 01m01_S    AIMS 20210605  ENVD   1          SW  June    15:35           01M
## 01m02_S    AIMS 20210605  ENVD   1          SW  June    17:15           01M
## 01m03_S    AIMS 20210606  ENVD   1          SW  June     9:00           01M
## 01m04_S    AIMS 20210606  ENVD   1          SW  June    10:37           01M
## 01m05_S    AIMS 20210606  ENVD   1          SW  June    12:15           01M
## 01m06_S    AIMS 20210606  ENVD   1          SW  June    14:04           01M
## 02m01_S    AIMS 20210605  ENVD   1          SW  June     9:21           02M
## 02m02_S    AIMS 20210605  ENVD   1          SW  June    11:06           02M
## 02m03_S    AIMS 20210605  ENVD   1          SW  June    13:14           02M
## 02m04_S    AIMS 20210605  ENVD   1          SW  June    15:00           02M
## 02m05_S    AIMS 20210605  ENVD   1          SW  June    16:21           02M
## 02m06_S    AIMS 20210606  ENVD   1          SW  June    17:50           02M
## 02m07_S    AIMS 20210606  ENVD   1          SW  June    10:05           02M
## 02m08_S    AIMS 20210606  ENVD   1          SW  June    11:30           02M
## 02m09_S    AIMS 20210606  ENVD   1          SW  June    12:54           02M
## 02m10_S    AIMS 20210606  ENVD   1          SW  June    15:00           02M
## 02m11_S    AIMS 20210606  ENVD   1          SW  June    16:40           02M
## 04m01_S    AIMS 20210603  ENVD   1          SW  June    11:15           04M
## 04m02_S    AIMS 20210605  ENVD   1          SW  June    14:50           04M
## 04m03_S    AIMS 20210605  ENVD   1          SW  June                    04M
## 04m04_S    AIMS 20210605  ENVD   1          SW  June    16:03           04M
## 04m05_S    AIMS 20210605  ENVD   1          SW  June    17:25           04M
## 04m06_S    AIMS 20210606  ENVD   1          SW  June     8:30           04M
## 04m07_S    AIMS 20210606  ENVD   1          SW  June    10:00           04M
## 04m08_S    AIMS 20210606  ENVD   1          SW  June    11:40           04M
## 04m09_S    AIMS 20210606  ENVD   1          SW  June    15:30           04M
## 04m10_S    AIMS 20210606  ENVD   1          SW  June    16:30           04M
## 04m11_S    AIMS 20210607  ENVD   1          SW  June    13:45           04M
## 04m12_S    AIMS 20210607  ENVD   1          SW  June    14:22           04M
## 04m13_S    AIMS 20210607  ENVD   1          SW  June    16:13           04M
## 04t01_S    AIMS 20210604  ENVD   1          SW  June     9:36           04M
## 04t02_S    AIMS 20210607  ENVD   1          SW  June    11:00           04M
## 04w01_S    AIMS 20210607  ENVD   1          SW  June     8:40           04W
## 04w02_S    AIMS 20210607  ENVD   1          SW  June     9:44           04W
## 04w03_S    AIMS 20210607  ENVD   1          SW  June    10:44           04W
## 04w04_S    AIMS 20210607  ENVD   1          SW  June    12:00           04W
## 20m01_S    AIMS 20210605  ENVD   1          SW  June    15:41           20M
## 20m02_S    AIMS 20210605  ENVD   1          SW  June    16:27           20M
## 20m03_S    AIMS 20210605  ENVD   1          SW  June    17:00           20M
## 20m04_S    AIMS 20210606  ENVD   1          SW  June     9:25           20M
## 20m05_S    AIMS 20210606  ENVD   1          SW  June    10:53           20M
## sfm01_S    AIMS 20210604  ENVD   1          SW  June    10:54           SFM
## sfm02_S    AIMS 20210604  ENVD   1          SW  June    14:00           SFM
## sfm03_S    AIMS 20210605  ENVD   1          SW  June                    SFM
## sfm04_S    AIMS 20210605  ENVD   1          SW  June                    SFM
## sfm05_S    AIMS 20210605  ENVD   1          SW  June    10:57           SFM
## sfm06_S    AIMS 20210605  ENVD   1          SW  June    12:16           SFM
## sfm07_S    AIMS 20210605  ENVD   1          SW  June    13:51           SFM
## Sft01_S    AIMS 20210606  ENVD   1          SW  June    14:58           SFM
## Sft02_S    AIMS 20210606  ENVD   1          SW  June    13:12           SFM
##         burn_area burn_interval stream_order elevation flow_state conductivity
## 01m01_S       N1B      1.205882            3  373.9098    flowing        560.0
## 01m02_S       N1B      1.205882            3  375.4253    flowing        562.0
## 01m03_S       N1B      1.205882            3  378.8144    flowing        557.7
## 01m04_S       N1B      1.205882            3  381.3559    flowing        542.8
## 01m05_S       N1B      1.205882            3  384.7108    flowing        527.8
## 01m06_S       N1B      1.205882            2  394.2241    flowing        575.6
## 02m01_S       N1A      1.051282            1  353.3494    flowing        546.1
## 02m02_S       N1A      1.051282            1  356.2749    flowing        560.4
## 02m03_S       N2B      2.277778            1  358.4956    flowing        558.4
## 02m04_S       N2B      2.277778            1  364.2157    flowing        558.0
## 02m05_S       N2B      2.277778            1  367.7589    flowing        564.0
## 02m06_S       N2B      2.277778            1  369.4064    flowing        561.2
## 02m07_S       N2B      2.277778            1  373.2965    flowing        568.6
## 02m08_S       N2B      2.277778            1  376.8670    flowing        566.0
## 02m09_S       N2B      2.277778            1  379.9472    flowing        557.7
## 02m10_S       N2B      2.277778            1  387.2234    flowing        541.4
## 02m11_S       N2B      2.277778            1  401.5449    flowing        566.9
## 04m01_S       N2B      2.277778            2  355.1574    flowing        534.5
## 04m02_S       N2B      2.277778            2  362.0723    flowing        534.6
## 04m03_S       N4D      4.100000            2  364.9916    flowing        521.4
## 04m04_S       N4D      4.100000            2  367.7222    flowing        548.1
## 04m05_S       N4D      4.100000            2  370.0585    flowing        559.0
## 04m06_S       N4D      4.100000            2  372.0548    flowing        557.2
## 04m07_S       N4D      4.100000            2  376.4349    flowing        557.3
## 04m08_S       N4D      4.100000            2  380.3074    flowing        558.3
## 04m09_S       N4D      4.100000            2  384.8762    flowing        546.1
## 04m10_S       N4D      4.100000            2  393.9353    flowing        555.0
## 04m11_S       N4D      4.100000            2  404.7170    flowing        528.5
## 04m12_S       N4D      4.100000            1  407.2463    flowing        569.1
## 04m13_S       N4D      4.100000            1  407.2463        dry           NA
## 04t01_S       N4B      3.416667            1  379.5954        dry           NA
## 04t02_S       N4B      3.416667            1  387.0224    flowing        546.1
## 04w01_S       N2B      2.277778            1  360.5698        dry           NA
## 04w02_S       N2B      2.277778            1  370.9928    flowing        541.2
## 04w03_S       N2B      2.277778            1  382.2555    flowing        555.9
## 04w04_S       N2B      2.277778            1  391.0867    flowing        561.7
## 20m01_S      N20B      6.833333            1  371.0545        dry           NA
## 20m02_S      N20B      6.833333            1  378.9335       pool           NA
## 20m03_S      N20B      6.833333            1  385.9613        dry           NA
## 20m04_S      N20B      6.833333            1  389.7962    flowing        544.1
## 20m05_S      N20B      6.833333            1  401.0049    flowing        529.8
## sfm01_S       N1A      1.051282            3  350.8112    flowing        561.1
## sfm02_S       N4B      3.416667            3  352.7506    flowing        545.7
## sfm03_S       N4B      3.416667            3  353.4152    flowing        574.9
## sfm04_S       N4B      3.416667            3  356.1383    flowing        564.8
## sfm05_S       N4B      3.416667            3  361.0678    flowing        559.5
## sfm06_S      N20B      6.833333            3  365.2245    flowing        549.4
## sfm07_S      N20B      6.833333            3  367.3486    flowing        528.8
## Sft01_S       N4B      3.416667            1  356.8398    flowing        589.7
## Sft02_S       N4B      3.416667            1  372.4689    flowing        536.1
##         canopy_cover_percent      long      lat stic_sublocation
## 01m01_S                 44.8 -96.57702 39.08667               HS
## 01m02_S                 74.0 -96.57633 39.08629               HS
## 01m03_S                  2.1 -96.57594 39.08471               HS
## 01m04_S                 85.4 -96.57516 39.08364               LS
## 01m05_S                 56.3 -96.57419 39.08264               HS
## 01m06_S                 60.4 -96.57158 39.08065               HS
## 02m01_S                 71.9 -96.58813 39.09188               LS
## 02m02_S                 86.5 -96.58833 39.09084               HS
## 02m03_S                 92.7 -96.58859 39.08991               HS
## 02m04_S                 96.9 -96.58964 39.08824                 
## 02m05_S                 28.1 -96.59082 39.08698                 
## 02m06_S                 46.9 -96.59143 39.08724               HS
## 02m07_S                 14.6 -96.59252 39.08648               HS
## 02m08_S                 51.0 -96.59291 39.08557               HS
## 02m09_S                 40.6 -96.59339 39.08482               HS
## 02m10_S                 27.1 -96.59357 39.08251               HS
## 02m11_S                  0.0 -96.59368 39.07925               HS
## 04m01_S                 76.0 -96.58620 39.08984               HS
## 04m02_S                  6.3 -96.58481 39.08775               HS
## 04m03_S                 26.0 -96.58366 39.08685               HS
## 04m04_S                 65.6 -96.58345 39.08576               HS
## 04m05_S                 96.9 -96.58310 39.08502               HS
## 04m06_S                 84.4 -96.58342 39.08426               HS
## 04m07_S                 70.8 -96.58253 39.08278               HS
## 04m08_S                 31.3 -96.58221 39.08131               HS
## 04m09_S                 32.3 -96.58163 39.07994               HS
## 04m10_S                 62.5 -96.58289 39.07743               HS
## 04m11_S                 37.5 -96.58383 39.07472               HS
## 04m12_S                 72.9 -96.58406 39.07316               HS
## 04m13_S                 50.0 -96.58430 39.07081               HS
## 04t01_S                 10.4 -96.58430 39.08236               HS
## 04t02_S                  1.0 -96.58083 39.07970               HS
## 04w01_S                 64.6 -96.58543 39.08816               HS
## 04w02_S                 95.8 -96.58689 39.08609               HS
## 04w03_S                 34.4 -96.58804 39.08386               HS
## 04w04_S                 93.8 -96.58866 39.08223               HS
## 20m01_S                 13.5 -96.57694 39.08838               HS
## 20m02_S                  0.0 -96.57370 39.08921               HS
## 20m03_S                 35.4 -96.57178 39.08822               HS
## 20m04_S                 76.0 -96.57111 39.08709               HS
## 20m05_S                  4.2 -96.56800 39.08600               HS
## sfm01_S                 78.1 -96.58719 39.09228               HS
## sfm02_S                 84.4 -96.58632 39.09126               HS
## sfm03_S                 63.5 -96.58578 39.09099               LS
## sfm04_S                 86.5 -96.58440 39.09089               HS
## sfm05_S                 80.2 -96.58186 39.09019               HS
## sfm06_S                 85.4 -96.57941 39.08950                 
## sfm07_S                 97.9 -96.57846 39.08868               HS
## Sft01_S                  2.1 -96.58517 39.09185               HS
## Sft02_S                  4.2 -96.57852 39.09105               HS
##         stream_temp_C_1wk_avg stream_temp_C_2wk_avg stream_temp_C_3wk_avg
## 01m01_S              14.99187              15.52654              15.52654
## 01m02_S              15.00088              15.62155              15.62155
## 01m03_S              16.58707              16.81508              16.89144
## 01m04_S              16.35122              16.62819              16.70815
## 01m05_S              15.99709              16.13474              16.19758
## 01m06_S              14.76880              15.05902              15.15786
## 02m01_S              15.83346              16.46933              16.46933
## 02m02_S              15.72499              16.30161              16.30161
## 02m03_S              15.89609              16.38938              16.38938
## 02m04_S                    NA                    NA                    NA
## 02m05_S                    NA                    NA                    NA
## 02m06_S              16.08588              16.22219              16.26795
## 02m07_S              15.51903              15.69292              15.73883
## 02m08_S              15.38467              15.59371              15.64881
## 02m09_S              15.52730              15.62343              15.66680
## 02m10_S              15.42985              15.63123              15.68870
## 02m11_S              18.03801              17.57932              17.58944
## 04m01_S              15.25973              15.88678              15.88678
## 04m02_S              15.27976              15.73862              15.73862
## 04m03_S              15.05235              15.62948              15.62948
## 04m04_S              14.93837              15.36597              15.36597
## 04m05_S              14.80410              15.18022              15.18022
## 04m06_S              15.11215              17.15255              17.47976
## 04m07_S              14.79667              14.99342              15.02939
## 04m08_S              14.76238              14.94428              14.97109
## 04m09_S              15.46201              15.59828              15.63621
## 04m10_S              15.49736              15.61895              15.65965
## 04m11_S              15.80325              15.53535              15.59864
## 04m12_S              15.04872              15.04683              15.21936
## 04m13_S              20.93713              19.98362              20.19477
## 04t01_S              16.21178              17.83773              17.83773
## 04t02_S              16.33662              16.26803              16.36318
## 04w01_S              19.60074              18.54883              18.55940
## 04w02_S              16.49336              16.48086              16.58824
## 04w03_S              17.07074              16.91755              16.97935
## 04w04_S              17.81425              17.18182              17.34407
## 20m01_S              16.67287              18.72120              18.72120
## 20m02_S              14.59120              15.59831              15.59831
## 20m03_S              14.70236              17.07537              17.07537
## 20m04_S              15.98811              16.32228              16.37584
## 20m05_S              15.84432              16.17126              16.24164
## sfm01_S              14.95903              15.77372              15.77372
## sfm02_S              14.99649              15.85153              15.85153
## sfm03_S              15.15370              15.87817              15.87817
## sfm04_S              15.09614              15.70999              15.70999
## sfm05_S              15.28462              15.92358              15.92358
## sfm06_S                    NA                    NA                    NA
## sfm07_S              15.39202              16.03691              16.03691
## Sft01_S              15.79067              16.04113              16.11101
## Sft02_S              16.26859              16.67016              16.70813
##         percent_wet_1wk_avg percent_wet_2wk_avg percent_wet_3wk_avg      twi
## 01m01_S          1.00000000           1.0000000           1.0000000 16.61854
## 01m02_S          1.00000000           1.0000000           1.0000000 15.35936
## 01m03_S          1.00000000           1.0000000           1.0000000 15.67691
## 01m04_S          1.00000000           1.0000000           1.0000000 15.51595
## 01m05_S          0.98216939           0.9910781           0.9916725 15.96002
## 01m06_S          1.00000000           1.0000000           1.0000000 15.75029
## 02m01_S          1.00000000           1.0000000           1.0000000 17.50626
## 02m02_S          1.00000000           1.0000000           1.0000000 16.74125
## 02m03_S          1.00000000           1.0000000           1.0000000 15.93150
## 02m04_S                  NA                  NA                  NA 16.02225
## 02m05_S                  NA                  NA                  NA 16.33888
## 02m06_S          1.00000000           1.0000000           1.0000000 15.43594
## 02m07_S          1.00000000           1.0000000           1.0000000 15.26017
## 02m08_S          1.00000000           1.0000000           1.0000000 15.93291
## 02m09_S          1.00000000           1.0000000           1.0000000 14.74790
## 02m10_S          1.00000000           1.0000000           1.0000000 14.12819
## 02m11_S          1.00000000           1.0000000           1.0000000 14.58442
## 04m01_S          1.00000000           1.0000000           1.0000000 16.12752
## 04m02_S          1.00000000           1.0000000           1.0000000 15.95807
## 04m03_S          1.00000000           1.0000000           1.0000000 17.71474
## 04m04_S          1.00000000           1.0000000           1.0000000 15.89908
## 04m05_S          1.00000000           1.0000000           1.0000000 16.17441
## 04m06_S          1.00000000           0.5940520           0.5544761 15.63759
## 04m07_S          1.00000000           1.0000000           1.0000000 17.33315
## 04m08_S          1.00000000           1.0000000           1.0000000 15.45113
## 04m09_S          1.00000000           1.0000000           1.0000000 15.01552
## 04m10_S          1.00000000           1.0000000           1.0000000 14.87435
## 04m11_S          1.00000000           1.0000000           1.0000000 13.76612
## 04m12_S          1.00000000           1.0000000           1.0000000 14.38845
## 04m13_S          0.18573551           0.1895911           0.2908263 14.38845
## 04t01_S          0.62109955           0.6869496           0.6869496 14.65861
## 04t02_S          1.00000000           1.0000000           1.0000000 13.50106
## 04w01_S          0.68499257           0.8423792           0.8620690 14.72918
## 04w02_S          1.00000000           1.0000000           1.0000000 14.14492
## 04w03_S          1.00000000           1.0000000           1.0000000 13.66540
## 04w04_S          0.08766716           0.3353160           0.4183474 14.39993
## 20m01_S          0.14561664           0.1858736           0.1858736 14.87513
## 20m02_S          1.00000000           1.0000000           1.0000000 16.03198
## 20m03_S          1.00000000           0.8848539           0.8848539 15.66395
## 20m04_S          1.00000000           1.0000000           1.0000000 15.41921
## 20m05_S          1.00000000           1.0000000           1.0000000 13.70703
## sfm01_S          1.00000000           1.0000000           1.0000000 18.44983
## sfm02_S          1.00000000           1.0000000           1.0000000 17.58335
## sfm03_S          1.00000000           1.0000000           1.0000000 18.85499
## sfm04_S          1.00000000           1.0000000           1.0000000 18.68798
## sfm05_S          1.00000000           1.0000000           1.0000000 16.93182
## sfm06_S                  NA                  NA                  NA 16.90306
## sfm07_S          1.00000000           1.0000000           1.0000000 17.54719
## Sft01_S          1.00000000           1.0000000           1.0000000 13.78743
## Sft02_S          1.00000000           0.9836431           0.9847328 14.25019
##         distance_from_outlet drainage_area wetted_width slope_percent
## 01m01_S                1.400       28.3099         3.26     1.9659865
## 01m02_S                1.510       27.8823         1.64     6.7913133
## 01m03_S                1.700       25.9970            1     4.6210146
## 01m04_S                1.840       24.7503         5.29     5.1649304
## 01m05_S                2.000       19.8808          1.6     2.6663996
## 01m06_S                2.460       10.5589                  1.7473247
## 02m01_S                0.102       24.1532          1.1     0.6906100
## 02m02_S                0.235       23.7320          1.1     1.4580085
## 02m03_S                0.360       20.3529          1.9     2.8084484
## 02m04_S                0.620       18.9885        1.615     2.3933994
## 02m05_S                0.809       17.7830          2.1     1.6336321
## 02m06_S                0.880       15.6919          1.1     3.5524391
## 02m07_S                1.040       14.1328                  3.8135683
## 02m08_S                1.200       12.9671          1.3     1.7876415
## 02m09_S                1.330        9.8943          1.3     4.4537733
## 02m10_S                1.600        6.1497          1.7     5.1409352
## 02m11_S                2.000        2.6741         0.25     1.4200636
## 04m01_S                0.320       39.7602            2     4.5041414
## 04m02_S                0.660       30.2096            3     4.0557311
## 04m03_S                0.810       29.3020          1.3     0.6801648
## 04m04_S                0.950       28.4130          1.7     4.0463663
## 04m05_S                1.060       23.8689            2     2.5836580
## 04m06_S                1.200       23.3323          1.5     4.3149004
## 04m07_S                1.400       15.1506          1.7     0.5150872
## 04m08_S                1.600       13.8929          2.3     3.0987060
## 04m09_S                1.800        8.4654          1.2     2.9192216
## 04m10_S                2.100        6.5928          0.6     2.6186152
## 04m11_S                2.500        2.8759         0.57     3.4581806
## 04m12_S                2.700        2.2526          2.7     1.4551936
## 04m13_S                2.930        2.2526                  1.4551936
## 04t01_S                1.450        6.6500                  3.2760137
## 04t02_S                1.800        3.6848                  5.7631675
## 04w01_S                0.600        7.6246          dry     3.4996900
## 04w02_S                0.880        6.1046          1.1     5.0192408
## 04w03_S                1.200        4.2006            2     5.5754928
## 04w04_S                1.400        2.9436          0.5     1.8795989
## 20m01_S                1.310       18.9453                  7.4814887
## 20m02_S                1.650       16.3166                  2.0370426
## 20m03_S                1.910        9.0899                  1.6399257
## 20m04_S                2.060        8.6075                  1.9832584
## 20m05_S                2.400        5.4440                  6.9193510
## sfm01_S                0.000      132.6873                  1.4764745
## sfm02_S                0.140      107.6787                  2.8482142
## sfm03_S                0.180       67.0512                  0.4976569
## sfm04_S                0.350       60.9054                  0.5342054
## sfm05_S                0.660       58.6702                  2.9770306
## sfm06_S                0.910       51.0121                  2.6644572
## sfm07_S                1.100       49.9061                  1.3695436
## Sft01_S                0.300        4.5053                  5.2945770
## Sft02_S                1.010        4.8346                  3.5823484
##                                   weather   pH
## 01m01_S clear, some clouds, hot sunny 90s 8.07
## 01m02_S                sunny, clear, warm 8.00
## 01m03_S         cloudy, warm, nice breeze 8.20
## 01m04_S                  some sun, cloudy 8.13
## 01m05_S                  some sun, cloudy 8.18
## 01m06_S                sunny, come clouds 7.99
## 02m01_S               sunny, 75deg, clear 7.94
## 02m02_S                 sunny, clear, 80s 8.22
## 02m03_S                sunny (relentless) 8.15
## 02m04_S                sunny, clear skies 8.12
## 02m05_S                             sunny 8.18
## 02m06_S                             sunny 8.16
## 02m07_S              cloudy, cool, breeze 7.97
## 02m08_S                  overcast, breezy 7.98
## 02m09_S                      75, overcast 7.71
## 02m10_S                             sunny 7.89
## 02m11_S                             BLANK 8.02
## 04m01_S                 hot, clear, sunny 8.33
## 04m02_S            sunny! Hot! Clear sky! 8.17
## 04m03_S               hot, partly cloudly 8.16
## 04m04_S                             sunny 8.17
## 04m05_S    sunny, cooler in shade, breezy 8.04
## 04m06_S               hot, cloudy, breezy 8.10
## 04m07_S              overcast, mild temps 8.11
## 04m08_S    overcast, mild, somewhat windy 7.73
## 04m09_S                       cloudy, hot 8.07
## 04m10_S                       cloudy, hot 8.07
## 04m11_S                        80s, sunny 8.25
## 04m12_S                  80s, hot as heck 8.21
## 04m13_S                        80s, sunny   NA
## 04t01_S                               80s   NA
## 04t02_S                               80s 8.25
## 04w01_S                        hot, sunny   NA
## 04w02_S                       warm, sunny 8.08
## 04w03_S                       suuny, warm 8.16
## 04w04_S                        sunny, hot 8.02
## 20m01_S                        90s, sunny   NA
## 20m02_S                        90s, sunny   NA
## 20m03_S                        90s, sunny   NA
## 20m04_S                     70s, overcast 8.24
## 20m05_S                     70s, overcast 8.13
## sfm01_S                      clear, sunny 8.01
## sfm02_S                 sunny, clear, hot 8.10
## sfm03_S                 sunny, clear, hot 7.98
## sfm04_S                 sunny, clear, hot 8.06
## sfm05_S                  ~70s, hot, sunny 8.02
## sfm06_S                        80s, sunny 8.06
## sfm07_S                        90s, sunny 8.01
## Sft01_S                        80s, sunny 8.02
## Sft02_S                80s, partly cloudy 8.13
##                                                                     crewBGC
## 01m01_S                                      Connor Brown, Rachel Wakefield
## 01m02_S                                      Connor Brown, Rachel Wakefield
## 01m03_S                                      Connor Brown, Rachel Wakefield
## 01m04_S                                      Connor Brown, Rachel Wakefield
## 01m05_S                                      Connor Brown, Rachel Wakefield
## 01m06_S                                      Connor Brown, Rachel Wakefield
## 02m01_S                                            Erin Seybold, Amy Burgin
## 02m02_S                                Erin Seybold, Amy Burgin, Kaci Zarek
## 02m03_S                                Erin Seybold, Amy Burgin, Kaci Zarek
## 02m04_S                                Erin Seybold, Amy Burgin, Kaci Zarek
## 02m05_S                                Erin Seybold, Amy Burgin, Kaci Zarek
## 02m06_S                                Erin Seybold, Amy Burgin, Kaci Zarek
## 02m07_S                                              Amy Burgin, Kaci Zarek
## 02m08_S                                Erin Seybold, Amy Burgin, Kaci Zarek
## 02m09_S                                Erin Seybold, Amy Burgin, Kaci Zarek
## 02m10_S                                            Erin Seybold, Amy Burgin
## 02m11_S                                Erin Seybold, Amy Burgin, Kaci Zarek
## 04m01_S                                           Jess Wilhelm, Sarah Flynn
## 04m02_S                                           Jess Wilhelm, Sarah Flynn
## 04m03_S                                           Jess Wilhelm, Sarah Flynn
## 04m04_S                                           Jess Wilhelm, Sarah Flynn
## 04m05_S                                           Jess Wilhelm, Sarah Flynn
## 04m06_S                                           Jess Wilhelm, Sarah Flynn
## 04m07_S                                           Jess Wilhelm, Sarah Flynn
## 04m08_S                                           Jess Wilhelm, Sarah Flynn
## 04m09_S                                           Jess Wilhelm, Sarah Flynn
## 04m10_S                                           Jess Wilhelm, Sarah Flynn
## 04m11_S                                             Eva Burke, Bri Richards
## 04m12_S                                 Bri Richards, Eva Burke, Sam Thomas
## 04m13_S                                 Bri Richards, Eva Burke, Sam Thomas
## 04t01_S                                 Bri Richards, Eva Burke, Sam Thomas
## 04t02_S                                 Bri Richards, Eva Burke, Sam Thomas
## 04w01_S                               Sarah Flynn, Jess Wilhelm, Kaci Zarek
## 04w02_S                               Sarah Flynn, Jess Wilhelm, Kaci Zarek
## 04w03_S                               Sarah Flynn, Jess Wilhelm, Kaci Zarek
## 04w04_S                               Sarah Flynn, Jess Wilhelm, Kaci Zarek
## 20m01_S                                             Eva Burke, Bri Richards
## 20m02_S                                             Eva Burke, Bri Richards
## 20m03_S                                             Eva Burke, Bri Richards
## 20m04_S                                             Eva Burke, Bri Richards
## 20m05_S                                             Eva Burke, Bri Richards
## sfm01_S Erin Seybold, Jess Wilhelm, Connor Brown, Bri Richards, Sarah Flynn
## sfm02_S Erin Seybold, Jess Wilhelm, Connor Brown, Bri Richards, Sarah Flynn
## sfm03_S               Jess Wilhelm, Connor Brown, Bri Richards, Sarah Flynn
## sfm04_S                                                               BLANK
## sfm05_S                                          Bri Richards, Connor Brown
## sfm06_S             Connor Brown, Bri Richards, Rachel Wakefield, Eva Burke
## sfm07_S             Connor Brown, Bri Richards, Rachel Wakefield, Eva Burke
## Sft01_S                                             Eva Burke, Bri Richards
## Sft02_S                                             Eva Burke, Bri Richards
##                                                                           crewMicro
## 01m01_S                                                    Ken Aho, Michael J Braus
## 01m02_S                                                    Ken Aho, Michael J Braus
## 01m03_S                                                    Ken Aho, Michael J Braus
## 01m04_S                                                    Ken Aho, Michael J Braus
## 01m05_S                                                    Ken Aho, Michael J Braus
## 01m06_S                                                    Ken Aho, Michael J Braus
## 02m01_S                           Kevin Kuehn, Charlie Bond, Diana Diaz, Brett Nave
## 02m02_S                                                      Brett Nave, Diana Diaz
## 02m03_S                                                      Brett Nave, Diana Diaz
## 02m04_S                                                      Brett Nave, Diana Diaz
## 02m05_S                                                      Brett Nave, Diana Diaz
## 02m06_S                                                      Brett Nave, Diana Diaz
## 02m07_S                                                     Brett Nave, Brooke Vogt
## 02m08_S                                                     Brett Nave, Brooke Vogt
## 02m09_S                                                     Brett Nave, Brooke Vogt
## 02m10_S                                                      Brett Nave, Kaci Zarek
## 02m11_S                                                                  Brett Nave
## 04m01_S                                                   Kevin Kuehn, Charlie Bond
## 04m02_S                                                   Kevin Kuehn, Charlie Bond
## 04m03_S                                                   Kevin Kuehn, Charlie Bond
## 04m04_S                                                   Kevin Kuehn, Charlie Bond
## 04m05_S                                                   Kevin Kuehn, Charlie Bond
## 04m06_S                                                   Kevin Kuehn, Charlie Bond
## 04m07_S                                                   Kevin Kuehn, Charlie Bond
## 04m08_S                                                   Kevin Kuehn, Charlie Bond
## 04m09_S                                                   Kevin Kuehn, Charlie Bond
## 04m10_S                                                   Kevin Kuehn, Charlie Bond
## 04m11_S                                        Charlie Bond, Harley-Payj Leatherman
## 04m12_S                          Lydia Zeglin, Charlie Bond, Harley-Payj Leatherman
## 04m13_S                          Lydia Zeglin, Charlie Bond, Harley-Payj Leatherman
## 04t01_S                          Lydia Zeglin, Charlie Bond, Harley-Payj Leatherman
## 04t02_S                          Lydia Zeglin, Charlie Bond, Harley-Payj Leatherman
## 04w01_S                                                    Ken Aho, Michael J Braus
## 04w02_S                                                    Ken Aho, Michael J Braus
## 04w03_S                                                    Ken Aho, Michael J Braus
## 04w04_S                                                    Ken Aho, Michael J Braus
## 20m01_S                                                     Eva Burke, Lydia Zeglin
## 20m02_S                                        Lydia Zeglin, Harley-Payj Leatherman
## 20m03_S                                        Lydia Zeglin, Harley-Payj Leatherman
## 20m04_S                                        Lydia Zeglin, Harley-Payj Leatherman
## 20m05_S                                        Lydia Zeglin, Harley-Payj Leatherman
## sfm01_S Brett Nave, Lydia Zeglin, Charlie Bond, Ken Aho, Rob Ramos, Michael J Braus
## sfm02_S Brett Nave, Lydia Zeglin, Charlie Bond, Ken Aho, Rob Ramos, Michael J Braus
## sfm03_S                                                                       BLANK
## sfm04_S                                                                       BLANK
## sfm05_S              Lydia Zeglin, Michael J Braus, Ken Aho, Harley-Payj Leatherman
## sfm06_S              Lydia Zeglin, Michael J Braus, Ken Aho, Harley-Payj Leatherman
## sfm07_S              Lydia Zeglin, Michael J Braus, Ken Aho, Harley-Payj Leatherman
## Sft01_S                                        Lydia Zeglin, Harley-Payj Leatherman
## Sft02_S                                        Lydia Zeglin, Harley-Payj Leatherman
##         wetdrybin   alpha.cent   page.rank imp.closeness.cent betweenness.cent
## 01m01_S         1           NA          NA                 NA               NA
## 01m02_S         1 2.227619e+09 0.022524170          0.2388125               24
## 01m03_S         1 5.510795e+06 0.019353794          0.2549933               21
## 01m04_S         1 1.438817e+04 0.015623939          0.5225321               16
## 01m05_S         1 1.231568e+02 0.011235874          0.3356343                9
## 01m06_S         1 1.000000e+00 0.006073446          0.0000000                0
## 02m01_S         1 1.429936e+23 0.033713970          1.2118946               10
## 02m02_S         1 2.297338e+21 0.032518264          0.6715845               18
## 02m03_S         1 1.447618e+19 0.031111551          0.6668311               24
## 02m04_S         1 1.106869e+17 0.029456595          0.5153950               28
## 02m05_S         1 7.389150e+14 0.027509587          0.3065895               30
## 02m06_S         1 2.383760e+12 0.025218990          0.2542547               30
## 02m07_S         1 5.599429e+09 0.022524170          0.3314081               28
## 02m08_S         1 2.516975e+07 0.019353794          0.2155983               24
## 02m09_S         1 7.677335e+04 0.015623939          0.1427609               18
## 02m10_S         1 1.508025e+02 0.011235874          0.2736938               10
## 02m11_S         1 1.000000e+00 0.006073446          0.0000000                0
## 04m01_S         1 1.499246e+26 0.036385276          0.7094577               24
## 04m02_S         1 1.038099e+24 0.035660977          0.5690639               33
## 04m03_S         1 5.556482e+21 0.034808861          0.4520184               40
## 04m04_S         1 1.686326e+19 0.033806371          0.6350717               45
## 04m05_S         1 1.199949e+17 0.032626971          0.4365059               48
## 04m06_S         1 4.511630e+14 0.031239442          0.4334246               49
## 04m07_S         1 1.758850e+12 0.029607055          0.4374748               48
## 04m08_S         1 7.518766e+09 0.027686599          0.4364054               45
## 04m09_S         1 1.872708e+07 0.019353794          0.2339300               30
## 04m10_S         1 5.049598e+04 0.015623939          0.3123012               22
## 04m11_S         1 2.742202e+02 0.011235874          0.1500621               12
## 04m12_S         1 1.000000e+00 0.006073446          0.0000000                0
## 04m13_S         0           NA          NA                 NA               NA
## 04t01_S         0           NA          NA                 NA               NA
## 04t02_S         1 1.000000e+00 0.006073446          0.0000000                0
## 04w01_S         0           NA          NA                 NA               NA
## 04w02_S         1 1.639315e+02 0.011235874          0.2516394                0
## 04w03_S         1           NA          NA                 NA               NA
## 04w04_S         1 1.000000e+00 0.006073446          0.0000000                0
## 20m01_S         0           NA          NA                 NA               NA
## 20m02_S         1 1.000000e+00 0.006073446          0.0000000                0
## 20m03_S         0           NA          NA                 NA               NA
## 20m04_S         1 2.773658e+02 0.011235874          0.1483541                0
## 20m05_S         1 1.000000e+00 0.006073446          0.0000000                0
## sfm01_S         1 8.235430e+30 0.095083882          1.6330347                0
## sfm02_S         1 2.520015e+28 0.071004190          1.3390882               24
## sfm03_S         1 1.149650e+19 0.040003835          0.6055277               20
## sfm04_S         1 2.256246e+16 0.033844659          0.5783555               24
## sfm05_S         1 1.184520e+14 0.032672016          0.6108834               28
## sfm06_S         1           NA          NA                 NA               NA
## sfm07_S         1 8.808420e+11 0.025218990          0.2500193               25
## Sft01_S         1 0.000000e+00 0.006073446          0.0000000                0
## Sft02_S         1 1.000000e+00 0.006073446          0.0000000                0
##         n.nodes.in.paths n.paths upstream.network.length path.length.mean
## 01m01_S               NA      NA                      NA               NA
## 01m02_S                4       4               1026.2137         780.4340
## 01m03_S                3       3                621.9854         501.6075
## 01m04_S                2       2                238.9767         177.8984
## 01m05_S                1       1                122.1568         122.1568
## 01m06_S                1       0                  0.0000           0.0000
## 02m01_S               10      10               2446.4219        1117.5401
## 02m02_S                9       9               2384.1787        1172.5521
## 02m03_S                8       8               2225.4810        1140.5862
## 02m04_S                7       7               2094.6961        1154.0586
## 02m05_S                6       6               1944.8995        1171.6390
## 02m06_S                5       5               1634.9202        1033.9917
## 02m07_S                4       4               1209.2061         760.3469
## 02m08_S                3       3                986.7395         717.1738
## 02m09_S                2       2                658.8946         583.9934
## 02m10_S                1       1                149.8025         149.8025
## 02m11_S                1       0                  0.0000           0.0000
## 04m01_S               12      12               2987.4094        1436.2436
## 04m02_S               11      11               2842.9871        1409.2597
## 04m03_S               10      10               2656.1605        1344.6764
## 04m04_S                9       9               2326.6582        1127.9712
## 04m05_S                8       8               2186.1251        1110.8679
## 04m06_S                7       7               1920.1574         965.6001
## 04m07_S                6       6               1663.6467         827.2711
## 04m08_S                5       5               1429.7189         712.0119
## 04m09_S                3       3                828.2233         584.6964
## 04m10_S                2       2                457.3604         320.7504
## 04m11_S                1       1                273.2202         273.2202
## 04m12_S                1       0                  0.0000           0.0000
## 04m13_S               NA      NA                      NA               NA
## 04t01_S               NA      NA                      NA               NA
## 04t02_S                1       0                  0.0000           0.0000
## 04w01_S               NA      NA                      NA               NA
## 04w02_S                1       1                162.9315         162.9315
## 04w03_S               NA      NA                      NA               NA
## 04w04_S                1       0                  0.0000           0.0000
## 20m01_S               NA      NA                      NA               NA
## 20m02_S                1       0                  0.0000           0.0000
## 20m03_S               NA      NA                      NA               NA
## 20m04_S                1       1                276.3658         276.3658
## 20m05_S                1       0                  0.0000           0.0000
## sfm01_S               36      36               9141.8043        1544.4877
## sfm02_S               24      24               6169.6472        1419.4947
## sfm03_S               10      10               2826.7084        1258.5955
## sfm04_S                8       8               2162.1418         980.6325
## sfm05_S                7       7               1971.6645         903.0345
## sfm06_S               NA      NA                      NA               NA
## sfm07_S                5       5               1421.6323        1019.7657
## Sft01_S                1       0                  0.0000           0.0000
## Sft02_S                1       0                  0.0000           0.0000
##         path.length.var path.length.skew path.length.kurt path.degree.mean
## 01m01_S              NA             <NA>               NA               NA
## 01m02_S       54316.821     -1.248785863        1.6976796         1.500000
## 01m03_S        9519.896      0.066974863               NA         1.333333
## 01m04_S        3730.568           #NAME?               NA         1.000000
## 01m05_S           0.000             <NA>               NA         0.000000
## 01m06_S              NA             <NA>               NA               NA
## 02m01_S      671357.198      0.370974689       -1.3388034         1.800000
## 02m02_S      608464.589      0.271073351       -1.4227284         1.777778
## 02m03_S      539974.121      0.133092965       -1.4235345         1.750000
## 02m04_S      450631.873     -0.010853048       -1.2887412         1.714286
## 02m05_S      329631.762     -0.031515342       -1.3367751         1.666667
## 02m06_S      217368.310      0.076868398       -2.3974893         1.600000
## 02m07_S      156084.891     -0.334968534       -3.1685438         1.500000
## 02m08_S       79528.637     -1.372761625               NA         1.333333
## 02m09_S        5610.194              Inf               NA         1.000000
## 02m10_S           0.000             <NA>               NA         0.000000
## 02m11_S              NA             <NA>               NA               NA
## 04m01_S      685100.475      0.056099525       -1.1486650         1.833333
## 04m02_S      581881.270      0.051359207       -1.1201534         1.818182
## 04m03_S      475691.709      0.100896097       -1.2067074         1.800000
## 04m04_S      401314.439       0.04780462       -1.1157912         1.777778
## 04m05_S      314364.590      0.094403399       -1.1958385         1.750000
## 04m06_S      242725.861      0.127465125       -1.3543796         1.714286
## 04m07_S      185411.970      0.098709732       -1.5602981         1.666667
## 04m08_S      138000.872     -0.061526721       -1.5543863         1.200000
## 04m09_S       35303.942      0.570981423               NA         1.333333
## 04m10_S       18662.314              Inf               NA         1.000000
## 04m11_S           0.000             <NA>               NA         0.000000
## 04m12_S              NA             <NA>               NA               NA
## 04m13_S              NA             <NA>               NA               NA
## 04t01_S              NA             <NA>               NA               NA
## 04t02_S              NA             <NA>               NA               NA
## 04w01_S              NA             <NA>               NA               NA
## 04w02_S           0.000             <NA>               NA         0.000000
## 04w03_S              NA             <NA>               NA               NA
## 04w04_S              NA             <NA>               NA               NA
## 20m01_S              NA             <NA>               NA               NA
## 20m02_S              NA             <NA>               NA               NA
## 20m03_S              NA             <NA>               NA               NA
## 20m04_S           0.000             <NA>               NA         0.000000
## 20m05_S              NA             <NA>               NA               NA
## sfm01_S      777673.412      0.194607866       -1.1602263         1.888889
## sfm02_S      687169.878      0.129037598       -1.1487930         1.833333
## sfm03_S      476988.579      0.048611958       -1.3427457         1.600000
## sfm04_S      320238.675      0.017314743       -1.8477390         1.750000
## sfm05_S      264053.134     -0.167224111       -1.8815127         1.428571
## sfm06_S              NA             <NA>               NA               NA
## sfm07_S      140905.808     -0.918431724       -0.4568918         1.600000
## Sft01_S              NA             <NA>               NA               NA
## Sft02_S              NA             <NA>               NA               NA
##         path.degree.var path.degree.skew path.degree.kurt in.eccentricity
## 01m01_S              NA               NA               NA              NA
## 01m02_S       0.2500000       0.00000000      -6.00000000       1026.2137
## 01m03_S       0.2222222       1.73205081               NA        621.9854
## 01m04_S       0.0000000               NA               NA        238.9767
## 01m05_S       0.0000000               NA               NA        122.1568
## 01m06_S              NA               NA               NA          0.0000
## 02m01_S       0.1600000      -1.77878118       1.40625000       2446.4219
## 02m02_S       0.1728395      -1.61984774       0.73469388       2384.1787
## 02m03_S       0.1875000      -1.44016460       0.00000000       2225.4810
## 02m04_S       0.2040816      -1.22963409      -0.84000000       2094.6961
## 02m05_S       0.2222222      -0.96824584      -1.87500000       1944.8995
## 02m06_S       0.2400000      -0.60858062      -3.33333333       1634.9202
## 02m07_S       0.2500000       0.00000000      -6.00000000       1209.2061
## 02m08_S       0.2222222       1.73205081               NA        986.7395
## 02m09_S       0.0000000               NA               NA        658.8946
## 02m10_S       0.0000000               NA               NA        149.8025
## 02m11_S              NA               NA               NA          0.0000
## 04m01_S       0.3055556      -0.06298367       0.65454546       2787.4053
## 04m02_S       0.3305785       0.02763854       0.41250000       2642.9831
## 04m03_S       0.3600000       0.13176157       0.17857143       2456.1565
## 04m04_S       0.3950617       0.25446429      -0.04017857       2126.6542
## 04m05_S       0.4375000       0.40406102      -0.22857143       1986.1211
## 04m06_S       0.4897959       0.59529405      -0.35000000       1720.1533
## 04m07_S       0.2222222      -0.96824584      -1.87500000       1463.6427
## 04m08_S       0.5600000      -0.51224083      -0.61224490       1229.7149
## 04m09_S       0.2222222       1.73205081               NA        828.2233
## 04m10_S       0.0000000               NA               NA        457.3604
## 04m11_S       0.0000000               NA               NA        273.2202
## 04m12_S              NA               NA               NA          0.0000
## 04m13_S              NA               NA               NA              NA
## 04t01_S              NA               NA               NA              NA
## 04t02_S              NA               NA               NA          0.0000
## 04w01_S              NA               NA               NA              NA
## 04w02_S       0.0000000               NA               NA        162.9315
## 04w03_S              NA               NA               NA              NA
## 04w04_S              NA               NA               NA          0.0000
## 20m01_S              NA               NA               NA              NA
## 20m02_S              NA               NA               NA          0.0000
## 20m03_S              NA               NA               NA              NA
## 20m04_S       0.0000000               NA               NA        276.3658
## 20m05_S              NA               NA               NA          0.0000
## sfm01_S       0.2654321      -0.16232311       0.79578353       3282.2906
## sfm02_S       0.3055556      -0.05854473       0.23698615       2955.4908
## sfm03_S       0.6400000      -0.38910838       0.37039620       2256.1267
## sfm04_S       0.1875000      -1.44016460       0.00000000       1746.5857
## sfm05_S       0.5306122      -1.11454978       0.27337278       1556.1084
## sfm06_S              NA               NA               NA              NA
## sfm07_S       0.2400000      -0.60858062      -3.33333333       1421.6323
## Sft01_S              NA               NA               NA          0.0000
## Sft02_S              NA               NA               NA          0.0000
##         mean.efficiency alpha.cent.wt flowing.upstream.length.m
## 01m01_S              NA            NA                        NA
## 01m02_S    1.420660e-04    16.7227749                 1026.2137
## 01m03_S    1.516910e-04    10.2898922                  621.9854
## 01m04_S    3.108460e-04     4.8215449                  238.9767
## 01m05_S    1.996630e-04     0.6931472                  122.1568
## 01m06_S    0.000000e+00     0.6931472                    0.0000
## 02m01_S    7.209370e-04    63.6024867                 2446.4219
## 02m02_S    3.995150e-04    55.8258767                 2384.1787
## 02m03_S    3.966870e-04    48.1181484                 2225.4810
## 02m04_S    3.066000e-04    40.4709846                 2094.6961
## 02m05_S    1.823850e-04    32.8980191                 1944.8995
## 02m06_S    1.512520e-04    25.4986698                 1634.9202
## 02m07_S    1.971490e-04    18.4009505                 1209.2061
## 02m08_S    1.282560e-04    11.5065545                  986.7395
## 02m09_S    8.492620e-05     5.0225801                  658.8946
## 02m10_S    1.628160e-04     0.6931472                  149.8025
## 02m11_S    0.000000e+00     0.6931472                    0.0000
## 04m01_S    4.220450e-04    71.9801783                 2987.4094
## 04m02_S    3.385270e-04    64.0275678                 2842.9871
## 04m03_S    2.688980e-04    56.1429308                 2656.1605
## 04m04_S    3.777940e-04    48.3907426                 2326.6582
## 04m05_S    2.596700e-04    40.7008567                 2186.1251
## 04m06_S    2.578370e-04    33.1406943                 1920.1574
## 04m07_S    2.602470e-04    25.7239270                 1663.6467
## 04m08_S    2.596110e-04    18.4586939                 1429.7189
## 04m09_S    1.391610e-04    11.7394190                  828.2233
## 04m10_S    1.857830e-04     5.6175714                  457.3604
## 04m11_S    8.926956e-05     0.6931472                  273.2202
## 04m12_S    0.000000e+00     0.6931472                    0.0000
## 04m13_S              NA            NA                        NA
## 04t01_S              NA            NA                        NA
## 04t02_S    0.000000e+00     0.6931472                    0.0000
## 04w01_S              NA            NA                        NA
## 04w02_S    1.496960e-04     0.6931472                  162.9315
## 04w03_S              NA            NA                        NA
## 04w04_S    0.000000e+00     0.6931472                    0.0000
## 20m01_S              NA            NA                        NA
## 20m02_S    0.000000e+00     0.6931472                    0.0000
## 20m03_S              NA            NA                        NA
## 20m04_S    8.825350e-05     0.6931472                  276.3658
## 20m05_S    0.000000e+00     0.6931472                    0.0000
## sfm01_S    9.714660e-04    88.7097372                 9141.8043
## sfm02_S    7.966020e-04    79.9823402                 6169.6472
## sfm03_S    3.602190e-04    46.1814551                 2826.7084
## sfm04_S    3.440540e-04    38.5026005                 2162.1418
## sfm05_S    3.634050e-04    30.9159671                 1971.6645
## sfm06_S              NA            NA                        NA
## sfm07_S    1.487320e-04    23.6564061                 1421.6323
## Sft01_S    0.000000e+00     0.6931472                    0.0000
## Sft02_S    0.000000e+00     0.6931472                    0.0000
##         W_Chl.a_ug_per_mL rock_area B_Chl.a_ug_per_cm2 W_AFDM B_AFDM S_AFDM
## 01m01_S          0.000000      76.2              0.160    1.8  74.39  0.032
## 01m02_S          0.000000      75.0              0.267    1.9  84.73  0.063
## 01m03_S          0.000000      73.4              0.275    1.8  83.65  0.052
## 01m04_S          0.000000      61.2              0.024    1.8  72.60  0.054
## 01m05_S          0.000000      75.0              0.029    2.1  68.11  0.043
## 01m06_S          9.624198      75.0              0.055    1.9  76.48  0.041
## 02m01_S          8.178957      75.0              0.149    2.0  68.85  0.041
## 02m02_S          0.000000      75.0              0.060    2.1  59.15  0.042
## 02m03_S          0.000000      75.0              0.065    1.6  17.97  0.044
## 02m04_S         10.687007      75.0              0.025    1.7  59.57  0.051
## 02m05_S         11.022447      75.0              0.288    0.6  16.64  0.038
## 02m06_S         15.654617      75.0              0.046    2.1  64.53  0.061
## 02m07_S        197.142577      75.0              0.259    2.0  67.20  0.045
## 02m08_S          2.891405      75.0              0.040    2.0  68.05  0.000
## 02m09_S          0.000000      75.0              0.209    1.9  63.31  0.024
## 02m10_S          0.000000      75.0              0.088    2.0  62.67  0.072
## 02m11_S         47.871840      75.0              0.066    0.6  19.63  0.045
## 04m01_S          0.000000      74.9              0.269    0.6  25.18  0.047
## 04m02_S          0.000000      36.4              0.043    0.8  53.52  0.097
## 04m03_S          9.618699      56.0              0.534    0.8  33.01  0.060
## 04m04_S          0.000000      65.9              0.911    0.9  26.10  0.067
## 04m05_S         11.487364      67.8              0.414    0.7  22.24  0.050
## 04m06_S          0.000000      71.9              1.150    0.8  38.99  0.034
## 04m07_S         40.861097      71.9              1.118    0.9  32.06  0.032
## 04m08_S        110.954030      83.0              0.691    0.9  24.75  0.043
## 04m09_S         69.102034      40.5              1.668    0.8 125.89  0.038
## 04m10_S          8.865000      33.5              0.164    0.8  64.27  0.067
## 04m11_S         19.965844      54.3              0.268    0.7  41.16  0.067
## 04m12_S        138.469097      83.6              0.179    0.9  28.06  0.116
## 04m13_S                NA      52.1              0.552    0.7  46.33  0.177
## 04t01_S                NA      57.1              0.044    0.7  27.74  0.086
## 04t02_S         16.131531      50.9              0.389    0.7  45.68  0.085
## 04w01_S                NA      75.0              0.027     NA  33.28  0.035
## 04w02_S          0.000000      56.5              0.036    0.8  38.87  0.053
## 04w03_S         29.790082      75.0              0.019    0.8  29.46  0.038
## 04w04_S          0.000000      71.2              0.021    0.8  25.21  0.073
## 20m01_S                NA      75.0              0.838    0.7  26.88  0.074
## 20m02_S        235.094272      62.5              0.087    0.7  29.38  0.072
## 20m03_S                NA      82.9              0.159    0.6  23.46  0.052
## 20m04_S         98.406280      66.4              0.734    0.6  35.64  0.063
## 20m05_S         24.120099      89.7              0.279    0.8  24.67  0.071
## sfm01_S          0.000000      86.8              0.140    0.6  21.74  0.037
## sfm02_S          0.000000      76.0              0.266    0.7  19.44  0.053
## sfm03_S          0.000000      75.0              0.064    0.7  29.01  0.078
## sfm04_S         21.026154      75.0              0.655     NA  43.71  0.028
## sfm05_S          4.068694      75.9              0.202    0.7  23.91  0.034
## sfm06_S         90.806642      94.6              0.185    0.7  19.34  0.038
## sfm07_S         18.039189      61.5              0.191    0.8  29.85  0.050
## Sft01_S          0.000000      79.0              0.314    0.8  26.89     NA
## Sft02_S          2.149028      91.0              0.428    0.7  20.80     NA
##         LL_AFDM pw_cluster wet_dist_cluster burn_freq
## 01m01_S   0.759          2                1 0.8292685
## 01m02_S   0.857          3                1 0.8292685
## 01m03_S   1.000          3                1 0.8292685
## 01m04_S   1.000          3                1 0.8292685
## 01m05_S   1.000          1                2 0.8292685
## 01m06_S   1.000          3                1 0.8292685
## 02m01_S   0.615          3                3 0.9512196
## 02m02_S   0.750          3                3 0.9512196
## 02m03_S   0.654          3                3 0.4390243
## 02m04_S   0.619          3                3 0.4390243
## 02m05_S   0.667          2                2 0.4390243
## 02m06_S   0.696          3                3 0.4390243
## 02m07_S   0.848          1                2 0.4390243
## 02m08_S   0.882          3                3 0.4390243
## 02m09_S   1.000          3                1 0.4390243
## 02m10_S   1.000          3                1 0.4390243
## 02m11_S      NA          2                2 0.4390243
## 04m01_S   0.656          2                2 0.4390243
## 04m02_S   0.444          2                2 0.4390243
## 04m03_S   0.706          3                3 0.2439024
## 04m04_S   0.480          1                2 0.2439024
## 04m05_S   0.735          1                2 0.2439024
## 04m06_S   0.800          3                3 0.2439024
## 04m07_S   0.909          3                1 0.2439024
## 04m08_S   0.500          1                2 0.2439024
## 04m09_S   1.000          3                1 0.2439024
## 04m10_S   1.000          3                1 0.2439024
## 04m11_S   1.000          3                1 0.2439024
## 04m12_S   1.000          3                1 0.2439024
## 04m13_S   0.889          3                1 0.2439024
## 04t01_S   0.302          3                1 0.2926829
## 04t02_S   1.000          3                1 0.2926829
## 04w01_S   0.962          3                3 0.4390243
## 04w02_S   1.000          3                3 0.4390243
## 04w03_S   1.000          3                3 0.4390243
## 04w04_S   1.000          3                1 0.4390243
## 20m01_S   0.952          3                1 0.1463415
## 20m02_S   1.000          3                1 0.1463415
## 20m03_S   0.905          3                1 0.1463415
## 20m04_S   1.000          3                1 0.1463415
## 20m05_S   0.917          3                1 0.1463415
## sfm01_S   0.783          2                3 0.9512196
## sfm02_S   0.833          3                3 0.2926829
## sfm03_S   0.704          3                3 0.2926829
## sfm04_S   0.788          3                3 0.2926829
## sfm05_S   0.741          2                3 0.2926829
## sfm06_S   0.526          3                3 0.1463415
## sfm07_S   0.846          3                3 0.1463415
## Sft01_S   0.655          2                2 0.2926829
## Sft02_S   1.000          3                3 0.2926829
summary(metadata_sitechars$burn_interval)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   1.051   2.278   3.417   3.296   4.100   6.833
sd(metadata_sitechars$burn_interval)
## [1] 1.759497
metasite_corr<- metadata_sitechars[,c("prc_wet","tempC_mean","elevation","distance_from_outlet","drainage_area","twi", "slope_percent","burn_interval","canopy_cover_percent", "B_Chl.a_ug_per_cm2")]
library(linkET)
metacorrplot50<- qcorrplot(correlate(x=metasite_corr[1:10], y=NULL, method = "spearman"), type = "lower", diag = FALSE, grid_size = 0.5) +
  geom_square() +
  geom_mark(sep = '\n',size=4,sig_level = c(0.05,0.01,0.001),sig_thres = 0.05,
            only_mark = TRUE)+
  #scale_fill_gradientn(colours = RColorBrewer::brewer.pal(11, "RdBu"))+
  scale_fill_gradientn(colours = RColorBrewer::brewer.pal(11, "RdYlBu"))+
  guides(fill = guide_colorbar(title = "Spearman's rho"))+
  theme(legend.key.size = unit(25,"pt"),
        axis.text = element_text(size = 18,color = "black"),
        strip.text = element_text(size = 18,color = "black"),
        plot.title=element_text(size=16),)+
  theme(legend.position = "right")+
  xlab(label="")+
  ylab(label="")+
  labs(title = "Environmental predictors (50 sites)")
metacorrplot50

metadata_sitecharsa<-metadata_sitechars[!is.na(metadata_sitechars$alpha.cent.wt),]
metasitedag_corr<- metadata_sitecharsa[,c("prc_wet","tempC_mean","elevation","distance_from_outlet","drainage_area","twi", "slope_percent","burn_interval", "canopy_cover_percent", "B_Chl.a_ug_per_cm2","W_Chl.a_ug_per_mL","alpha.cent.wt", "flowing.upstream.length.m")]

metacorrplot42<- qcorrplot(correlate(x=metasitedag_corr[1:13], y=NULL, method = "spearman"), type = "lower", diag = FALSE, grid_size = 0.5) +
  geom_square() +
  geom_mark(sep = '\n',size=4,sig_level = c(0.05,0.01,0.001),sig_thres = 0.05,
            only_mark = TRUE)+
  #scale_fill_gradientn(colours = RColorBrewer::brewer.pal(11, "RdBu"))+
  scale_fill_gradientn(colours = RColorBrewer::brewer.pal(11, "RdYlBu"))+
  guides(fill = guide_colorbar(title = "Spearman's rho"))+
  theme(legend.key.size = unit(25,"pt"),
        axis.text = element_text(size = 18,color = "black"),
        strip.text = element_text(size = 18,color = "black"),
        plot.title=element_text(size=16),)+
  theme(legend.position = "right")+
  xlab(label="")+
  ylab(label="")+
  labs(title = "Environmental predictors (42 wet StreamDAG sites)")
metacorrplot42

library(cowplot)
## 
## Attaching package: 'cowplot'
## The following object is masked from 'package:ggpubr':
## 
##     get_legend
plotout <- "envi_corrplots_03102025.tiff"
agg_tiff(filename=plotout, width=2400, height=4200, units="px",
         pointsize=10, res=600, compression="lzw", scaling=0.5)
plot_grid(metacorrplot50,metacorrplot42,labels="AUTO", ncol=1)
invisible(dev.off())




detach("package:linkET", unload=TRUE)

###Accumulation curves from unrarefied data

#library('rgdal')
#library('biosurvey')
### epilithon leaf sediment 
myColors <- c("#9ACD32","#CD853F","#B0C4DE")

pseqtestf<-pseqtest
samdftestf<-samdftest

botu<- pseqtestf@otu_table[samdftestf$substrate=='B',]
lotu<- pseqtestf@otu_table[samdftestf$substrate=='L',]
sotu<- pseqtestf@otu_table[samdftestf$substrate=='S',]
#wotu<- pseqtestf@otu_table[samdftestf$substrate=='W',]

accum_nor_B <- specaccum(botu, method="random")
accum_nor_L <- specaccum(lotu, method="random")
accum_nor_S <- specaccum(sotu, method="random")
#accum_nor_W <- specaccum(wotu, method="random")

plot(accum_nor_S, col = myColors[3])
#then plot the rest
plot(accum_nor_L, add = TRUE, col = myColors[2]) #col is COLOUR setting, so change it to something else if you want 
plot(accum_nor_B, add = TRUE, col = myColors[1])
#plot(accum_nor_W, add = TRUE, col = 4)
legend("topright",y=NULL,legend=as.factor(samdftestf$substrate),fill=NULL,col = as.factor(samdftestf$substrate))

#legend("topright",threednmds$xyz.convert(18, 0, 12), pch = 1, col = as.factor(samdftest$substrate), yjust=0, legend = as.factor(samdftest$substrate), cex = 1)

#data <- data.frame(Sites=acc$sites, Richness=acc$richness, SD=acc$sd)
dfb <-data.frame(Sites=accum_nor_B$sites, Richness=accum_nor_B$richness, SD=accum_nor_B$sd)
dfl <-data.frame(Sites=accum_nor_L$sites, Richness=accum_nor_L$richness, SD=accum_nor_L$sd)
dfs <-data.frame(Sites=accum_nor_S$sites, Richness=accum_nor_S$richness, SD=accum_nor_S$sd)
#dfw <-data.frame(Sites=accum_nor_W$sites, Richness=accum_nor_W$richness, SD=accum_nor_W$sd)


library(RColorBrewer)



#define custom color scale
#myColors <- brewer.pal(3, "Spectral")
myColors <- c("#9ACD32","#CD853F","#6495ED")
#myColors <- c("#ADFF2F","#A0522D","#FFD700")
#myColors <- c("#ADFF2F","#D2B48C"," #8B4513")
#myColors <- c("#F8766D","#7CAE00", "#00BFC4") #"#C77CFF"

              
names(myColors) <- levels(samdftestf$substrate)
custom_colors <- scale_colour_manual(name = samdftestf$substrate, values = myColors)




ASVaccumsub<- ggplot() +
  geom_point(data=dfl, colour="#CD853F", aes(x=Sites, y=Richness, )) +
geom_line(data=dfl, colour="#CD853F",aes(x=Sites, y=Richness)) +
geom_ribbon(data=dfl,aes(x=Sites,
ymin=(Richness-2*SD),ymax=(Richness+2*SD)),alpha=0.2)+

  geom_point(data=dfb, colour="#9ACD32", aes(x=Sites, y=Richness)) +
geom_line(data=dfb, colour="#9ACD32", aes(x=Sites, y=Richness)) +
geom_ribbon(data=dfb,aes(x=Sites,
ymin=(Richness-2*SD),ymax=(Richness+2*SD)),alpha=0.2)+
  
  geom_point(data=dfs, colour="#6495ED", aes(x=Sites, y=Richness)) +
geom_line(data=dfs, colour="#6495ED", aes(x=Sites, y=Richness)) +
geom_ribbon(data=dfs,aes(x=Sites,
ymin=(Richness-2*SD),ymax=(Richness+2*SD)),alpha=0.2) +
  # Color of lines and points
scale_color_discrete(name='Substrate:', labels=c('Epilithic Biofilms', 'Leaf Litter', 'Sediment'))+
  #title(main = "Fungal ASV accumulation curves by substrate")+

                        #, 'Surface #water'))+

#  geom_point(data=dfw, aes(x=Sites, y=Richness, colour='W')) +
#geom_line(data=dfw, aes(x=Sites, y=Richness,colour='W')) +
#geom_ribbon(data=dfw,aes(x=Sites,
#ymin=(Richness-2*SD),ymax=(Richness+2*SD)),alpha=0.2)+
  labs(title = "Fungal ASV accumulation curves by substrate", y="ASV Richness")+
   theme(text=element_text(size=12), #change font size of all text
        axis.text=element_text(size=12), #change font size of axis text
        axis.title=element_text(size=12), #change font size of axis titles
        plot.title=element_text(size=15), #change font size of plot title
       # legend.text=element_text(size=15),
      #  legend.title = element_text(size=15),#change font size of legend text
        strip.text.x = element_text(size = 12),
        #legend.title=element_text(size=9),
       # legend.position = "right",
        plot.margin = unit(c(1, 1, 1, 2), "lines"))  #+
  #theme(legend.position="bottom")
  #scale_fill_discrete(labels=c('High Program',
#  custom_colors
ASVaccumsub

ASVaccumsub2<- ASVaccumsub+ theme(legend.position="bottom", plot.margin = unit(c(1, 1, 2, 2), "lines"))
ASVaccumsub2

plotout <- "Fungal_ASV_accum.curve_substrate_022224.tiff"
agg_tiff(filename=plotout, width=2555, height=1464, units="px",
         pointsize=10, res=600, compression="lzw", scaling=0.5)
ASVaccumsub<- ASVaccumsub + theme(legend.position = "bottom")+ scale_color_discrete(name='Substrate:', labels=c('Epilithic Biofilms', 'Leaf Litter', 'Sediment'))
## Scale for colour is already present.
## Adding another scale for colour, which will replace the existing scale.
ASVaccumsub
invisible(dev.off())

Saved ASVaccumsub so I can combine it in a Beta Diversity figure with multiple other plots.

library(MicEco)
library(eulerr)

myColors <- c("#9ACD32","#CD853F","#6495ED")

venndiagram<- ps_venn(pseqtest,group="substrate", labels=c('Epilithon', 'Leaf litter', 'Sediment'), fill=myColors)

venndiagram

summary stats on taxa before rarefaction

tax_tib<-as.data.frame(pseqtest@tax_table@.Data)
unique_gen<-unique(tax_tib$Genus)
###number of genera
length(unique_gen)
## [1] 989
nrow(tax_tib)
## [1] 6564
unique_fam<-unique(tax_tib$Family)
#number of families
length(unique_fam)
## [1] 413
unique(tax_tib$Phylum)
##  [1] "p__Ascomycota"             "p__Basidiomycota"         
##  [3] "p__Blastocladiomycota"     "p__Mortierellomycota"     
##  [5] NA                          "p__Kickxellomycota"       
##  [7] "p__Rozellomycota"          "p__Aphelidiomycota"       
##  [9] "p__Basidiobolomycota"      "p__Mucoromycota"          
## [11] "p__Chytridiomycota"        "p__Calcarisporiellomycota"
## [13] "p__Olpidiomycota"          "p__Glomeromycota"         
## [15] "p__Neocallimastigomycota"  "p__Entorrhizomycota"
#unique(tax_tib$Class)
#unique(tax_tib$Family)

## number of ASV without genus assigned
sum(is.na(tax_tib$Genus))
## [1] 1564
### number of ASVs
nrow(tax_tib)
## [1] 6564
## proportion of ASVs without genus-level taxonomy:
sum(is.na(tax_tib$Genus))/nrow(tax_tib)
## [1] 0.2382693
### proportion of ASVs with genus-or-lower taxonomy:
1-(sum(is.na(tax_tib$Genus))/nrow(tax_tib))
## [1] 0.7617307

Rarefaction

NMDS of fungi, rarefied data rarefaction

summary(rowSums(cured_asvs))
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##     352    7706   14872   17680   25932   59985
sum(rowSums(cured_asvs))
## [1] 2545863
rowSums(cured_asvs)
## 01m01_B 01m01_L 01m01_S 01m02_B 01m02_L 01m02_S 01m03_B 01m03_L 01m03_S 01m04_B 
##    3057   14839   10080    7353   43601    2549    5324   34079   12735    6781 
## 01m04_L 01m04_S 01m05_B 01m05_L 01m05_S 01m06_B 01m06_L 01m06_S 02m01_B 02m01_L 
##   21031   11674    6414   32460    8861    3353   33616   15291     959   33392 
## 02m01_S 02m02_B 02m02_L 02m02_S 02m03_B 02m03_L 02m03_S 02m04_L 02m04_S 02m05_B 
##   28833    9469   16814   21342   31449   24657   39038   25888    7663    3399 
## 02m05_L 02m06_B 02m06_L 02m06_S 02m07_B 02m07_L 02m07_S 02m08_B 02m08_L 02m08_S 
##   44235   13430   20384   12116    7721   59985   29320     716   43176    2953 
## 02m09_B 02m09_L 02m09_S 02m10_B 02m10_L 02m10_S 02m11_B 02m11_S 04m01_B 04m01_L 
##   11247   23858    6147   17150   28241   19307   13306   13981   24438   28848 
## 04m01_S 04m02_B 04m02_L 04m02_S 04m03_B 04m03_L 04m03_S 04m04_B 04m04_L 04m04_S 
##   17104   10799   33147   19771   14551    5333   17328   14700   22412   12689 
## 04m05_B 04m05_L 04m05_S 04m06_B 04m06_L 04m06_S 04m07_L 04m07_S 04m08_B 04m08_L 
##    6675   26064    7167    3384   36404    9423   23929    3607     352   11880 
## 04m08_S 04m09_B 04m09_L 04m09_S 04m10_B 04m10_L 04m10_S 04m11_B 04m11_L 04m11_S 
##    2659    1451   18005    3124   27744    5421   24009   11575   25477   12324 
## 04m12_B 04m12_L 04m12_S 04m13_B 04m13_L 04m13_S 04t01_B 04t01_L 04t01_S 04t02_B 
##    5956   19195   18670    7849   56252   15698    8776   33402    6529   15162 
## 04t02_L 04t02_S 04w01_B 04w01_L 04w01_S 04w02_B 04w02_L 04w02_S 04w03_B 04w03_L 
##   28756   11520   16484   43197   18909    2441   32314   24453    8313   10039 
## 04w03_S 04w04_L 04w04_S 20m01_L 20m01_S 20m02_B 20m02_L 20m02_S 20m03_B 20m03_L 
##   19108   31826    3018   35696   16404    7727   23272   13105    8008   40416 
## 20m03_S 20m04_B 20m04_L 20m04_S 20m05_B 20m05_L 20m05_S sfm01_B sfm01_L sfm01_S 
##   14905    3547   44427   34406     900   26199    6383   13850   27294    7888 
## sfm02_B sfm02_L sfm02_S sfm03_B sfm03_L sfm03_S sfm04_B sfm04_L sfm04_S sfm05_B 
##    7012   31527   26776    4523   33214    1747   10658   43674   13650    7260 
## sfm05_L sfm05_S sfm06_B sfm06_L sfm06_S sfm07_B sfm07_L sfm07_S Sft01_B Sft01_L 
##   23448   10453    1095   15116   15920    7266   25794   14319   20756   28730 
## Sft01_S Sft02_B Sft02_L Sft02_S 
##   17019   11569   37060    9915
### NMDS no convergent solutions at the lower read depth. 
set.seed(2024)

### Rarefying to 2441 reads to balance sample retention and read depth
rarefied <- Rarefy(cured_asvs, 2441)

rarefied$discard
## [1] "02m01_B" "02m08_B" "04m08_B" "04m09_B" "20m05_B" "sfm03_S" "sfm06_B"
## [1] "saltob1"
rarasv<-rarefied$otu.tab.rff
rarasv<- rarasv[,colSums(rarasv)>0]

summary(rowSums(rarasv))
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    2441    2441    2441    2441    2441    2441
## look at read depths for the different substrates:
asvtab <- otu_table(rarasv, taxa_are_rows = FALSE)
taxtab <- tax_table(taxtab)

### removing sample 04w03_L, which was 1 leaf rather than 3, and sample Sft02_L, where the leaf types were missing
#asvtab <- asvtab[row.names(asvtab)!="04w03_L"|row.names(asvtab)!="Sft02_L",]
metadata<- metadata[metadata$Sample!="04w03_L",]
metadata<- metadata[metadata$Sample!="Sft02_L",]

#metadata <- sample_data(metadata_full)
#combine into phyloseq object
pseqtest <- phyloseq(asvtab, taxtab, metadata)
#extract easy-to-use sample data
samdftest <- data.frame(sample_data(pseqtest))

## Examine the read depths by substrate:
###Leaf
#summary(rowSums(pseqtest@otu_table[pseqtest@sam_data$substrate=="L",]))
count(samdftest[samdftest$substrate=="L",])
##    n
## 1 47
###Biofilm
#summary(rowSums(pseqtest@otu_table[pseqtest@sam_data$substrate=="B",]))
count(samdftest[samdftest$substrate=="B",])
##    n
## 1 40
###Sediment
#summary(rowSums(pseqtest@otu_table[pseqtest@sam_data$substrate=="S",]))
count(samdftest[samdftest$substrate=="S",])
##    n
## 1 48
unique(samdftest$Site)
##  [1] "01m01" "01m02" "01m03" "01m04" "01m05" "01m06" "02m01" "02m02" "02m03"
## [10] "02m04" "02m05" "02m06" "02m07" "02m08" "02m09" "02m10" "02m11" "04m01"
## [19] "04m02" "04m03" "04m04" "04m05" "04m06" "04m07" "04m08" "04m09" "04m10"
## [28] "04m11" "04m12" "04m13" "04t01" "04t02" "04w01" "04w02" "04w03" "04w04"
## [37] "20m01" "20m02" "20m03" "20m04" "20m05" "sfm01" "sfm02" "sfm03" "sfm04"
## [46] "sfm05" "sfm06" "sfm07" "Sft01" "Sft02"

BETA DIVERSITY

#generate distance matrices
braytest <- phyloseq::distance(pseqtest, method = "bray")
#jactest <- phyloseq::distance(pseqtest, method="jaccard", binary=TRUE)
#perform NMDS
#Bray-Curtis
braymds <- metaMDS(braytest, k=2, trymax=500, wascores = T)
## Run 0 stress 0.1891976 
## Run 1 stress 0.1909647 
## Run 2 stress 0.194675 
## Run 3 stress 0.1947434 
## Run 4 stress 0.1933821 
## Run 5 stress 0.1941827 
## Run 6 stress 0.1823702 
## ... New best solution
## ... Procrustes: rmse 0.05962884  max resid 0.3333668 
## Run 7 stress 0.1897989 
## Run 8 stress 0.1854733 
## Run 9 stress 0.1959085 
## Run 10 stress 0.192988 
## Run 11 stress 0.192998 
## Run 12 stress 0.187779 
## Run 13 stress 0.1832224 
## Run 14 stress 0.1956015 
## Run 15 stress 0.1866696 
## Run 16 stress 0.1904082 
## Run 17 stress 0.1932108 
## Run 18 stress 0.1886411 
## Run 19 stress 0.187856 
## Run 20 stress 0.1893 
## Run 21 stress 0.1899564 
## Run 22 stress 0.2034321 
## Run 23 stress 0.1892057 
## Run 24 stress 0.1862322 
## Run 25 stress 0.1891321 
## Run 26 stress 0.193693 
## Run 27 stress 0.187922 
## Run 28 stress 0.1966583 
## Run 29 stress 0.1852158 
## Run 30 stress 0.1970215 
## Run 31 stress 0.1870829 
## Run 32 stress 0.19193 
## Run 33 stress 0.1932851 
## Run 34 stress 0.1786509 
## ... New best solution
## ... Procrustes: rmse 0.02473061  max resid 0.1328608 
## Run 35 stress 0.1943987 
## Run 36 stress 0.1841554 
## Run 37 stress 0.1886268 
## Run 38 stress 0.1870192 
## Run 39 stress 0.1857629 
## Run 40 stress 0.190391 
## Run 41 stress 0.1902609 
## Run 42 stress 0.1985282 
## Run 43 stress 0.1903108 
## Run 44 stress 0.1921002 
## Run 45 stress 0.1903866 
## Run 46 stress 0.1880437 
## Run 47 stress 0.1923011 
## Run 48 stress 0.1889239 
## Run 49 stress 0.1998468 
## Run 50 stress 0.1913908 
## Run 51 stress 0.1961096 
## Run 52 stress 0.192702 
## Run 53 stress 0.1914727 
## Run 54 stress 0.1880673 
## Run 55 stress 0.1930168 
## Run 56 stress 0.1964203 
## Run 57 stress 0.188099 
## Run 58 stress 0.1927073 
## Run 59 stress 0.1991048 
## Run 60 stress 0.1933623 
## Run 61 stress 0.1872033 
## Run 62 stress 0.1877236 
## Run 63 stress 0.188185 
## Run 64 stress 0.1930705 
## Run 65 stress 0.196322 
## Run 66 stress 0.1892131 
## Run 67 stress 0.1988549 
## Run 68 stress 0.1911861 
## Run 69 stress 0.1926128 
## Run 70 stress 0.1978086 
## Run 71 stress 0.1949472 
## Run 72 stress 0.1925612 
## Run 73 stress 0.2020521 
## Run 74 stress 0.20001 
## Run 75 stress 0.1945963 
## Run 76 stress 0.1904209 
## Run 77 stress 0.2025506 
## Run 78 stress 0.1804386 
## Run 79 stress 0.1887502 
## Run 80 stress 0.189241 
## Run 81 stress 0.1964436 
## Run 82 stress 0.1913557 
## Run 83 stress 0.1903153 
## Run 84 stress 0.1889073 
## Run 85 stress 0.1833801 
## Run 86 stress 0.1936862 
## Run 87 stress 0.1822609 
## Run 88 stress 0.1940231 
## Run 89 stress 0.1822199 
## Run 90 stress 0.187969 
## Run 91 stress 0.187106 
## Run 92 stress 0.1879956 
## Run 93 stress 0.1865517 
## Run 94 stress 0.1909236 
## Run 95 stress 0.185613 
## Run 96 stress 0.1979995 
## Run 97 stress 0.1901827 
## Run 98 stress 0.1888313 
## Run 99 stress 0.2008897 
## Run 100 stress 0.1948892 
## Run 101 stress 0.1976156 
## Run 102 stress 0.1970096 
## Run 103 stress 0.1892256 
## Run 104 stress 0.1886899 
## Run 105 stress 0.1912327 
## Run 106 stress 0.1866122 
## Run 107 stress 0.2006185 
## Run 108 stress 0.1915875 
## Run 109 stress 0.1957624 
## Run 110 stress 0.1960796 
## Run 111 stress 0.1968611 
## Run 112 stress 0.1946191 
## Run 113 stress 0.1940794 
## Run 114 stress 0.1955224 
## Run 115 stress 0.191767 
## Run 116 stress 0.1878099 
## Run 117 stress 0.1913789 
## Run 118 stress 0.1899183 
## Run 119 stress 0.1906047 
## Run 120 stress 0.1945278 
## Run 121 stress 0.1844739 
## Run 122 stress 0.1884762 
## Run 123 stress 0.1836336 
## Run 124 stress 0.1888132 
## Run 125 stress 0.1880465 
## Run 126 stress 0.1893887 
## Run 127 stress 0.1877807 
## Run 128 stress 0.191328 
## Run 129 stress 0.1869569 
## Run 130 stress 0.1909365 
## Run 131 stress 0.1966191 
## Run 132 stress 0.190234 
## Run 133 stress 0.1933312 
## Run 134 stress 0.1895461 
## Run 135 stress 0.1909229 
## Run 136 stress 0.1923826 
## Run 137 stress 0.1900266 
## Run 138 stress 0.1890306 
## Run 139 stress 0.1897782 
## Run 140 stress 0.1880601 
## Run 141 stress 0.1913699 
## Run 142 stress 0.1899254 
## Run 143 stress 0.1877806 
## Run 144 stress 0.1968299 
## Run 145 stress 0.1908171 
## Run 146 stress 0.1909314 
## Run 147 stress 0.1886333 
## Run 148 stress 0.1828151 
## Run 149 stress 0.1922951 
## Run 150 stress 0.1819447 
## Run 151 stress 0.1853189 
## Run 152 stress 0.1843539 
## Run 153 stress 0.1909701 
## Run 154 stress 0.1939012 
## Run 155 stress 0.1973056 
## Run 156 stress 0.1862691 
## Run 157 stress 0.1845437 
## Run 158 stress 0.1849241 
## Run 159 stress 0.1935671 
## Run 160 stress 0.1892494 
## Run 161 stress 0.1828378 
## Run 162 stress 0.1887036 
## Run 163 stress 0.1868185 
## Run 164 stress 0.1959341 
## Run 165 stress 0.1917535 
## Run 166 stress 0.1863588 
## Run 167 stress 0.1982453 
## Run 168 stress 0.1882796 
## Run 169 stress 0.1873868 
## Run 170 stress 0.2029617 
## Run 171 stress 0.1887465 
## Run 172 stress 0.1826517 
## Run 173 stress 0.1957385 
## Run 174 stress 0.1944879 
## Run 175 stress 0.1981288 
## Run 176 stress 0.1902004 
## Run 177 stress 0.192224 
## Run 178 stress 0.1805073 
## Run 179 stress 0.1917858 
## Run 180 stress 0.1777344 
## ... New best solution
## ... Procrustes: rmse 0.01910761  max resid 0.1617494 
## Run 181 stress 0.1898878 
## Run 182 stress 0.1859507 
## Run 183 stress 0.1931142 
## Run 184 stress 0.1902316 
## Run 185 stress 0.1882324 
## Run 186 stress 0.1902599 
## Run 187 stress 0.1898895 
## Run 188 stress 0.1881876 
## Run 189 stress 0.1890749 
## Run 190 stress 0.1822972 
## Run 191 stress 0.1819856 
## Run 192 stress 0.1981679 
## Run 193 stress 0.196465 
## Run 194 stress 0.1877572 
## Run 195 stress 0.1984572 
## Run 196 stress 0.1865292 
## Run 197 stress 0.1891491 
## Run 198 stress 0.1962862 
## Run 199 stress 0.1942636 
## Run 200 stress 0.1886724 
## Run 201 stress 0.1973607 
## Run 202 stress 0.1883056 
## Run 203 stress 0.1941041 
## Run 204 stress 0.1884547 
## Run 205 stress 0.1883699 
## Run 206 stress 0.1910796 
## Run 207 stress 0.1967403 
## Run 208 stress 0.2039191 
## Run 209 stress 0.193408 
## Run 210 stress 0.1868312 
## Run 211 stress 0.1940444 
## Run 212 stress 0.1891353 
## Run 213 stress 0.2026844 
## Run 214 stress 0.1933983 
## Run 215 stress 0.1893615 
## Run 216 stress 0.1836253 
## Run 217 stress 0.1919392 
## Run 218 stress 0.1844414 
## Run 219 stress 0.1951802 
## Run 220 stress 0.1928407 
## Run 221 stress 0.1964546 
## Run 222 stress 0.1923054 
## Run 223 stress 0.2004224 
## Run 224 stress 0.1943279 
## Run 225 stress 0.1911648 
## Run 226 stress 0.1843366 
## Run 227 stress 0.1917337 
## Run 228 stress 0.1955354 
## Run 229 stress 0.1944403 
## Run 230 stress 0.1869175 
## Run 231 stress 0.1931796 
## Run 232 stress 0.2009384 
## Run 233 stress 0.1969439 
## Run 234 stress 0.197343 
## Run 235 stress 0.1872224 
## Run 236 stress 0.1882582 
## Run 237 stress 0.1888781 
## Run 238 stress 0.187506 
## Run 239 stress 0.1883125 
## Run 240 stress 0.1907056 
## Run 241 stress 0.191905 
## Run 242 stress 0.1881421 
## Run 243 stress 0.1991756 
## Run 244 stress 0.202732 
## Run 245 stress 0.1934979 
## Run 246 stress 0.1917299 
## Run 247 stress 0.1882648 
## Run 248 stress 0.1957255 
## Run 249 stress 0.1963839 
## Run 250 stress 0.1920152 
## Run 251 stress 0.1850492 
## Run 252 stress 0.1969224 
## Run 253 stress 0.196907 
## Run 254 stress 0.1934385 
## Run 255 stress 0.1861066 
## Run 256 stress 0.1867593 
## Run 257 stress 0.1881954 
## Run 258 stress 0.1861657 
## Run 259 stress 0.1875607 
## Run 260 stress 0.188101 
## Run 261 stress 0.1867631 
## Run 262 stress 0.1941762 
## Run 263 stress 0.1870254 
## Run 264 stress 0.1924627 
## Run 265 stress 0.1909871 
## Run 266 stress 0.1900517 
## Run 267 stress 0.1885799 
## Run 268 stress 0.1898127 
## Run 269 stress 0.1916223 
## Run 270 stress 0.1960152 
## Run 271 stress 0.198482 
## Run 272 stress 0.1881585 
## Run 273 stress 0.1966169 
## Run 274 stress 0.1964876 
## Run 275 stress 0.1923564 
## Run 276 stress 0.1926133 
## Run 277 stress 0.1877417 
## Run 278 stress 0.1838232 
## Run 279 stress 0.1863313 
## Run 280 stress 0.1958102 
## Run 281 stress 0.1920048 
## Run 282 stress 0.1951677 
## Run 283 stress 0.1924266 
## Run 284 stress 0.1887527 
## Run 285 stress 0.192678 
## Run 286 stress 0.1911346 
## Run 287 stress 0.1937817 
## Run 288 stress 0.1900233 
## Run 289 stress 0.1889079 
## Run 290 stress 0.1962895 
## Run 291 stress 0.1915464 
## Run 292 stress 0.1939541 
## Run 293 stress 0.1911418 
## Run 294 stress 0.1899328 
## Run 295 stress 0.1879169 
## Run 296 stress 0.1848676 
## Run 297 stress 0.182461 
## Run 298 stress 0.1956611 
## Run 299 stress 0.1804774 
## Run 300 stress 0.1797535 
## Run 301 stress 0.1929199 
## Run 302 stress 0.1952378 
## Run 303 stress 0.1896224 
## Run 304 stress 0.1995012 
## Run 305 stress 0.1942602 
## Run 306 stress 0.1957277 
## Run 307 stress 0.190621 
## Run 308 stress 0.183418 
## Run 309 stress 0.1924987 
## Run 310 stress 0.1910188 
## Run 311 stress 0.1943918 
## Run 312 stress 0.1806788 
## Run 313 stress 0.1879904 
## Run 314 stress 0.1852803 
## Run 315 stress 0.184622 
## Run 316 stress 0.1889435 
## Run 317 stress 0.1862958 
## Run 318 stress 0.1900985 
## Run 319 stress 0.1941502 
## Run 320 stress 0.1985915 
## Run 321 stress 0.1906462 
## Run 322 stress 0.1887699 
## Run 323 stress 0.1890816 
## Run 324 stress 0.1958738 
## Run 325 stress 0.1877639 
## Run 326 stress 0.1980853 
## Run 327 stress 0.1929745 
## Run 328 stress 0.1939778 
## Run 329 stress 0.1954235 
## Run 330 stress 0.1992674 
## Run 331 stress 0.1887597 
## Run 332 stress 0.1990786 
## Run 333 stress 0.1987317 
## Run 334 stress 0.1906694 
## Run 335 stress 0.1991507 
## Run 336 stress 0.1893595 
## Run 337 stress 0.1892032 
## Run 338 stress 0.1975062 
## Run 339 stress 0.1885472 
## Run 340 stress 0.1956985 
## Run 341 stress 0.194271 
## Run 342 stress 0.1871074 
## Run 343 stress 0.1909308 
## Run 344 stress 0.1885559 
## Run 345 stress 0.1969455 
## Run 346 stress 0.1868531 
## Run 347 stress 0.1900283 
## Run 348 stress 0.1878055 
## Run 349 stress 0.1994094 
## Run 350 stress 0.414389 
## Run 351 stress 0.1826817 
## Run 352 stress 0.1874826 
## Run 353 stress 0.1854206 
## Run 354 stress 0.1919361 
## Run 355 stress 0.1956489 
## Run 356 stress 0.1838852 
## Run 357 stress 0.1937114 
## Run 358 stress 0.1891868 
## Run 359 stress 0.1987877 
## Run 360 stress 0.1908862 
## Run 361 stress 0.1938105 
## Run 362 stress 0.2016536 
## Run 363 stress 0.1991799 
## Run 364 stress 0.1928752 
## Run 365 stress 0.1891844 
## Run 366 stress 0.1970695 
## Run 367 stress 0.1948097 
## Run 368 stress 0.1873856 
## Run 369 stress 0.193635 
## Run 370 stress 0.1830101 
## Run 371 stress 0.1931814 
## Run 372 stress 0.1880275 
## Run 373 stress 0.1813116 
## Run 374 stress 0.191119 
## Run 375 stress 0.2003192 
## Run 376 stress 0.1932405 
## Run 377 stress 0.1881153 
## Run 378 stress 0.1872743 
## Run 379 stress 0.1899907 
## Run 380 stress 0.1966163 
## Run 381 stress 0.181207 
## Run 382 stress 0.1882907 
## Run 383 stress 0.2003697 
## Run 384 stress 0.1887629 
## Run 385 stress 0.184336 
## Run 386 stress 0.1865058 
## Run 387 stress 0.1878444 
## Run 388 stress 0.1926212 
## Run 389 stress 0.1948657 
## Run 390 stress 0.1934716 
## Run 391 stress 0.1868215 
## Run 392 stress 0.1986473 
## Run 393 stress 0.1944373 
## Run 394 stress 0.1853206 
## Run 395 stress 0.1863847 
## Run 396 stress 0.1884371 
## Run 397 stress 0.2013491 
## Run 398 stress 0.1931913 
## Run 399 stress 0.1908774 
## Run 400 stress 0.1913025 
## Run 401 stress 0.1922105 
## Run 402 stress 0.193199 
## Run 403 stress 0.1883399 
## Run 404 stress 0.197077 
## Run 405 stress 0.1856686 
## Run 406 stress 0.1963262 
## Run 407 stress 0.1911527 
## Run 408 stress 0.188997 
## Run 409 stress 0.1996167 
## Run 410 stress 0.1925836 
## Run 411 stress 0.1867384 
## Run 412 stress 0.1893756 
## Run 413 stress 0.194179 
## Run 414 stress 0.1978553 
## Run 415 stress 0.1917992 
## Run 416 stress 0.1834055 
## Run 417 stress 0.1887553 
## Run 418 stress 0.4144019 
## Run 419 stress 0.1915043 
## Run 420 stress 0.1891586 
## Run 421 stress 0.200928 
## Run 422 stress 0.1829835 
## Run 423 stress 0.2003824 
## Run 424 stress 0.184246 
## Run 425 stress 0.1919255 
## Run 426 stress 0.1870849 
## Run 427 stress 0.196823 
## Run 428 stress 0.1937572 
## Run 429 stress 0.2022543 
## Run 430 stress 0.1887011 
## Run 431 stress 0.1842817 
## Run 432 stress 0.1950056 
## Run 433 stress 0.193364 
## Run 434 stress 0.1908061 
## Run 435 stress 0.196929 
## Run 436 stress 0.1918667 
## Run 437 stress 0.1886759 
## Run 438 stress 0.1887802 
## Run 439 stress 0.1897995 
## Run 440 stress 0.1974958 
## Run 441 stress 0.1937299 
## Run 442 stress 0.1940707 
## Run 443 stress 0.1996789 
## Run 444 stress 0.1991509 
## Run 445 stress 0.1916808 
## Run 446 stress 0.1918503 
## Run 447 stress 0.1924755 
## Run 448 stress 0.1986175 
## Run 449 stress 0.1914548 
## Run 450 stress 0.187949 
## Run 451 stress 0.191301 
## Run 452 stress 0.1913627 
## Run 453 stress 0.1840026 
## Run 454 stress 0.1855785 
## Run 455 stress 0.1962891 
## Run 456 stress 0.1962026 
## Run 457 stress 0.1887745 
## Run 458 stress 0.1907859 
## Run 459 stress 0.1899797 
## Run 460 stress 0.189778 
## Run 461 stress 0.1974119 
## Run 462 stress 0.189218 
## Run 463 stress 0.1918351 
## Run 464 stress 0.1977978 
## Run 465 stress 0.1871353 
## Run 466 stress 0.1907778 
## Run 467 stress 0.1902103 
## Run 468 stress 0.1907671 
## Run 469 stress 0.1835454 
## Run 470 stress 0.1843454 
## Run 471 stress 0.1983959 
## Run 472 stress 0.1892465 
## Run 473 stress 0.1892641 
## Run 474 stress 0.1897441 
## Run 475 stress 0.1906896 
## Run 476 stress 0.1983922 
## Run 477 stress 0.1921287 
## Run 478 stress 0.188698 
## Run 479 stress 0.1928516 
## Run 480 stress 0.1937712 
## Run 481 stress 0.194665 
## Run 482 stress 0.1915294 
## Run 483 stress 0.1935402 
## Run 484 stress 0.1941058 
## Run 485 stress 0.1929196 
## Run 486 stress 0.1909367 
## Run 487 stress 0.2025344 
## Run 488 stress 0.1934206 
## Run 489 stress 0.1892748 
## Run 490 stress 0.1968336 
## Run 491 stress 0.1858169 
## Run 492 stress 0.1950756 
## Run 493 stress 0.1950358 
## Run 494 stress 0.1877189 
## Run 495 stress 0.191614 
## Run 496 stress 0.195286 
## Run 497 stress 0.1939566 
## Run 498 stress 0.1932685 
## Run 499 stress 0.1904055 
## Run 500 stress 0.1981087 
## *** Best solution was not repeated -- monoMDS stopping criteria:
##     62: no. of iterations >= maxit
##    430: stress ratio > sratmax
##      8: scale factor of the gradient < sfgrmin
## Warning in metaMDS(braytest, k = 2, trymax = 500, wascores = T): stress is
## (nearly) zero: you may have insufficient data
brayscores <- scores(braymds)
#Jaccard
#jacmds <- metaMDS(jactest, k=3, trymax=500, wascores = T)
#jacscores <- scores(jacmds)
braymds
## 
## Call:
## metaMDS(comm = braytest, k = 2, trymax = 500, wascores = T) 
## 
## global Multidimensional Scaling using monoMDS
## 
## Data:     braytest 
## Distance: bray 
## 
## Dimensions: 2 
## Stress:     0.1777344 
## Stress type 1, weak ties
## Best solution was not repeated after 500 tries
## The best solution was from try 180 (random start)
## Scaling: centring, PC rotation, halfchange scaling 
## Species: scores missing
#jacmds
stressplot(braymds)

#stressplot(jacmds)

factorfit(brayscores, samdftest$substrate, permutations = 999)
## Centroids:
##      NMDS1   NMDS2
## PB  0.0693 -0.0640
## PL  0.6033 -0.0651
## PS -0.6484  0.1171
## 
## Goodness of fit:
##      r2 Pr(>r)    
## P 0.495  0.001 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## Permutation: free
## Number of permutations: 999
factorfit(brayscores, samdftest$flow_state, strata = samdftest$substrate, permutations = 999)
## Centroids:
##            NMDS1   NMDS2
## Pdry      0.2113  0.0924
## Pflowing -0.0249 -0.0116
## Ppool    -0.0065  0.0235
## 
## Goodness of fit:
##       r2 Pr(>r)
## P 0.0107  0.232
## Blocks:  strata 
## Permutation: free
## Number of permutations: 999
factorfit(brayscores, samdftest$pw_cluster, strata = samdftest$substrate, permutations = 999)
## Centroids:
##      NMDS1   NMDS2
## P1 -0.1436 -0.1575
## P2 -0.0353 -0.0043
## P3  0.0282  0.0232
## 
## Goodness of fit:
##       r2 Pr(>r)
## P 0.0102   0.26
## Blocks:  strata 
## Permutation: free
## Number of permutations: 999
myColors <- c("#9ACD32","#CD853F","#6495ED")

nmdsp3 <- plot_ordination(pseqtest, braymds, type="samples", color="substrate", shape="flow_state")+
  geom_point(size=2)+scale_colour_manual(values=myColors)
nmdsp3

nmds2plus<- plot_ordination(pseqtest, braymds, type="samples")
nmds2plus$layers<-nmds2plus$layers[-1]
nmds2plus<-nmds2plus+
  geom_point(size=2, aes(shape=flow_state, color=substrate))+
  scale_colour_manual(values=myColors, name='Substrate:', labels=c('Epilithon', 'Leaf litter', 'Sediment'))+
  #scale_color_discrete(name='Substrate:', labels=c('Epilithic biofilms', 'Leaf litter', 'Benthic sediment'))+
  scale_shape_discrete(name='Flow state:')+
  stat_ellipse(
    #inherit.aes = FALSE, 
               aes(x=brayscores[,1],y=brayscores[,2],color=samdftest$substrate 
 #                                       ,linetype=(samdftest$flow_state)
                                        ))+
  labs(title = "Bray-Curtis NMDS of fungal ASVs by substrate")+
  annotate("text", x = -1.1, y = -1.4, label = sprintf("k=2, Stress=%.4f",braymds$stress), size=3.5)+
 # theme(legend.text = element_text(size=10))+
    theme(text=element_text(size=8), #change font size of all text
        axis.text=element_text(size=10), #change font size of axis text
        axis.title=element_text(size=10), #change font size of axis titles
        plot.title=element_text(size=12), #change font size of plot title
        legend.text=element_text(size=10), #change font size of legend text
        strip.text.x = element_text(size = 10),
        #legend.title=element_text(size=9),
        legend.position = "none",
        plot.margin = unit(c(1, 1, 1, 2), "lines"))      #+
  # guides(color = myColors) #+scale_colour_manual(values=myColors)

nmds2plus

### now with legend, for publishing
nmds2plusleg<-nmds2plus+
  geom_point(size=2, aes(shape=flow_state, color=substrate))+
  scale_colour_manual(values=myColors, name='Substrate:', labels=c('Epilithon', 'Leaf litter', 'Sediment'))+
  #scale_color_discrete(name='Substrate:', labels=c('Epilithic biofilms', 'Leaf litter', 'Benthic sediment'))+
  scale_shape_discrete(name='Flow state:')+
  stat_ellipse(
    #inherit.aes = FALSE, 
               aes(x=brayscores[,1],y=brayscores[,2],color=samdftest$substrate 
 #                                       ,linetype=(samdftest$flow_state)
                                        ))+
  labs(title = "Bray-Curtis NMDS of fungal ASVs by substrate")+
  annotate("text", x = -1.1, y = -1.4, label = sprintf("k=2, Stress=%.4f",braymds$stress), size=3.5)+
 # theme(legend.text = element_text(size=10))+
    theme(text=element_text(size=12), #change font size of all text
        axis.text=element_text(size=12), #change font size of axis text
        axis.title=element_text(size=12), #change font size of axis titles
        plot.title=element_text(size=15), #change font size of plot title
        legend.text=element_text(size=15),
        legend.title = element_text(size=15),#change font size of legend text
        strip.text.x = element_text(size = 12),
        #legend.title=element_text(size=9),
        legend.position = "right",
        plot.margin = unit(c(1, 1, 1, 2), "lines"))      #+
## Scale for colour is already present.
## Adding another scale for colour, which will replace the existing scale.
## Scale for shape is already present.
## Adding another scale for shape, which will replace the existing scale.
  # guides(color = myColors) #+scale_colour_manual(values=myColors)
nmds2plusleg

Combined beta-diversity plot:

ASVaccumsub nmds2plus venndiagram

library(cowplot)

### Golden ratio: 1.618:1, to scale the figures.

ASVaccumsub<- ASVaccumsub+ ggtitle("")  #theme(plot.title = NULL)#element_text(size=11))

bottom<- plot_grid(ASVaccumsub,venndiagram,#dbRDA_B,dbRDAL,dbRDA_S, 
          labels=c('B','C'), ncol=2, rel_widths = c(1.618,1))
bottom

plotout <- "Beta_threeway_03.15.2025.tiff"
agg_tiff(filename=plotout, width=2200, height=2500, units="px",
         pointsize=10, res=600, compression="lzw", scaling=0.5)
plot_grid(nmds2plusleg,bottom,
          labels=c('A','',''), ncol=1, rel_heights = c(1.618,1))
invisible(dev.off())

Table of PERMANOVA results

### ANOSIM for effects of substrate ## cut, redundant with PERMANOVA
#anosim(braytest, samdftest$substrate, permutations = 99999)

### PERMANOVA for substarte effects
adonis2(braytest ~ substrate, data = samdftest, permutations = 99999, by="terms")
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 99999
## 
## adonis2(formula = braytest ~ substrate, data = samdftest, permutations = 99999, by = "terms")
##            Df SumOfSqs      R2      F Pr(>F)    
## substrate   2    6.300 0.13147 9.9903  1e-05 ***
## Residual  132   41.618 0.86853                  
## Total     134   47.918 1.00000                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
### testing for differences in dispersion between substrates
bds<- betadisper(braytest, samdftest$substrate)
anova(bds)
## Analysis of Variance Table
## 
## Response: Distances
##            Df  Sum Sq   Mean Sq F value Pr(>F)
## Groups      2 0.00886 0.0044275  0.8442 0.4322
## Residuals 132 0.69230 0.0052447
### no significant differences in dispersion between substrates.

### dispersion test for substrate
bds<- betadisper(braytest, samdftest$substrate)

permutest(bds)
## 
## Permutation test for homogeneity of multivariate dispersions
## Permutation: free
## Number of permutations: 999
## 
## Response: Distances
##            Df  Sum Sq   Mean Sq      F N.Perm Pr(>F)
## Groups      2 0.00886 0.0044275 0.8442    999  0.433
## Residuals 132 0.69230 0.0052447
plot(bds)

boxplot(bds)

mod.HSD<- TukeyHSD(bds)
mod.HSD
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = distances ~ group, data = df)
## 
## $group
##            diff         lwr        upr     p adj
## L-B 0.003254524 -0.03367464 0.04018369 0.9762330
## S-B 0.018457369 -0.01829450 0.05520924 0.4609375
## S-L 0.015202846 -0.02002459 0.05043028 0.5637110
plot(mod.HSD)

PERMANOVA for all samples

samdftest$lndrainage_area<- log(samdftest$drainage_area)

## annual flow permanence
adonis2(braytest ~ prc_wet, strata=samdftest$substrate, data = samdftest,  permutations = 9999, by="terms")
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Blocks:  strata 
## Permutation: free
## Number of permutations: 9999
## 
## adonis2(formula = braytest ~ prc_wet, data = samdftest, permutations = 9999, by = "terms", strata = samdftest$substrate)
##           Df SumOfSqs      R2      F Pr(>F)   
## prc_wet    1    0.483 0.01008 1.3542 0.0045 **
## Residual 133   47.435 0.98992                 
## Total    134   47.918 1.00000                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
adonis2(braytest ~ lndrainage_area*prc_wet, strata=samdftest$substrate, data = samdftest,  permutations = 9999, by="terms")
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Blocks:  strata 
## Permutation: free
## Number of permutations: 9999
## 
## adonis2(formula = braytest ~ lndrainage_area * prc_wet, data = samdftest, permutations = 9999, by = "terms", strata = samdftest$substrate)
##                          Df SumOfSqs      R2      F Pr(>F)    
## lndrainage_area           1    0.589 0.01229 1.6561 0.0006 ***
## prc_wet                   1    0.447 0.00932 1.2557 0.0115 *  
## lndrainage_area:prc_wet   1    0.289 0.00604 0.8133 0.6851    
## Residual                131   46.593 0.97235                  
## Total                   134   47.918 1.00000                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#################################
#adonis2(braytest ~ lndrainage_area+burn_interval+prc_wet+tempC_mean
#        , strata=samdftest$substrate, data = samdftest,  permutations = 9999, by="terms")
##########

### Multi-factor PERMANOVA for all samples 
## bray~ drainage:annual percent wet + burn interval
adonis2(braytest ~ lndrainage_area*prc_wet+burn_interval#+tempC_mean
        , strata=samdftest$substrate, data = samdftest,  permutations = 99999, by="terms")
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Blocks:  strata 
## Permutation: free
## Number of permutations: 99999
## 
## adonis2(formula = braytest ~ lndrainage_area * prc_wet + burn_interval, data = samdftest, permutations = 99999, by = "terms", strata = samdftest$substrate)
##                          Df SumOfSqs      R2      F  Pr(>F)    
## lndrainage_area           1    0.589 0.01229 1.6620 0.00054 ***
## prc_wet                   1    0.447 0.00932 1.2602 0.01081 *  
## burn_interval             1    0.519 0.01084 1.4656 0.00080 ***
## lndrainage_area:prc_wet   1    0.289 0.00604 0.8167 0.67279    
## Residual                130   46.073 0.96151                   
## Total                   134   47.918 1.00000                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
################################

PERMANOVA for StreamDAG/Wet sites

####streamDAG measures on beta diversity
#packageVersion("streamDAG")
pseq_DAG<- subset_samples(pseqtest, !is.na(alpha.cent))
sam_DAG<- data.frame(sample_data(pseq_DAG))
table(sam_DAG$substrate)
## 
##  B  L  S 
## 34 40 40
bray_DAG <- phyloseq::distance(pseq_DAG, method = "bray")
##stream temp the week before
adonis2(bray_DAG ~ alpha.cent, data = sam_DAG, strata=sam_DAG$substrate)
## Permutation test for adonis under reduced model
## Blocks:  strata 
## Permutation: free
## Number of permutations: 999
## 
## adonis2(formula = bray_DAG ~ alpha.cent, data = sam_DAG, strata = sam_DAG$substrate)
##           Df SumOfSqs      R2      F Pr(>F)
## Model      1    0.272 0.00676 0.7621  0.765
## Residual 112   39.986 0.99324              
## Total    113   40.259 1.00000
adonis2(bray_DAG ~ alpha.cent.wt, data = sam_DAG, strata=sam_DAG$substrate,  permutations = 9999)
## Permutation test for adonis under reduced model
## Blocks:  strata 
## Permutation: free
## Number of permutations: 9999
## 
## adonis2(formula = bray_DAG ~ alpha.cent.wt, data = sam_DAG, permutations = 9999, strata = sam_DAG$substrate)
##           Df SumOfSqs      R2      F Pr(>F)   
## Model      1    0.475 0.01181 1.3381 0.0093 **
## Residual 112   39.783 0.98819                 
## Total    113   40.259 1.00000                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#adonis2(bray_DAG ~ alpha.cent.wt+burn_interval+prc_wet+tempC_mean, data = sam_DAG, strata=sam_DAG$substrate,  permutations = 9999, by="terms")

adonis2(bray_DAG ~ alpha.cent.wt*prc_wet+burn_interval, data = sam_DAG, strata=sam_DAG$substrate,  permutations = 99999, by="terms")
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Blocks:  strata 
## Permutation: free
## Number of permutations: 99999
## 
## adonis2(formula = bray_DAG ~ alpha.cent.wt * prc_wet + burn_interval, data = sam_DAG, permutations = 99999, by = "terms", strata = sam_DAG$substrate)
##                        Df SumOfSqs      R2      F  Pr(>F)   
## alpha.cent.wt           1    0.475 0.01181 1.3450 0.00817 **
## prc_wet                 1    0.420 0.01043 1.1883 0.02887 * 
## burn_interval           1    0.487 0.01209 1.3775 0.00455 **
## alpha.cent.wt:prc_wet   1    0.356 0.00884 1.0073 0.16258   
## Residual              109   38.520 0.95683                  
## Total                 113   40.259 1.00000                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

PERMANOVA for Leaf Type effects in leaf samples

# subsetting for leaf sampels only
pseqL<- subset_samples(pseqtest, substrate=='L')
samL<- data.frame(sample_data(pseqL))
table(samL$substrate)
## 
##  L 
## 47
bray_L <- phyloseq::distance(pseqL, method = "bray")


adonis2(bray_L ~ Oak, data = samL,  permutations = 9999, by="terms")
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 9999
## 
## adonis2(formula = bray_L ~ Oak, data = samL, permutations = 9999, by = "terms")
##          Df SumOfSqs      R2      F Pr(>F)  
## Oak       1   0.4538 0.03197 1.4862 0.0161 *
## Residual 45  13.7418 0.96803                
## Total    46  14.1957 1.00000                
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
adonis2(bray_L ~ Elm, data = samL,  permutations = 9999, by="terms")
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 9999
## 
## adonis2(formula = bray_L ~ Elm, data = samL, permutations = 9999, by = "terms")
##          Df SumOfSqs      R2      F Pr(>F)  
## Elm       1   0.4416 0.03111 1.4449 0.0236 *
## Residual 45  13.7540 0.96889                
## Total    46  14.1957 1.00000                
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
adonis2(bray_L ~ Populus, data = samL,  permutations = 9999, by="terms")
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 9999
## 
## adonis2(formula = bray_L ~ Populus, data = samL, permutations = 9999, by = "terms")
##          Df SumOfSqs      R2      F Pr(>F)  
## Populus   1   0.4617 0.03252 1.5127 0.0121 *
## Residual 45  13.7340 0.96748                
## Total    46  14.1957 1.00000                
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
adonis2(bray_L ~ Graminales, data = samL,  permutations = 9999, by="terms")
## Permutation test for adonis under reduced model
## Terms added sequentially (first to last)
## Permutation: free
## Number of permutations: 9999
## 
## adonis2(formula = bray_L ~ Graminales, data = samL, permutations = 9999, by = "terms")
##            Df SumOfSqs      R2      F Pr(>F)  
## Graminales  1   0.4363 0.03073 1.4269 0.0295 *
## Residual   45  13.7594 0.96927                
## Total      46  14.1957 1.00000                
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
otherleaf<- samL
otherleaf$Other_leaf <- ifelse(otherleaf$Locust == "1" | otherleaf$Rubrus == "1" | otherleaf$Elderberry == "1" | otherleaf$Forb == "1" | otherleaf$Shrub == "1" , 1, 0)

adonis2(bray_L ~ Other_leaf, data = otherleaf)
## Permutation test for adonis under reduced model
## Permutation: free
## Number of permutations: 999
## 
## adonis2(formula = bray_L ~ Other_leaf, data = otherleaf)
##          Df SumOfSqs      R2     F Pr(>F)
## Model     1   0.3519 0.02479 1.144  0.209
## Residual 45  13.8437 0.97521             
## Total    46  14.1957 1.00000

ALPHA DIVERSITY

Documentation for estimate_richness advises you do not rarefy data beforehand, so I am testing on the beta pseqtest version.

#setwd("/Users/chunk/Documents/DADA2/DADA2_package_test/Kz_Syn_ITS/run_2/outputs")
#calculate alpha diversity
#write.csv(samdftest, "/Users/chunk/Documents/DADA2/DADA2_package_test/Kz_Syn_ITS/run_2/outputs/metadata.csv" )
#metadata <- read.csv("~/Documents/DADA2/DADA2_package_test/Kz_Syn_ITS/metadata.csv", stringsAsFactors=TRUE)

#pseqtest <- pseqtestBetac
#samdftest <- samdftestBetac


alpha <- estimate_richness(pseqtest, split=TRUE, measures=NULL)
#write.csv(alpha, "alpha diversity temp.csv")
#alpha2 <- read.csv("~/Documents/DADA2/DADA2_package_test/Kz_Syn_ITS/alpha diversity.csv", stringsAsFactors=TRUE)

#alpha's row names got messed up, but order is conserved, so set row.names to samdftest
row.names(alpha)<- row.names(samdftest)

alpha <- merge(samdftest, alpha, by= 'row.names', all=TRUE)
row.names(alpha) <- alpha$Row.names 
#alpha 
#write.csv(alpha, "alpharar diversity_fungi_040723.csv")

pseq_richplot<- plot_richness(pseqtest, x = "substrate", color = "substrate", measures = c("Observed","Shannon"))+ geom_boxplot()
pseq_richplot

Playing with wet/dry effects

alpha$substrate<- as.factor(alpha$substrate)
alpha$flow_state<- as.factor(alpha$flow_state)
alpha$wet_dry<- as.factor(alpha$wet_dry)
#Set theme for upcoming figures
theme_set(theme_bw() + theme(
              plot.title = element_text(size=16, color="black"),#,
              axis.text.x = element_text(size=12, color="black"),
              axis.text.y = element_text(size=12, color="black"),
              axis.title.x = element_text(size=14),
              axis.title.y = element_text(size=14)#,
              #legend.text = element_text(size=10),
              #legend.title = element_text(size=10),
            #  legend.position = "bottom",
            #  legend.key=element_blank(),
            #  legend.key.size = unit(0.5, "cm"),
            #  legend.spacing.x = unit(0.1, "cm"),
            #  legend.spacing.y = unit(0.1, "cm"),
              #panel.background = element_blank(), 
              #panel.border = element_rect(colour = "black", fill=NA, size=1),
              #plot.background = element_blank()))
              ))
alpha$flow_state<- as.factor(alpha$flow_state)
sublablist<- c('B'='Epilithic biofilms', 'L'='Leaf litter', 'S'='Benthic sediment')
sub_labeller <- function(variable,value){
  return(sublablist[value])
}
library(ggpattern) 
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ forcats   1.0.0     ✔ readr     2.1.5
## ✔ lubridate 1.9.3     ✔ stringr   1.5.1
## ✔ purrr     1.0.2     ✔ tibble    3.2.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter()    masks stats::filter()
## ✖ dplyr::lag()       masks stats::lag()
## ✖ lubridate::stamp() masks cowplot::stamp()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(ggpubr)
library(rstatix)
## 
## Attaching package: 'rstatix'
## 
## The following object is masked from 'package:stats':
## 
##     filter
stat.test <- alpha %>%
wilcox_test(Observed~substrate) %>%
  adjust_pvalue(method = "bonferroni") %>%
  add_significance()
stat.test
## # A tibble: 3 × 9
##   .y.      group1 group2    n1    n2 statistic     p p.adj p.adj.signif
##   <chr>    <chr>  <chr>  <int> <int>     <dbl> <dbl> <dbl> <chr>       
## 1 Observed B      L         40    47       759 0.124 0.372 ns          
## 2 Observed B      S         40    48       569 0.001 0.003 **          
## 3 Observed L      S         47    48       728 0.003 0.009 **
effsize <- alpha %>%
  wilcox_effsize(Observed~substrate)
effsize
## # A tibble: 3 × 7
##   .y.      group1 group2 effsize    n1    n2 magnitude
## * <chr>    <chr>  <chr>    <dbl> <int> <int> <ord>    
## 1 Observed B      L        0.165    40    47 small    
## 2 Observed B      S        0.349    40    48 moderate 
## 3 Observed L      S        0.305    47    48 moderate
subalpha_rich <- ggplot(alpha, aes(x=substrate, y=Observed)) +
  geom_boxplot()+
  scale_x_discrete(labels = c('Epilithon','Leaf litter','Sediment'))+
  ylab("ASV Richness")+
  ylim(0,600)+
   geom_signif(comparisons = list(c("L","S")),y_position = 500,
              map_signif_level=TRUE)+
     geom_signif(comparisons = list(c("B","S")),y_position = 540,
            map_signif_level=TRUE)+
       geom_signif(comparisons = list(c("B","L")),y_position = 460,
            map_signif_level=TRUE)+
  theme(legend.position='none',axis.text.x = element_text(size=16), axis.title.x = element_blank(),strip.text.x = element_text(size = 16), plot.title = element_text(size=20, color="black"),
              axis.text.y = element_text(size=16, color="black"),
              axis.title.y = element_text(size=16))+
  theme(plot.margin = unit(c(2, 2, 2, 2), "lines")) 
subalpha_rich
## Warning in wilcox.test.default(c(210, 195, 187, 216, 292, 210, 294, 262, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(101, 224, 219, 72, 203, 107, 149, 210, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(101, 224, 219, 72, 203, 107, 149, 210, :
## cannot compute exact p-value with ties

###############

##################################################
stat.test <- alpha %>%
wilcox_test(Shannon ~substrate) %>%
 adjust_pvalue(method = "bonferroni") %>%
  add_significance()
stat.test
## # A tibble: 3 × 9
##   .y.     group1 group2    n1    n2 statistic            p    p.adj p.adj.signif
##   <chr>   <chr>  <chr>  <int> <int>     <dbl>        <dbl>    <dbl> <chr>       
## 1 Shannon B      L         40    47      1225 0.015         4.5 e-2 *           
## 2 Shannon B      S         40    48       578 0.001         3   e-3 **          
## 3 Shannon L      S         47    48       416 0.0000000282  8.46e-8 ****
effsize <- alpha %>%
  wilcox_effsize(Shannon~substrate)
effsize
## # A tibble: 3 × 7
##   .y.     group1 group2 effsize    n1    n2 magnitude
## * <chr>   <chr>  <chr>    <dbl> <int> <int> <ord>    
## 1 Shannon B      L        0.260    40    47 small    
## 2 Shannon B      S        0.341    40    48 moderate 
## 3 Shannon L      S        0.544    47    48 large
subalpha_shan <- ggplot(alpha, aes(x=substrate, y=Shannon)) +
  geom_boxplot()+
  scale_x_discrete(labels = c('Epilithon','Leaf litter','Sediment'))+
  ylab("Shannon Diversity Index")+
  ylim(0,6.5)+
   geom_signif(comparisons = list(c("L","S")),y_position = 5.7,
              map_signif_level=TRUE)+
     geom_signif(comparisons = list(c("B","S")),y_position = 6.2,
            map_signif_level=TRUE)+
       geom_signif(comparisons = list(c("B","L")),y_position = 5.4,
            map_signif_level=TRUE)+
  theme(legend.position='none',axis.text.x = element_text(size=16), axis.title.x = element_blank(),strip.text.x = element_text(size = 16), plot.title = element_text(size=20, color="black"),
              axis.text.y = element_text(size=16, color="black"),
              axis.title.y = element_text(size=16))+
  theme(plot.margin = unit(c(2, 2, 2, 2), "lines")) 
subalpha_shan

###############

library(cowplot)
plotout <- "Alpha-2-panel_03-14-2025.tiff"
agg_tiff(filename=plotout, width=1800, height=2800, units="px",
         pointsize=10, res=600, compression="lzw", scaling=0.5)
plot_grid(subalpha_rich, subalpha_shan, labels="AUTO",label_size = 18, ncol = 1)
## Warning in wilcox.test.default(c(210, 195, 187, 216, 292, 210, 294, 262, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(101, 224, 219, 72, 203, 107, 149, 210, :
## cannot compute exact p-value with ties
## Warning in wilcox.test.default(c(101, 224, 219, 72, 203, 107, 149, 210, :
## cannot compute exact p-value with ties
invisible(dev.off())

Generalized linear models for alpha diversity

### checkinig for normality of response variables (required for gaussian)
# Shapiro-Wilk test for normality
shapiro_test <- alpha %>%
  group_by(substrate) %>%
  summarize(p_value = shapiro.test(Observed)$p.value)
shapiro_test
## # A tibble: 3 × 2
##   substrate p_value
##   <fct>       <dbl>
## 1 B           0.321
## 2 L           0.898
## 3 S           0.296
# Shapiro-Wilk test for normality
shapiro_test <- alpha %>%
  group_by(substrate) %>%
  summarize(p_value = shapiro.test(Shannon)$p.value)
shapiro_test
## # A tibble: 3 × 2
##   substrate  p_value
##   <fct>        <dbl>
## 1 B         0.271   
## 2 L         0.0456  
## 3 S         0.000265

So, for ASV richness, we can use a Gaussian (normal) distribution, while Shannon is non-normal and would would better with Gamma (skewed withh all positive values).

GLMs for ASV richness

### Now, we should log-transform drainage area for this, since:
summary(alpha$drainage_area)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.253   6.621  16.317  23.725  28.096 132.687
summary(log(alpha$drainage_area))
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##  0.8121  1.8903  2.7922  2.6852  3.3356  4.8880
## Log-transforming drainage_area
alpha$lndrainage_area<- log(alpha$drainage_area)

### Richness is normal but shannon diversity is non-normal
##################### Richness ############################
####### leaf

##### BEST FIT FOR LEAF LITTER RICHNESS ###################
glmoL<- glm(Observed ~ lndrainage_area, family = gaussian, data=alpha, subset = substrate=='L')
summary(glmoL) ##### AIC: 516.67 LOWEST FOR Leaf RICHNESS
## 
## Call:
## glm(formula = Observed ~ lndrainage_area, family = gaussian, 
##     data = alpha, subset = substrate == "L")
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      157.545     24.842   6.342 9.69e-08 ***
## lndrainage_area   26.904      8.528   3.155  0.00286 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 3200.049)
## 
##     Null deviance: 175854  on 46  degrees of freedom
## Residual deviance: 144002  on 45  degrees of freedom
## AIC: 516.67
## 
## Number of Fisher Scoring iterations: 2
###########################################################

glmoL<- glm(Observed ~ lndrainage_area+prc_wet, family = gaussian, data=alpha, subset = substrate=='L')
summary(glmoL) ###### AIC: 517.49
## 
## Call:
## glm(formula = Observed ~ lndrainage_area + prc_wet, family = gaussian, 
##     data = alpha, subset = substrate == "L")
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      153.914     25.045   6.145 2.06e-07 ***
## lndrainage_area   24.924      8.719   2.858  0.00648 ** 
## prc_wet           33.383     31.562   1.058  0.29596    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 3191.628)
## 
##     Null deviance: 175854  on 46  degrees of freedom
## Residual deviance: 140432  on 44  degrees of freedom
## AIC: 517.49
## 
## Number of Fisher Scoring iterations: 2
glmoL<- glm(Observed ~ lndrainage_area*prc_wet, family = gaussian, data=alpha, subset = substrate=='L')
summary(glmoL) ##### AIC: 517.95
## 
## Call:
## glm(formula = Observed ~ lndrainage_area * prc_wet, family = gaussian, 
##     data = alpha, subset = substrate == "L")
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)   
## (Intercept)               118.24      38.82   3.046  0.00396 **
## lndrainage_area            38.14      14.03   2.718  0.00942 **
## prc_wet                   220.79     159.48   1.384  0.17337   
## lndrainage_area:prc_wet   -64.27      53.62  -1.199  0.23726   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 3160.272)
## 
##     Null deviance: 175854  on 46  degrees of freedom
## Residual deviance: 135892  on 43  degrees of freedom
## AIC: 517.95
## 
## Number of Fisher Scoring iterations: 2
glmoL<- glm(Observed ~ lndrainage_area+prc_wet+burn_interval, family = gaussian, data=alpha, subset = substrate=='L')
summary(glmoL) ##### AIC: 518.06
## 
## Call:
## glm(formula = Observed ~ lndrainage_area + prc_wet + burn_interval, 
##     family = gaussian, data = alpha, subset = substrate == "L")
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      131.965     31.408   4.202 0.000131 ***
## lndrainage_area   25.944      8.733   2.971 0.004844 ** 
## prc_wet           37.766     31.676   1.192 0.239705    
## burn_interval      5.381      4.676   1.151 0.256183    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 3168.277)
## 
##     Null deviance: 175854  on 46  degrees of freedom
## Residual deviance: 136236  on 43  degrees of freedom
## AIC: 518.06
## 
## Number of Fisher Scoring iterations: 2
glmoL<- glm(Observed ~ lndrainage_area+prc_wet+burn_interval+tempC_mean, family = gaussian, data=alpha, subset = substrate=='L')
summary(glmoL) #### AIC: 520.04
## 
## Call:
## glm(formula = Observed ~ lndrainage_area + prc_wet + burn_interval + 
##     tempC_mean, family = gaussian, data = alpha, subset = substrate == 
##     "L")
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)   
## (Intercept)     135.4836    41.2379   3.285  0.00206 **
## lndrainage_area  25.9820     8.8387   2.940  0.00532 **
## prc_wet          37.8393    32.0491   1.181  0.24438   
## burn_interval     5.5063     4.8222   1.142  0.25997   
## tempC_mean       -0.2823     2.1086  -0.134  0.89415   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 3242.329)
## 
##     Null deviance: 175854  on 46  degrees of freedom
## Residual deviance: 136178  on 42  degrees of freedom
## AIC: 520.04
## 
## Number of Fisher Scoring iterations: 2
glmoL<- glm(Observed ~ lndrainage_area*prc_wet+tempC_mean, family = gaussian, data=alpha, subset = substrate=='L')
summary(glmoL) #### AIC: 519.95
## 
## Call:
## glm(formula = Observed ~ lndrainage_area * prc_wet + tempC_mean, 
##     family = gaussian, data = alpha, subset = substrate == "L")
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)  
## (Intercept)             118.06017   47.92236   2.464   0.0179 *
## lndrainage_area          38.13087   14.22277   2.681   0.0104 *
## prc_wet                 220.71838  161.74127   1.365   0.1796  
## tempC_mean                0.01336    2.07137   0.006   0.9949  
## lndrainage_area:prc_wet -64.24119   54.38894  -1.181   0.2442  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 3235.514)
## 
##     Null deviance: 175854  on 46  degrees of freedom
## Residual deviance: 135892  on 42  degrees of freedom
## AIC: 519.95
## 
## Number of Fisher Scoring iterations: 2
glmoL<- glm(Observed ~ lndrainage_area*prc_wet+burn_interval, family = gaussian, data=alpha, subset = substrate=='L')
summary(glmoL) #### AIC: 518.67
## 
## Call:
## glm(formula = Observed ~ lndrainage_area * prc_wet + burn_interval, 
##     family = gaussian, data = alpha, subset = substrate == "L")
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)   
## (Intercept)               99.865     42.342   2.359   0.0231 * 
## lndrainage_area           38.296     14.004   2.735   0.0091 **
## prc_wet                  213.629    159.326   1.341   0.1872   
## burn_interval              5.029      4.672   1.077   0.2878   
## lndrainage_area:prc_wet  -60.406     53.640  -1.126   0.2665   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 3148.64)
## 
##     Null deviance: 175854  on 46  degrees of freedom
## Residual deviance: 132243  on 42  degrees of freedom
## AIC: 518.67
## 
## Number of Fisher Scoring iterations: 2
#########################################################
####### bioifilm
glmoB<- glm(Observed ~ lndrainage_area, family = gaussian, data=alpha, subset = substrate=='B')
summary(glmoB) ###AIC: 485.76
## 
## Call:
## glm(formula = Observed ~ lndrainage_area, family = gaussian, 
##     data = alpha, subset = substrate == "B")
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)  
## (Intercept)       114.14      43.34   2.634   0.0121 *
## lndrainage_area    34.65      15.04   2.303   0.0268 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 9971.903)
## 
##     Null deviance: 431830  on 39  degrees of freedom
## Residual deviance: 378932  on 38  degrees of freedom
## AIC: 485.76
## 
## Number of Fisher Scoring iterations: 2
glmoB<- glm(Observed ~ lndrainage_area+prc_wet, family = gaussian, data=alpha, subset = substrate=='B')
summary(glmoB) ## AIC: 485.48
## 
## Call:
## glm(formula = Observed ~ lndrainage_area + prc_wet, family = gaussian, 
##     data = alpha, subset = substrate == "B")
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)  
## (Intercept)       101.00      43.61   2.316   0.0262 *
## lndrainage_area    30.10      15.14   1.989   0.0542 .
## prc_wet            88.05      59.74   1.474   0.1490  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 9673.413)
## 
##     Null deviance: 431830  on 39  degrees of freedom
## Residual deviance: 357916  on 37  degrees of freedom
## AIC: 485.48
## 
## Number of Fisher Scoring iterations: 2
glmoB<- glm(Observed ~ lndrainage_area*prc_wet, family = gaussian, data=alpha, subset = substrate=='B')
summary(glmoB) ## AIC: 487.14
## 
## Call:
## glm(formula = Observed ~ lndrainage_area * prc_wet, family = gaussian, 
##     data = alpha, subset = substrate == "B")
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)
## (Intercept)                73.48      66.32   1.108    0.275
## lndrainage_area            40.65      24.40   1.666    0.104
## prc_wet                   208.45     225.28   0.925    0.361
## lndrainage_area:prc_wet   -42.76      77.09  -0.555    0.583
## 
## (Dispersion parameter for gaussian family taken to be 9857.862)
## 
##     Null deviance: 431830  on 39  degrees of freedom
## Residual deviance: 354883  on 36  degrees of freedom
## AIC: 487.14
## 
## Number of Fisher Scoring iterations: 2
glmoB<- glm(Observed ~ lndrainage_area+prc_wet+burn_interval, family = gaussian, data=alpha, subset = substrate=='B')
summary(glmoB) ### AIC: 479.97
## 
## Call:
## glm(formula = Observed ~ lndrainage_area + prc_wet + burn_interval, 
##     family = gaussian, data = alpha, subset = substrate == "B")
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)   
## (Intercept)        4.671     53.540   0.087  0.93096   
## lndrainage_area   33.878     14.037   2.414  0.02101 * 
## prc_wet          116.613     56.115   2.078  0.04489 * 
## burn_interval     25.121      9.209   2.728  0.00979 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 8239.054)
## 
##     Null deviance: 431830  on 39  degrees of freedom
## Residual deviance: 296606  on 36  degrees of freedom
## AIC: 479.97
## 
## Number of Fisher Scoring iterations: 2
###### BEST FIT FOR EPILITHON RICHNESS ###################
glmoB<- glm(Observed ~ lndrainage_area+prc_wet+burn_interval+tempC_mean, family = gaussian, data=alpha, subset = substrate=='B')
summary(glmoB) ### AIC: 476.36  #LOWEST FOR BIOFILM RICHNESS
## 
## Call:
## glm(formula = Observed ~ lndrainage_area + prc_wet + burn_interval + 
##     tempC_mean, family = gaussian, data = alpha, subset = substrate == 
##     "B")
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)  
## (Intercept)      -91.796     65.791  -1.395   0.1717  
## lndrainage_area   31.456     13.314   2.363   0.0238 *
## prc_wet          109.552     53.146   2.061   0.0468 *
## burn_interval     18.309      9.199   1.990   0.0544 .
## tempC_mean         8.612      3.752   2.296   0.0278 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 7365.442)
## 
##     Null deviance: 431830  on 39  degrees of freedom
## Residual deviance: 257790  on 35  degrees of freedom
## AIC: 476.36
## 
## Number of Fisher Scoring iterations: 2
##########################################################

glmoB<- glm(Observed ~ lndrainage_area*prc_wet+tempC_mean, family = gaussian, data=alpha, subset = substrate=='B')
summary(glmoB) ### AIC: 480.57 
## 
## Call:
## glm(formula = Observed ~ lndrainage_area * prc_wet + tempC_mean, 
##     family = gaussian, data = alpha, subset = substrate == "B")
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)   
## (Intercept)               -65.91      77.30  -0.853  0.39961   
## lndrainage_area            32.81      22.40   1.465  0.15187   
## prc_wet                   140.06     206.62   0.678  0.50230   
## tempC_mean                 10.90       3.77   2.892  0.00654 **
## lndrainage_area:prc_wet   -18.17      70.75  -0.257  0.79888   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 8183.645)
## 
##     Null deviance: 431830  on 39  degrees of freedom
## Residual deviance: 286428  on 35  degrees of freedom
## AIC: 480.57
## 
## Number of Fisher Scoring iterations: 2
glmoB<- glm(Observed ~ lndrainage_area*prc_wet+burn_interval, family = gaussian, data=alpha, subset = substrate=='B')
summary(glmoB) ### AIC: 481.42
## 
## Call:
## glm(formula = Observed ~ lndrainage_area * prc_wet + burn_interval, 
##     family = gaussian, data = alpha, subset = substrate == "B")
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)   
## (Intercept)              -27.840     71.471  -0.390  0.69925   
## lndrainage_area           46.064     22.560   2.042  0.04876 * 
## prc_wet                  255.500    208.174   1.227  0.22789   
## burn_interval             25.336      9.281   2.730  0.00985 **
## lndrainage_area:prc_wet  -49.240     71.032  -0.693  0.49275   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 8359.68)
## 
##     Null deviance: 431830  on 39  degrees of freedom
## Residual deviance: 292589  on 35  degrees of freedom
## AIC: 481.42
## 
## Number of Fisher Scoring iterations: 2
#########################################################
####### sediment
###### BEST FIT FOR SEDIMENT RICHNESS ###################
glmoS<- glm(Observed ~ lndrainage_area, family = gaussian, data=alpha, subset = substrate=='S')
summary(glmoS) ## AIC: 591.47 # LOWEST IN SEDIMENT
## 
## Call:
## glm(formula = Observed ~ lndrainage_area, family = gaussian, 
##     data = alpha, subset = substrate == "S")
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      308.215     44.899   6.865 1.45e-08 ***
## lndrainage_area   -8.309     15.991  -0.520    0.606    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 12111.69)
## 
##     Null deviance: 560407  on 47  degrees of freedom
## Residual deviance: 557138  on 46  degrees of freedom
## AIC: 591.47
## 
## Number of Fisher Scoring iterations: 2
#########################################################

glmoS<- glm(Observed ~ lndrainage_area+prc_wet, family = gaussian, data=alpha, subset = substrate=='S')
summary(glmoS) ### AIC: 593.29
## 
## Call:
## glm(formula = Observed ~ lndrainage_area + prc_wet, family = gaussian, 
##     data = alpha, subset = substrate == "S")
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      311.644     46.061   6.766 2.27e-08 ***
## lndrainage_area   -6.997     16.446  -0.425    0.673    
## prc_wet          -25.333     61.253  -0.414    0.681    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 12333.96)
## 
##     Null deviance: 560407  on 47  degrees of freedom
## Residual deviance: 555028  on 45  degrees of freedom
## AIC: 593.29
## 
## Number of Fisher Scoring iterations: 2
glmoS<- glm(Observed ~ lndrainage_area*prc_wet, family = gaussian, data=alpha, subset = substrate=='S')
summary(glmoS) ### AIC: 594.82
## 
## Call:
## glm(formula = Observed ~ lndrainage_area * prc_wet, family = gaussian, 
##     data = alpha, subset = substrate == "S")
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              275.974     71.335   3.869 0.000358 ***
## lndrainage_area            6.742     26.647   0.253 0.801442    
## prc_wet                  130.923    245.391   0.534 0.596353    
## lndrainage_area:prc_wet  -56.055     85.208  -0.658 0.514055    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 12491.41)
## 
##     Null deviance: 560407  on 47  degrees of freedom
## Residual deviance: 549622  on 44  degrees of freedom
## AIC: 594.82
## 
## Number of Fisher Scoring iterations: 2
glmoS<- glm(Observed ~ lndrainage_area+prc_wet+burn_interval, family = gaussian, data=alpha, subset = substrate=='S')
summary(glmoS) ## AIC: 592.86
## 
## Call:
## glm(formula = Observed ~ lndrainage_area + prc_wet + burn_interval, 
##     family = gaussian, data = alpha, subset = substrate == "S")
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      259.473     57.084   4.545 4.26e-05 ***
## lndrainage_area   -5.428     16.251  -0.334    0.740    
## prc_wet          -14.537     60.825  -0.239    0.812    
## burn_interval     13.611      9.020   1.509    0.138    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 11993.65)
## 
##     Null deviance: 560407  on 47  degrees of freedom
## Residual deviance: 527721  on 44  degrees of freedom
## AIC: 592.86
## 
## Number of Fisher Scoring iterations: 2
glmoS<- glm(Observed ~ lndrainage_area+prc_wet+burn_interval+tempC_mean, family = gaussian, data=alpha, subset = substrate=='S')
summary(glmoS) ## AIC: 594.48 
## 
## Call:
## glm(formula = Observed ~ lndrainage_area + prc_wet + burn_interval + 
##     tempC_mean, family = gaussian, data = alpha, subset = substrate == 
##     "S")
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)   
## (Intercept)      230.386     75.964   3.033   0.0041 **
## lndrainage_area   -6.407     16.459  -0.389   0.6990   
## prc_wet          -16.772     61.402  -0.273   0.7860   
## burn_interval     12.453      9.301   1.339   0.1876   
## tempC_mean         2.471      4.215   0.586   0.5609   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 12175.3)
## 
##     Null deviance: 560407  on 47  degrees of freedom
## Residual deviance: 523538  on 43  degrees of freedom
## AIC: 594.48
## 
## Number of Fisher Scoring iterations: 2
glmoS<- glm(Observed ~ lndrainage_area*prc_wet+tempC_mean, family = gaussian, data=alpha, subset = substrate=='S')
summary(glmoS) ## AIC: 596.13
## 
## Call:
## glm(formula = Observed ~ lndrainage_area * prc_wet + tempC_mean, 
##     family = gaussian, data = alpha, subset = substrate == "S")
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)   
## (Intercept)              237.145     86.983   2.726  0.00923 **
## lndrainage_area            3.123     27.155   0.115  0.90898   
## prc_wet                  100.970    249.379   0.405  0.68757   
## tempC_mean                 3.336      4.237   0.787  0.43548   
## lndrainage_area:prc_wet  -45.947     86.537  -0.531  0.59818   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 12600.32)
## 
##     Null deviance: 560407  on 47  degrees of freedom
## Residual deviance: 541814  on 43  degrees of freedom
## AIC: 596.13
## 
## Number of Fisher Scoring iterations: 2
glmoS<- glm(Observed ~ lndrainage_area*prc_wet+burn_interval, family = gaussian, data=alpha, subset = substrate=='S')
summary(glmoS) ## AIC: 594.42 
## 
## Call:
## glm(formula = Observed ~ lndrainage_area * prc_wet + burn_interval, 
##     family = gaussian, data = alpha, subset = substrate == "S")
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)   
## (Intercept)              226.143     77.985   2.900  0.00586 **
## lndrainage_area            7.589     26.297   0.289  0.77427   
## prc_wet                  133.587    242.116   0.552  0.58398   
## burn_interval             13.478      9.085   1.484  0.14521   
## lndrainage_area:prc_wet  -53.175     84.091  -0.632  0.53050   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for gaussian family taken to be 12159.5)
## 
##     Null deviance: 560407  on 47  degrees of freedom
## Residual deviance: 522858  on 43  degrees of freedom
## AIC: 594.42
## 
## Number of Fisher Scoring iterations: 2
#########################################################################################################

GLMs for Shannon diversity

# Shannon Diversity by substrate
####### leaf
glmsL<- glm(Shannon ~ lndrainage_area, family = Gamma, data=alpha, subset = substrate=='L')
summary(glmsL) ### AIC: 84.772
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area, family = Gamma, data = alpha, 
##     subset = substrate == "L")
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.318906   0.018622  17.126   <2e-16 ***
## lndrainage_area -0.017426   0.006154  -2.832   0.0069 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.02280456)
## 
##     Null deviance: 1.2800  on 46  degrees of freedom
## Residual deviance: 1.0972  on 45  degrees of freedom
## AIC: 84.772
## 
## Number of Fisher Scoring iterations: 4
glmsL<- glm(Shannon ~ lndrainage_area+prc_wet, family = Gamma, data=alpha, subset = substrate=='L')
summary(glmsL) ### AIC: 84.168 ### 
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area + prc_wet, family = Gamma, 
##     data = alpha, subset = substrate == "L")
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.323603   0.018647  17.354   <2e-16 ***
## lndrainage_area -0.015549   0.006202  -2.507   0.0159 *  
## prc_wet         -0.035035   0.021061  -1.663   0.1033    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.02198014)
## 
##     Null deviance: 1.2800  on 46  degrees of freedom
## Residual deviance: 1.0383  on 44  degrees of freedom
## AIC: 84.168
## 
## Number of Fisher Scoring iterations: 4
###### BEST FIT FOR LEAF LITTER SHANNON ###################
glmsL<- glm(Shannon ~ lndrainage_area*prc_wet, family = Gamma, data=alpha, subset = substrate=='L')
summary(glmsL) ### AIC: 83.879 ### LOWEST FOR LEAF SHANNON
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area * prc_wet, family = Gamma, 
##     data = alpha, subset = substrate == "L")
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              0.356752   0.028634  12.459 7.31e-16 ***
## lndrainage_area         -0.027590   0.009994  -2.761  0.00844 ** 
## prc_wet                 -0.197933   0.107940  -1.834  0.07362 .  
## lndrainage_area:prc_wet  0.055484   0.036268   1.530  0.13338    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.02117977)
## 
##     Null deviance: 1.27998  on 46  degrees of freedom
## Residual deviance: 0.98909  on 43  degrees of freedom
## AIC: 83.879
## 
## Number of Fisher Scoring iterations: 4
###########################################################

glmsL<- glm(Shannon ~ lndrainage_area+prc_wet+tempC_mean, family = Gamma, data=alpha, subset = substrate=='L')
summary(glmsL) ### AIC: 84.168 ### 
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area + prc_wet + tempC_mean, 
##     family = Gamma, data = alpha, subset = substrate == "L")
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.3267717  0.0285582  11.442 1.24e-14 ***
## lndrainage_area -0.0155518  0.0062717  -2.480   0.0171 *  
## prc_wet         -0.0350478  0.0212869  -1.646   0.1070    
## tempC_mean      -0.0002191  0.0014814  -0.148   0.8831    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.02246013)
## 
##     Null deviance: 1.2800  on 46  degrees of freedom
## Residual deviance: 1.0378  on 43  degrees of freedom
## AIC: 86.146
## 
## Number of Fisher Scoring iterations: 4
glmsL<- glm(Shannon ~ lndrainage_area+prc_wet+burn_interval, family = Gamma, data=alpha, subset = substrate=='L')
summary(glmsL) ### AIC: 84.865
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area + prc_wet + burn_interval, 
##     family = Gamma, data = alpha, subset = substrate == "L")
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.338942   0.023006  14.733   <2e-16 ***
## lndrainage_area -0.016228   0.006212  -2.612   0.0123 *  
## prc_wet         -0.038112   0.021112  -1.805   0.0780 .  
## burn_interval   -0.003738   0.003271  -1.143   0.2595    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.02190781)
## 
##     Null deviance: 1.28  on 46  degrees of freedom
## Residual deviance: 1.01  on 43  degrees of freedom
## AIC: 84.865
## 
## Number of Fisher Scoring iterations: 4
glmsL<- glm(Shannon ~ lndrainage_area+prc_wet+burn_interval+tempC_mean, family = Gamma, data=alpha, subset = substrate=='L')
summary(glmsL) ### AIC:  86.864 
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area + prc_wet + burn_interval + 
##     tempC_mean, family = Gamma, data = alpha, subset = substrate == 
##     "L")
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      3.383e-01  3.047e-02  11.101 4.54e-14 ***
## lndrainage_area -1.623e-02  6.285e-03  -2.582   0.0134 *  
## prc_wet         -3.812e-02  2.137e-02  -1.784   0.0816 .  
## burn_interval   -3.756e-03  3.354e-03  -1.120   0.2691    
## tempC_mean       4.977e-05  1.498e-03   0.033   0.9737    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.02243281)
## 
##     Null deviance: 1.28  on 46  degrees of freedom
## Residual deviance: 1.01  on 42  degrees of freedom
## AIC: 86.864
## 
## Number of Fisher Scoring iterations: 4
glmsL<- glm(Shannon ~ lndrainage_area*prc_wet+tempC_mean, family = Gamma, data=alpha, subset = substrate=='L')
summary(glmsL) ### AIC: 85.87
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area * prc_wet + tempC_mean, 
##     family = Gamma, data = alpha, subset = substrate == "L")
## 
## Coefficients:
##                           Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              0.3585856  0.0353187  10.153 7.12e-13 ***
## lndrainage_area         -0.0275660  0.0101163  -2.725  0.00934 ** 
## prc_wet                 -0.1974331  0.1092623  -1.807  0.07794 .  
## tempC_mean              -0.0001316  0.0014483  -0.091  0.92805    
## lndrainage_area:prc_wet  0.0553092  0.0367137   1.507  0.13942    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.02167875)
## 
##     Null deviance: 1.27998  on 46  degrees of freedom
## Residual deviance: 0.98891  on 42  degrees of freedom
## AIC: 85.87
## 
## Number of Fisher Scoring iterations: 4
glmsL<- glm(Shannon ~ lndrainage_area*prc_wet+burn_interval, family = Gamma, data=alpha, subset = substrate=='L')
summary(glmsL) ### AIC: 84.755
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area * prc_wet + burn_interval, 
##     family = Gamma, data = alpha, subset = substrate == "L")
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              0.368947   0.030876  11.949 4.26e-15 ***
## lndrainage_area         -0.027568   0.009973  -2.764  0.00844 ** 
## prc_wet                 -0.192827   0.108288  -1.781  0.08220 .  
## burn_interval           -0.003394   0.003224  -1.053  0.29847    
## lndrainage_area:prc_wet  0.052758   0.036419   1.449  0.15487    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.02121778)
## 
##     Null deviance: 1.2800  on 46  degrees of freedom
## Residual deviance: 0.9658  on 42  degrees of freedom
## AIC: 84.755
## 
## Number of Fisher Scoring iterations: 4
#################################################################################
####### bioifilm
glmsB<- glm(Shannon ~ lndrainage_area, family = Gamma, data=alpha, subset = substrate=='B')
summary(glmsB) ### AIC: 71.798
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area, family = Gamma, data = alpha, 
##     subset = substrate == "B")
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.289209   0.015696  18.426  < 2e-16 ***
## lndrainage_area -0.015228   0.005218  -2.918  0.00589 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.0196937)
## 
##     Null deviance: 0.92450  on 39  degrees of freedom
## Residual deviance: 0.75712  on 38  degrees of freedom
## AIC: 71.798
## 
## Number of Fisher Scoring iterations: 4
glmsB<- glm(Shannon ~ lndrainage_area+prc_wet, family = Gamma, data=alpha, subset = substrate=='B')
summary(glmsB) ### AIC: 73.304
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area + prc_wet, family = Gamma, 
##     data = alpha, subset = substrate == "B")
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.291558   0.016210  17.986  < 2e-16 ***
## lndrainage_area -0.014561   0.005357  -2.718  0.00993 ** 
## prc_wet         -0.014164   0.020650  -0.686  0.49704    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.01994359)
## 
##     Null deviance: 0.92450  on 39  degrees of freedom
## Residual deviance: 0.74785  on 37  degrees of freedom
## AIC: 73.304
## 
## Number of Fisher Scoring iterations: 4
glmsB<- glm(Shannon ~ lndrainage_area*prc_wet, family = Gamma, data=alpha, subset = substrate=='B')
summary(glmsB) ### AIC: 73.084
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area * prc_wet, family = Gamma, 
##     data = alpha, subset = substrate == "B")
## 
## Coefficients:
##                         Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              0.31768    0.02427  13.091 2.96e-15 ***
## lndrainage_area         -0.02423    0.00850  -2.850  0.00719 ** 
## prc_wet                 -0.12511    0.07820  -1.600  0.11834    
## lndrainage_area:prc_wet  0.03860    0.02641   1.462  0.15255    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.01923683)
## 
##     Null deviance: 0.92450  on 39  degrees of freedom
## Residual deviance: 0.70761  on 36  degrees of freedom
## AIC: 73.084
## 
## Number of Fisher Scoring iterations: 4
glmsB<- glm(Shannon ~ lndrainage_area+prc_wet+burn_interval, family = Gamma, data=alpha, subset = substrate=='B')
summary(glmsB) ### AIC: 71.484
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area + prc_wet + burn_interval, 
##     family = Gamma, data = alpha, subset = substrate == "B")
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.316110   0.020272  15.593  < 2e-16 ***
## lndrainage_area -0.015413   0.005191  -2.969  0.00529 ** 
## prc_wet         -0.021598   0.020139  -1.072  0.29067    
## burn_interval   -0.006353   0.003289  -1.931  0.06134 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.01862153)
## 
##     Null deviance: 0.92450  on 39  degrees of freedom
## Residual deviance: 0.67994  on 36  degrees of freedom
## AIC: 71.484
## 
## Number of Fisher Scoring iterations: 4
glmsB<- glm(Shannon ~ lndrainage_area+prc_wet+burn_interval+tempC_mean, family = Gamma, data=alpha, subset = substrate=='B')
summary(glmsB) ### AIC: 68.913 
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area + prc_wet + burn_interval + 
##     tempC_mean, family = Gamma, data = alpha, subset = substrate == 
##     "B")
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.350873   0.025741  13.631 1.46e-15 ***
## lndrainage_area -0.014949   0.004964  -3.012   0.0048 ** 
## prc_wet         -0.019667   0.019149  -1.027   0.3114    
## burn_interval   -0.004195   0.003287  -1.276   0.2102    
## tempC_mean      -0.002922   0.001401  -2.085   0.0444 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.01682868)
## 
##     Null deviance: 0.9245  on 39  degrees of freedom
## Residual deviance: 0.6067  on 35  degrees of freedom
## AIC: 68.913
## 
## Number of Fisher Scoring iterations: 4
###### BEST FIT FOR EPILITHON SHANNON ###################
glmsB<- glm(Shannon ~ lndrainage_area*prc_wet+tempC_mean, family = Gamma, data=alpha, subset = substrate=='B')
summary(glmsB) ### AIC: 68.796 ####### LOWEST FOR BIOFILM SHANNON
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area * prc_wet + tempC_mean, 
##     family = Gamma, data = alpha, subset = substrate == "B")
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              0.362652   0.029397  12.336 2.66e-14 ***
## lndrainage_area         -0.022590   0.008062  -2.802  0.00822 ** 
## prc_wet                 -0.109276   0.073500  -1.487  0.14603    
## tempC_mean              -0.003309   0.001337  -2.475  0.01831 *  
## lndrainage_area:prc_wet  0.032809   0.024800   1.323  0.19443    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.01678025)
## 
##     Null deviance: 0.92450  on 39  degrees of freedom
## Residual deviance: 0.60493  on 35  degrees of freedom
## AIC: 68.796
## 
## Number of Fisher Scoring iterations: 4
#################################################################################

glmsB<- glm(Shannon ~ lndrainage_area*prc_wet+burn_interval, family = Gamma, data=alpha, subset = substrate=='B')
summary(glmsB) ### AIC: 70.884
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area * prc_wet + burn_interval, 
##     family = Gamma, data = alpha, subset = substrate == "B")
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              0.343297   0.026650  12.882 7.65e-15 ***
## lndrainage_area         -0.025260   0.008142  -3.103  0.00378 ** 
## prc_wet                 -0.136684   0.075904  -1.801  0.08037 .  
## burn_interval           -0.006464   0.003221  -2.007  0.05256 .  
## lndrainage_area:prc_wet  0.039772   0.025455   1.562  0.12718    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.01787228)
## 
##     Null deviance: 0.92450  on 39  degrees of freedom
## Residual deviance: 0.63726  on 35  degrees of freedom
## AIC: 70.884
## 
## Number of Fisher Scoring iterations: 4
#################################################################################
####### sediment
###### BEST FIT FOR SEDIMENT SHANNON ###################
glmsS<- glm(Shannon ~ lndrainage_area, family = Gamma, data=alpha, subset = substrate=='S')
summary(glmsS) ### AIC: 112.51 LOWEST
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area, family = Gamma, data = alpha, 
##     subset = substrate == "S")
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     2.248e-01  1.446e-02  15.546   <2e-16 ***
## lndrainage_area 8.023e-05  5.150e-03   0.016    0.988    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.02482373)
## 
##     Null deviance: 1.339  on 47  degrees of freedom
## Residual deviance: 1.339  on 46  degrees of freedom
## AIC: 112.51
## 
## Number of Fisher Scoring iterations: 4
##############################################################

glmsS<- glm(Shannon ~ lndrainage_area+prc_wet, family = Gamma, data=alpha, subset = substrate=='S')
summary(glmsS) ### AIC: 114.48
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area + prc_wet, family = Gamma, 
##     data = alpha, subset = substrate == "S")
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.2252145  0.0148534  15.163   <2e-16 ***
## lndrainage_area  0.0002545  0.0053048   0.048    0.962    
## prc_wet         -0.0033527  0.0196470  -0.171    0.865    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.02533586)
## 
##     Null deviance: 1.3390  on 47  degrees of freedom
## Residual deviance: 1.3383  on 45  degrees of freedom
## AIC: 114.48
## 
## Number of Fisher Scoring iterations: 4
glmsS<- glm(Shannon ~ lndrainage_area*prc_wet, family = Gamma, data=alpha, subset = substrate=='S')
summary(glmsS) ### AIC: 116.25
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area * prc_wet, family = Gamma, 
##     data = alpha, subset = substrate == "S")
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              0.234025   0.023211  10.083 5.18e-13 ***
## lndrainage_area         -0.003138   0.008647  -0.363    0.718    
## prc_wet                 -0.041433   0.078140  -0.530    0.599    
## lndrainage_area:prc_wet  0.013697   0.027252   0.503    0.618    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.02593494)
## 
##     Null deviance: 1.3390  on 47  degrees of freedom
## Residual deviance: 1.3318  on 44  degrees of freedom
## AIC: 116.25
## 
## Number of Fisher Scoring iterations: 4
glmsS<- glm(Shannon ~ lndrainage_area+prc_wet+burn_interval, family = Gamma, data=alpha, subset = substrate=='S')
summary(glmsS) #### AIC: 114.4
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area + prc_wet + burn_interval, 
##     family = Gamma, data = alpha, subset = substrate == "S")
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.2420253  0.0185442  13.051   <2e-16 ***
## lndrainage_area -0.0001634  0.0052837  -0.031    0.975    
## prc_wet         -0.0071479  0.0196380  -0.364    0.718    
## burn_interval   -0.0043495  0.0028703  -1.515    0.137    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.02509339)
## 
##     Null deviance: 1.3390  on 47  degrees of freedom
## Residual deviance: 1.2816  on 44  degrees of freedom
## AIC: 114.4
## 
## Number of Fisher Scoring iterations: 4
glmsS<- glm(Shannon ~ lndrainage_area+prc_wet+burn_interval+tempC_mean, family = Gamma, data=alpha, subset = substrate=='S')
summary(glmsS) ### AIC: 116.39
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area + prc_wet + burn_interval + 
##     tempC_mean, family = Gamma, data = alpha, subset = substrate == 
##     "S")
## 
## Coefficients:
##                   Estimate Std. Error t value Pr(>|t|)    
## (Intercept)      0.2436529  0.0250204   9.738 1.92e-12 ***
## lndrainage_area -0.0001205  0.0053635  -0.022    0.982    
## prc_wet         -0.0070380  0.0198960  -0.354    0.725    
## burn_interval   -0.0042881  0.0029701  -1.444    0.156    
## tempC_mean      -0.0001350  0.0013711  -0.098    0.922    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.02566735)
## 
##     Null deviance: 1.3390  on 47  degrees of freedom
## Residual deviance: 1.2813  on 43  degrees of freedom
## AIC: 116.39
## 
## Number of Fisher Scoring iterations: 4
glmsS<- glm(Shannon ~ lndrainage_area*prc_wet+tempC_mean, family = Gamma, data=alpha, subset = substrate=='S')
summary(glmsS) ### AIC: 118.14
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area * prc_wet + tempC_mean, 
##     family = Gamma, data = alpha, subset = substrate == "S")
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              0.239426   0.028556   8.385 1.36e-10 ***
## lndrainage_area         -0.002648   0.008870  -0.299    0.767    
## prc_wet                 -0.037380   0.079923  -0.468    0.642    
## tempC_mean              -0.000460   0.001379  -0.334    0.740    
## lndrainage_area:prc_wet  0.012320   0.027845   0.442    0.660    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.02645821)
## 
##     Null deviance: 1.3390  on 47  degrees of freedom
## Residual deviance: 1.3289  on 43  degrees of freedom
## AIC: 118.14
## 
## Number of Fisher Scoring iterations: 4
glmsS<- glm(Shannon ~ lndrainage_area*prc_wet+burn_interval, family = Gamma, data=alpha, subset = substrate=='S')
summary(glmsS) ### AIC: 116.18
## 
## Call:
## glm(formula = Shannon ~ lndrainage_area * prc_wet + burn_interval, 
##     family = Gamma, data = alpha, subset = substrate == "S")
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              0.250058   0.025543   9.790 1.64e-12 ***
## lndrainage_area         -0.003301   0.008603  -0.384    0.703    
## prc_wet                 -0.042758   0.078495  -0.545    0.589    
## burn_interval           -0.004310   0.002906  -1.483    0.145    
## lndrainage_area:prc_wet  0.012788   0.027330   0.468    0.642    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## (Dispersion parameter for Gamma family taken to be 0.02575849)
## 
##     Null deviance: 1.339  on 47  degrees of freedom
## Residual deviance: 1.276  on 43  degrees of freedom
## AIC: 116.18
## 
## Number of Fisher Scoring iterations: 4
#########################################################################################################

TAXONOMIC COMPOSITION:

PHYLUM ~ class ~ family Taxonomy table

#setwd("/Users/chunk/Documents/DADA2/DADA2_package_test/Kz_Syn_ITS/run_2/outputs")
#make taxonomy object by phylum
phyla_counts_tab <- otu_table(tax_glom(pseqtest, taxrank="Phylum"), taxa_are_rows = FALSE)
phyla_counts_tab <- t(phyla_counts_tab)
#make vector of phyla names to set as row names
phyla_tax_vec <- as.vector(tax_table(tax_glom(pseqtest, taxrank="Phylum"))[,2]) 
rownames(phyla_counts_tab) <- as.vector(phyla_tax_vec)
phyla_counts_tab
## OTU Table:          [15 taxa and 135 samples]
##                      taxa are rows
##                           01m01_B 01m01_L 01m01_S 01m02_B 01m02_L 01m02_S
## p__Ascomycota                1454    1977    1205    2024    2259    1057
## p__Basidiomycota              295     451     606     272     178     702
## p__Blastocladiomycota           0       0      67       7       0     276
## p__Mortierellomycota            1       2     376      86       0     334
## p__Kickxellomycota              0       1      75       0       0       0
## p__Rozellomycota                0       0       4       0       0       6
## p__Aphelidiomycota            528       3       0      16       0       3
## p__Basidiobolomycota            0       0       1       0       0       0
## p__Mucoromycota                 0       0      20       0       0       0
## p__Chytridiomycota              0       0      12       0       0       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       0       0       0       0       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                0       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           01m03_B 01m03_L 01m03_S 01m04_B 01m04_L 01m04_S
## p__Ascomycota                1362    1828     554    1541    2003     826
## p__Basidiomycota              461     589     989     726     415     630
## p__Blastocladiomycota          48       0      67       0       0     195
## p__Mortierellomycota           82       2     230      42       7     473
## p__Kickxellomycota             14       0      57       0       0      93
## p__Rozellomycota               17       0       3       0       0       8
## p__Aphelidiomycota             37       5       3       1       0      57
## p__Basidiobolomycota            0       0       0       0       0       0
## p__Mucoromycota                 8       0       3       0       0      28
## p__Chytridiomycota              0       0       0       0       0       4
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       0       0       0       0       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                0       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           01m05_B 01m05_L 01m05_S 01m06_B 01m06_L 01m06_S
## p__Ascomycota                1731    1965    1262    1591    2246     966
## p__Basidiomycota              253     445     596     507     190     878
## p__Blastocladiomycota          29       7      55       0       0       2
## p__Mortierellomycota          170       8     298       0       3     401
## p__Kickxellomycota              0       1      69     101       0      51
## p__Rozellomycota                0       0       2       0       0      11
## p__Aphelidiomycota             83       1       4      60       0       2
## p__Basidiobolomycota            0       0       1       0       0       0
## p__Mucoromycota                35       0      30       0       0       6
## p__Chytridiomycota              4       0       0       0       0       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       0       0       0       0       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                0       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           02m01_L 02m01_S 02m02_B 02m02_L 02m02_S 02m03_B
## p__Ascomycota                2074     162    2023    2180     316    2055
## p__Basidiomycota              305    2104     390     205    1938     355
## p__Blastocladiomycota          21       0      10      13      24       1
## p__Mortierellomycota            6      81       0      15     106       5
## p__Kickxellomycota              2       1       0       0       7       2
## p__Rozellomycota                0       2       0       0       2       0
## p__Aphelidiomycota              0       0       0       1       0       0
## p__Basidiobolomycota            0       0       0       0       0       0
## p__Mucoromycota                 0       0       0       1       3       0
## p__Chytridiomycota              0       0       0       0       2       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       0       0       0       7       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                0       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           02m03_L 02m03_S 02m04_L 02m04_S 02m05_B 02m05_L
## p__Ascomycota                1771     307    2265    1043    1366    2309
## p__Basidiomycota              632    1969     124     822     327     108
## p__Blastocladiomycota           4       3       9      21       8       0
## p__Mortierellomycota           13      73       3     408      10       1
## p__Kickxellomycota              2      15       0      29       0       0
## p__Rozellomycota                2       0       0       2       2       0
## p__Aphelidiomycota              0       0       0       0      11       0
## p__Basidiobolomycota            1       0       0       0       0       0
## p__Mucoromycota                 0       0       0       4       0       0
## p__Chytridiomycota              0       0       0       0       0       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       0       0       3       0       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                0       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           02m06_B 02m06_L 02m06_S 02m07_B 02m07_L 02m07_S
## p__Ascomycota                1950    2028    1443    1911    1885    1042
## p__Basidiomycota              240     366     533     247     537    1144
## p__Blastocladiomycota          24       2      68       1       0      78
## p__Mortierellomycota           35       2     203      15       2      48
## p__Kickxellomycota              5       0      47       0       0       7
## p__Rozellomycota                6       0      13      10       0      39
## p__Aphelidiomycota              3       0       1       7       0       4
## p__Basidiobolomycota            0       0       3       0       0       1
## p__Mucoromycota                 8       0       1       0       0      12
## p__Chytridiomycota              1       0       0       0       0       1
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                1       0       0       0       0       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                0       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           02m08_L 02m08_S 02m09_B 02m09_L 02m09_S 02m10_B
## p__Ascomycota                1695    1180    2038    2192    1465    2184
## p__Basidiomycota              723     245     274     233     516     214
## p__Blastocladiomycota           0      10       0       0     179       1
## p__Mortierellomycota            0     153      15       2      73       0
## p__Kickxellomycota              0     537      12       0      39       0
## p__Rozellomycota                0       3       0       0      17       0
## p__Aphelidiomycota              0       0       0       0       0       0
## p__Basidiobolomycota            0       0       0       0       0       0
## p__Mucoromycota                 0       7       0       0       0       0
## p__Chytridiomycota              0       0       0       0       0       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       0       0       0       0       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                0       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           02m10_L 02m10_S 02m11_B 02m11_S 04m01_B 04m01_L
## p__Ascomycota                2363    1785    2159    1615    1956    2011
## p__Basidiomycota               77     395     269     265     347     381
## p__Blastocladiomycota           0      12       0     197      41       5
## p__Mortierellomycota            0     141       9     174      10      18
## p__Kickxellomycota              0      14       0      24       0       3
## p__Rozellomycota                0       3       0       1       6       2
## p__Aphelidiomycota              0      19       0       1       1       0
## p__Basidiobolomycota            0       3       0       3       0       0
## p__Mucoromycota                 1       0       0       2       2       0
## p__Chytridiomycota              0       0       0       0       0       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       0       0       0       0       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                0       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           04m01_S 04m02_B 04m02_L 04m02_S 04m03_B 04m03_L
## p__Ascomycota                1324    1973    2358     614    2045    2073
## p__Basidiomycota              446     279      69     750     282     338
## p__Blastocladiomycota         211      12       0     275       0       0
## p__Mortierellomycota          168      13       3     363      10       4
## p__Kickxellomycota              8       0       1      25      12       0
## p__Rozellomycota               18       0       0       8       0       1
## p__Aphelidiomycota              6      15       0       6       0       0
## p__Basidiobolomycota            0       0       0       0       0       0
## p__Mucoromycota                 0       0       0       0       0       0
## p__Chytridiomycota              0       0       0       0       0       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       0       0       0       0       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                3       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           04m03_S 04m04_B 04m04_L 04m04_S 04m05_B 04m05_L
## p__Ascomycota                1435     840    2277     227    1472    2001
## p__Basidiomycota              528    1359     113    1967     264     429
## p__Blastocladiomycota          82       3       0       0       2       0
## p__Mortierellomycota          138      58       7     159      56       0
## p__Kickxellomycota             43       2       1      27       6       0
## p__Rozellomycota                8       9       1      11       0       0
## p__Aphelidiomycota              2      15       2       1      68       0
## p__Basidiobolomycota            4      10       0       0       0       0
## p__Mucoromycota                 3       1       0       0       0       0
## p__Chytridiomycota              0       0       0       0       0       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       0       0       0       2       0
## p__Neocallimastigomycota        3       0       1       0       0       0
## p__Glomeromycota               28       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           04m05_S 04m06_B 04m06_L 04m06_S 04m07_L 04m07_S
## p__Ascomycota                1251    1546    2269    1618    2160    1434
## p__Basidiomycota              763     616     167     496     255     485
## p__Blastocladiomycota          13       0       0       3       0     128
## p__Mortierellomycota          132       9       0     198       7      90
## p__Kickxellomycota             39       0       0      36       0       0
## p__Rozellomycota                7       0       0      18       1       8
## p__Aphelidiomycota              0      65       0       1       0      21
## p__Basidiobolomycota            0       0       0       0       0       0
## p__Mucoromycota                 3       0       0       9       0       0
## p__Chytridiomycota              0       0       0       0       0       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       0       0       0       0       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                0       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           04m08_L 04m08_S 04m09_L 04m09_S 04m10_B 04m10_L
## p__Ascomycota                2281    1742    2175    1851    2109    1857
## p__Basidiomycota              105     282     233     355     289     565
## p__Blastocladiomycota           0       0       3       0       0       0
## p__Mortierellomycota            7      77       6      47      10       2
## p__Kickxellomycota              0      35       0      29       0       0
## p__Rozellomycota                0       0       0      38       5       5
## p__Aphelidiomycota              8      27       1       0       0       0
## p__Basidiobolomycota            0       0       0       0       0       0
## p__Mucoromycota                 0       0       2       0       0       0
## p__Chytridiomycota              0       0       0       0       0       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                1      13       0       0       0       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                0       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           04m10_S 04m11_B 04m11_L 04m11_S 04m12_B 04m12_L
## p__Ascomycota                 459    2041    2338    1680    2162    2366
## p__Basidiomycota             1307     274      89     242     246      62
## p__Blastocladiomycota          66       1       0     139       0       0
## p__Mortierellomycota          372      21       4     215      24       5
## p__Kickxellomycota             37       0       0      56       0       2
## p__Rozellomycota              121       6       0       2       0       0
## p__Aphelidiomycota              5       6       0      17       0       2
## p__Basidiobolomycota            2       0       0       7       0       0
## p__Mucoromycota                 9       0       0       3       0       0
## p__Chytridiomycota              1       0       0       1       0       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       0       5       0       0       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                0       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       3       8       0
##                           04m12_S 04m13_B 04m13_L 04m13_S 04t01_B 04t01_L
## p__Ascomycota                1265    2289    1822    1348    2210    2202
## p__Basidiomycota              762     110     617     651     138     164
## p__Blastocladiomycota          58      36       0      13      21      62
## p__Mortierellomycota          220       0       0     230      11       3
## p__Kickxellomycota             24       0       0       9       0       0
## p__Rozellomycota                2       0       0      10       0       0
## p__Aphelidiomycota              4       4       0      69       0       0
## p__Basidiobolomycota            0       0       0       4       0       0
## p__Mucoromycota                 1       2       0       6       0       0
## p__Chytridiomycota              0       0       0       0       0       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       0       0       0       6       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                0       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           04t01_S 04t02_B 04t02_L 04t02_S 04w01_B 04w01_L
## p__Ascomycota                1270    2122    2296    2155    2077    2114
## p__Basidiomycota              552     214      78     197     345     326
## p__Blastocladiomycota          34       1       1       3       6       0
## p__Mortierellomycota          252      20       6      44       4       0
## p__Kickxellomycota            150       1       0      10       0       0
## p__Rozellomycota                2       1       1       1       0       0
## p__Aphelidiomycota              0       0       0       0       0       0
## p__Basidiobolomycota            2       0       0       1       0       0
## p__Mucoromycota                 0       3       0       0       0       0
## p__Chytridiomycota              0       0       0       0       0       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       0       0       0       0       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                0       0       0       0       0       0
## p__Entorrhizomycota             2       0       0       0       0       0
##                           04w01_S 04w02_B 04w02_L 04w02_S 04w03_B 04w03_S
## p__Ascomycota                1462    2282    1888     870    1936    1393
## p__Basidiomycota              554     149     495     618     505     289
## p__Blastocladiomycota          69       0      30     365       0     233
## p__Mortierellomycota          122       0      12     476       0     193
## p__Kickxellomycota             23       0       0      47       0      32
## p__Rozellomycota                1       0       0       5       0       6
## p__Aphelidiomycota              0       0       0       0       0       0
## p__Basidiobolomycota            4       0       0       0       0       2
## p__Mucoromycota                 2       0       1       1       0       3
## p__Chytridiomycota              0       0       0       0       0       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       0       0       0       0       3
## p__Neocallimastigomycota        0       0       0       0       0       2
## p__Glomeromycota                0       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           04w04_L 04w04_S 20m01_L 20m01_S 20m02_B 20m02_L
## p__Ascomycota                2190    1245    1470    1032    1490    1344
## p__Basidiomycota              240     752     901     846     634    1055
## p__Blastocladiomycota           0       0       0       3       0       0
## p__Mortierellomycota            7     351      47     353      14      20
## p__Kickxellomycota              0       0       0      98       4       0
## p__Rozellomycota                0       0       1      19       0       0
## p__Aphelidiomycota              0      44       0       0      12       0
## p__Basidiobolomycota            0       0       0       2       0       0
## p__Mucoromycota                 0       0       2       1       0       2
## p__Chytridiomycota              0       0       0       0       0       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       0       0       0       0       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                0       0       2       5       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           20m02_S 20m03_B 20m03_L 20m03_S 20m04_B 20m04_L
## p__Ascomycota                 995    2118    2337    1210    1642    2107
## p__Basidiomycota              842     260      98     534     281     308
## p__Blastocladiomycota           0       0       0       2       0       0
## p__Mortierellomycota          495       5       5     415       9       2
## p__Kickxellomycota             35       2       0      67       0       0
## p__Rozellomycota                5       2       0      12       8       0
## p__Aphelidiomycota              0       4       0       1       0       0
## p__Basidiobolomycota            0       0       0       0       0       0
## p__Mucoromycota                 2       2       0       4       0       0
## p__Chytridiomycota              0       0       0       0       0       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       0       0       0       0       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                0       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           20m04_S 20m05_L 20m05_S sfm01_B sfm01_L sfm01_S
## p__Ascomycota                1242    2310    1252    1879    2102    1303
## p__Basidiomycota              251     118     600     383     301     724
## p__Blastocladiomycota          15       1      38      11       1      34
## p__Mortierellomycota          614       0     119      39      16     239
## p__Kickxellomycota            150       0     291       1       0      60
## p__Rozellomycota               51       3      23       7       2      10
## p__Aphelidiomycota              2       0       4       9       0       4
## p__Basidiobolomycota            1       0       4       0       0       0
## p__Mucoromycota                21       0       1       0       0       0
## p__Chytridiomycota              8       0       0       0       0       0
## p__Calcarisporiellomycota       6       0       0       0       0       0
## p__Olpidiomycota                0       0       0       0       0       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                1       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           sfm02_B sfm02_L sfm02_S sfm03_B sfm03_L sfm04_B
## p__Ascomycota                1620    2329     506    1862    2192    2149
## p__Basidiomycota              509      91    1291     382     241     197
## p__Blastocladiomycota           1       0      25       0       0       0
## p__Mortierellomycota           60       1     440      17       2       3
## p__Kickxellomycota              3       0      16       0       0       0
## p__Rozellomycota                5       0       6       0       0       4
## p__Aphelidiomycota             41       0       1       0       0       0
## p__Basidiobolomycota            0       0       0       0       0       0
## p__Mucoromycota                 0       1       0       0       0       0
## p__Chytridiomycota              0       0       0       0       0       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       0       0       0       0       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                0       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           sfm04_L sfm04_S sfm05_B sfm05_L sfm05_S sfm06_L
## p__Ascomycota                1827    1795    1700    2127     497    2015
## p__Basidiomycota              255     415     440     229    1253     366
## p__Blastocladiomycota         306       0      23      36       0      17
## p__Mortierellomycota           11      84      43      18     296      18
## p__Kickxellomycota              0       4       1       0      48       1
## p__Rozellomycota                2       7       3       0       1       1
## p__Aphelidiomycota              0       7      61      15      10       1
## p__Basidiobolomycota            0       0       0       0       0       0
## p__Mucoromycota                 1       4       0       0       0       0
## p__Chytridiomycota              0       0       0       0       0       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       0       0       0       0       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                0       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           sfm06_S sfm07_B sfm07_L sfm07_S Sft01_B Sft01_L
## p__Ascomycota                1284    1763    1975    1240    1956    2055
## p__Basidiomycota              754     369     400     580     315     320
## p__Blastocladiomycota          16      29      30       2      53       1
## p__Mortierellomycota          293      54      18     506      39      11
## p__Kickxellomycota             34       3       0      16       2       0
## p__Rozellomycota                5       6       1       7       0       1
## p__Aphelidiomycota              1      46       0       0       1       0
## p__Basidiobolomycota            0       2       0       2       8       0
## p__Mucoromycota                 1       0       0       1       1       3
## p__Chytridiomycota              0       0       0       1       0       0
## p__Calcarisporiellomycota       0       0       0       0       0       0
## p__Olpidiomycota                0       3       0       0       0       0
## p__Neocallimastigomycota        0       0       0       0       0       0
## p__Glomeromycota                0       0       0       0       0       0
## p__Entorrhizomycota             0       0       0       0       0       0
##                           Sft01_S Sft02_B Sft02_S
## p__Ascomycota                1146    2102    1726
## p__Basidiomycota              766     272     333
## p__Blastocladiomycota          41       7       0
## p__Mortierellomycota          286      13     194
## p__Kickxellomycota             36       1      53
## p__Rozellomycota                8       2      13
## p__Aphelidiomycota              2       0       0
## p__Basidiobolomycota            6       0       0
## p__Mucoromycota                 1       1      11
## p__Chytridiomycota              0       0       0
## p__Calcarisporiellomycota       0       0       0
## p__Olpidiomycota                0       0       0
## p__Neocallimastigomycota        0       0       0
## p__Glomeromycota                0       0       4
## p__Entorrhizomycota             0       0       0
write.csv(phyla_counts_tab, 'phyla_counts_rar_03.08.2025.csv')
asv_counts <- pseqtest@otu_table
#determine the number of unclassified seqs at the phylum level
unclassified_tax_counts <- colSums(t(asv_counts)) - colSums(phyla_counts_tab)
#Add a row of "unclassified" to the phylum count table
phyla_and_unidentified_counts_tab <- rbind(phyla_counts_tab, "Unclassified_Phylum"=unclassified_tax_counts)

split Ascomycota into classes

#remove p__Ascomycota for the purpose of separating it into classes later
temp_major_taxa_counts_tab <- 
  phyla_and_unidentified_counts_tab[!row.names(phyla_and_unidentified_counts_tab)
                                    %in% "p__Ascomycota",]
#make count table broken down by class
class_counts_tab <- otu_table(tax_glom(t(pseqtest), taxrank="Class"))
#make table containing phylum and class data
class_tax_phy_tab <- tax_table(tax_glom(t(pseqtest), taxrank="Class"))
phy_tmp_vec <- class_tax_phy_tab[,2]
class_tmp_vec <- class_tax_phy_tab[,3]
rows_tmp <- row.names(class_tax_phy_tab)
class_tax_tab <- data.frame("Phylum"=phy_tmp_vec, "Class"=class_tmp_vec, row.names = rows_tmp)
#make vector of just the p__Ascomycota classes
asco_classes_vec <- as.vector(class_tax_tab[class_tax_tab$Phylum == "p__Ascomycota", "Class"])
row.names(class_counts_tab) <- as.vector(class_tax_tab$Class)
#make table of p__Ascomycota classes
asco_class_counts_tab <- class_counts_tab[row.names(class_counts_tab) %in% asco_classes_vec, ]
#make table of p__Ascomycota not identified to the class level
asco_no_class_annotated_counts <- 
  phyla_and_unidentified_counts_tab[row.names(phyla_and_unidentified_counts_tab) %in% "p__Ascomycota",]-
  colSums(asco_class_counts_tab)
#Now combine the tables
major_taxa_counts_tab <- rbind(temp_major_taxa_counts_tab, asco_class_counts_tab,
                               "Unclassified_Ascomycetes"=asco_no_class_annotated_counts)
head(major_taxa_counts_tab)
##                       01m01_B 01m01_L 01m01_S 01m02_B 01m02_L 01m02_S 01m03_B
## p__Basidiomycota          295     451     606     272     178     702     461
## p__Blastocladiomycota       0       0      67       7       0     276      48
## p__Mortierellomycota        1       2     376      86       0     334      82
## p__Kickxellomycota          0       1      75       0       0       0      14
## p__Rozellomycota            0       0       4       0       0       6      17
## p__Aphelidiomycota        528       3       0      16       0       3      37
##                       01m03_L 01m03_S 01m04_B 01m04_L 01m04_S 01m05_B 01m05_L
## p__Basidiomycota          589     989     726     415     630     253     445
## p__Blastocladiomycota       0      67       0       0     195      29       7
## p__Mortierellomycota        2     230      42       7     473     170       8
## p__Kickxellomycota          0      57       0       0      93       0       1
## p__Rozellomycota            0       3       0       0       8       0       0
## p__Aphelidiomycota          5       3       1       0      57      83       1
##                       01m05_S 01m06_B 01m06_L 01m06_S 02m01_L 02m01_S 02m02_B
## p__Basidiomycota          596     507     190     878     305    2104     390
## p__Blastocladiomycota      55       0       0       2      21       0      10
## p__Mortierellomycota      298       0       3     401       6      81       0
## p__Kickxellomycota         69     101       0      51       2       1       0
## p__Rozellomycota            2       0       0      11       0       2       0
## p__Aphelidiomycota          4      60       0       2       0       0       0
##                       02m02_L 02m02_S 02m03_B 02m03_L 02m03_S 02m04_L 02m04_S
## p__Basidiomycota          205    1938     355     632    1969     124     822
## p__Blastocladiomycota      13      24       1       4       3       9      21
## p__Mortierellomycota       15     106       5      13      73       3     408
## p__Kickxellomycota          0       7       2       2      15       0      29
## p__Rozellomycota            0       2       0       2       0       0       2
## p__Aphelidiomycota          1       0       0       0       0       0       0
##                       02m05_B 02m05_L 02m06_B 02m06_L 02m06_S 02m07_B 02m07_L
## p__Basidiomycota          327     108     240     366     533     247     537
## p__Blastocladiomycota       8       0      24       2      68       1       0
## p__Mortierellomycota       10       1      35       2     203      15       2
## p__Kickxellomycota          0       0       5       0      47       0       0
## p__Rozellomycota            2       0       6       0      13      10       0
## p__Aphelidiomycota         11       0       3       0       1       7       0
##                       02m07_S 02m08_L 02m08_S 02m09_B 02m09_L 02m09_S 02m10_B
## p__Basidiomycota         1144     723     245     274     233     516     214
## p__Blastocladiomycota      78       0      10       0       0     179       1
## p__Mortierellomycota       48       0     153      15       2      73       0
## p__Kickxellomycota          7       0     537      12       0      39       0
## p__Rozellomycota           39       0       3       0       0      17       0
## p__Aphelidiomycota          4       0       0       0       0       0       0
##                       02m10_L 02m10_S 02m11_B 02m11_S 04m01_B 04m01_L 04m01_S
## p__Basidiomycota           77     395     269     265     347     381     446
## p__Blastocladiomycota       0      12       0     197      41       5     211
## p__Mortierellomycota        0     141       9     174      10      18     168
## p__Kickxellomycota          0      14       0      24       0       3       8
## p__Rozellomycota            0       3       0       1       6       2      18
## p__Aphelidiomycota          0      19       0       1       1       0       6
##                       04m02_B 04m02_L 04m02_S 04m03_B 04m03_L 04m03_S 04m04_B
## p__Basidiomycota          279      69     750     282     338     528    1359
## p__Blastocladiomycota      12       0     275       0       0      82       3
## p__Mortierellomycota       13       3     363      10       4     138      58
## p__Kickxellomycota          0       1      25      12       0      43       2
## p__Rozellomycota            0       0       8       0       1       8       9
## p__Aphelidiomycota         15       0       6       0       0       2      15
##                       04m04_L 04m04_S 04m05_B 04m05_L 04m05_S 04m06_B 04m06_L
## p__Basidiomycota          113    1967     264     429     763     616     167
## p__Blastocladiomycota       0       0       2       0      13       0       0
## p__Mortierellomycota        7     159      56       0     132       9       0
## p__Kickxellomycota          1      27       6       0      39       0       0
## p__Rozellomycota            1      11       0       0       7       0       0
## p__Aphelidiomycota          2       1      68       0       0      65       0
##                       04m06_S 04m07_L 04m07_S 04m08_L 04m08_S 04m09_L 04m09_S
## p__Basidiomycota          496     255     485     105     282     233     355
## p__Blastocladiomycota       3       0     128       0       0       3       0
## p__Mortierellomycota      198       7      90       7      77       6      47
## p__Kickxellomycota         36       0       0       0      35       0      29
## p__Rozellomycota           18       1       8       0       0       0      38
## p__Aphelidiomycota          1       0      21       8      27       1       0
##                       04m10_B 04m10_L 04m10_S 04m11_B 04m11_L 04m11_S 04m12_B
## p__Basidiomycota          289     565    1307     274      89     242     246
## p__Blastocladiomycota       0       0      66       1       0     139       0
## p__Mortierellomycota       10       2     372      21       4     215      24
## p__Kickxellomycota          0       0      37       0       0      56       0
## p__Rozellomycota            5       5     121       6       0       2       0
## p__Aphelidiomycota          0       0       5       6       0      17       0
##                       04m12_L 04m12_S 04m13_B 04m13_L 04m13_S 04t01_B 04t01_L
## p__Basidiomycota           62     762     110     617     651     138     164
## p__Blastocladiomycota       0      58      36       0      13      21      62
## p__Mortierellomycota        5     220       0       0     230      11       3
## p__Kickxellomycota          2      24       0       0       9       0       0
## p__Rozellomycota            0       2       0       0      10       0       0
## p__Aphelidiomycota          2       4       4       0      69       0       0
##                       04t01_S 04t02_B 04t02_L 04t02_S 04w01_B 04w01_L 04w01_S
## p__Basidiomycota          552     214      78     197     345     326     554
## p__Blastocladiomycota      34       1       1       3       6       0      69
## p__Mortierellomycota      252      20       6      44       4       0     122
## p__Kickxellomycota        150       1       0      10       0       0      23
## p__Rozellomycota            2       1       1       1       0       0       1
## p__Aphelidiomycota          0       0       0       0       0       0       0
##                       04w02_B 04w02_L 04w02_S 04w03_B 04w03_S 04w04_L 04w04_S
## p__Basidiomycota          149     495     618     505     289     240     752
## p__Blastocladiomycota       0      30     365       0     233       0       0
## p__Mortierellomycota        0      12     476       0     193       7     351
## p__Kickxellomycota          0       0      47       0      32       0       0
## p__Rozellomycota            0       0       5       0       6       0       0
## p__Aphelidiomycota          0       0       0       0       0       0      44
##                       20m01_L 20m01_S 20m02_B 20m02_L 20m02_S 20m03_B 20m03_L
## p__Basidiomycota          901     846     634    1055     842     260      98
## p__Blastocladiomycota       0       3       0       0       0       0       0
## p__Mortierellomycota       47     353      14      20     495       5       5
## p__Kickxellomycota          0      98       4       0      35       2       0
## p__Rozellomycota            1      19       0       0       5       2       0
## p__Aphelidiomycota          0       0      12       0       0       4       0
##                       20m03_S 20m04_B 20m04_L 20m04_S 20m05_L 20m05_S sfm01_B
## p__Basidiomycota          534     281     308     251     118     600     383
## p__Blastocladiomycota       2       0       0      15       1      38      11
## p__Mortierellomycota      415       9       2     614       0     119      39
## p__Kickxellomycota         67       0       0     150       0     291       1
## p__Rozellomycota           12       8       0      51       3      23       7
## p__Aphelidiomycota          1       0       0       2       0       4       9
##                       sfm01_L sfm01_S sfm02_B sfm02_L sfm02_S sfm03_B sfm03_L
## p__Basidiomycota          301     724     509      91    1291     382     241
## p__Blastocladiomycota       1      34       1       0      25       0       0
## p__Mortierellomycota       16     239      60       1     440      17       2
## p__Kickxellomycota          0      60       3       0      16       0       0
## p__Rozellomycota            2      10       5       0       6       0       0
## p__Aphelidiomycota          0       4      41       0       1       0       0
##                       sfm04_B sfm04_L sfm04_S sfm05_B sfm05_L sfm05_S sfm06_L
## p__Basidiomycota          197     255     415     440     229    1253     366
## p__Blastocladiomycota       0     306       0      23      36       0      17
## p__Mortierellomycota        3      11      84      43      18     296      18
## p__Kickxellomycota          0       0       4       1       0      48       1
## p__Rozellomycota            4       2       7       3       0       1       1
## p__Aphelidiomycota          0       0       7      61      15      10       1
##                       sfm06_S sfm07_B sfm07_L sfm07_S Sft01_B Sft01_L Sft01_S
## p__Basidiomycota          754     369     400     580     315     320     766
## p__Blastocladiomycota      16      29      30       2      53       1      41
## p__Mortierellomycota      293      54      18     506      39      11     286
## p__Kickxellomycota         34       3       0      16       2       0      36
## p__Rozellomycota            5       6       1       7       0       1       8
## p__Aphelidiomycota          1      46       0       0       1       0       2
##                       Sft02_B Sft02_S
## p__Basidiomycota          272     333
## p__Blastocladiomycota       7       0
## p__Mortierellomycota       13     194
## p__Kickxellomycota          1      53
## p__Rozellomycota            2      13
## p__Aphelidiomycota          0       0
write.csv(major_taxa_counts_tab, "majortaxa_count_rar_03.08.2025.csv")
#Check that all sequences are accounted for
identical(colSums(major_taxa_counts_tab), rowSums(asv_counts))
## [1] TRUE
## [1] TRUE
#Convert totals to relative abundance
major_taxa_proportions_tab <- apply(major_taxa_counts_tab, 2, function(x) x/sum(x)*100)
#colSums(major_taxa_proportions_tab)
write.csv(major_taxa_proportions_tab, "majortaxa_relative abundance_rar_03.08.2025col.csv")

by family

#make taxonomy object by genus
family_counts_tab <- otu_table(tax_glom(pseqtest, taxrank="Family"), taxa_are_rows = FALSE)
family_counts_tab <- t(family_counts_tab)
#make vector of genus names to set as row names
family_tax_vec <- as.vector(tax_table(tax_glom(pseqtest, taxrank="Family"))[,5]) 
rownames(family_counts_tab) <- as.vector(family_tax_vec)

#determine the number of unclassified seqs at the family level
unclassified_family_counts <- colSums(t(asv_counts)) - colSums(family_counts_tab)
unclassified_family_counts
## 01m01_B 01m01_L 01m01_S 01m02_B 01m02_L 01m02_S 01m03_B 01m03_L 01m03_S 01m04_B 
##     355      39     122     208      81     112     629      31     577     377 
## 01m04_L 01m04_S 01m05_B 01m05_L 01m05_S 01m06_B 01m06_L 01m06_S 02m01_L 02m01_S 
##      54     189     213      48     318     331      16     223      64      98 
## 02m02_B 02m02_L 02m02_S 02m03_B 02m03_L 02m03_S 02m04_L 02m04_S 02m05_B 02m05_L 
##     128      60      92      52      34      98      72     148    1033      92 
## 02m06_B 02m06_L 02m06_S 02m07_B 02m07_L 02m07_S 02m08_L 02m08_S 02m09_B 02m09_L 
##     250      85     212     338      38     130      77     340     148      95 
## 02m09_S 02m10_B 02m10_L 02m10_S 02m11_B 02m11_S 04m01_B 04m01_L 04m01_S 04m02_B 
##     286     102      18     139     145     272     116      84     424     222 
## 04m02_L 04m02_S 04m03_B 04m03_L 04m03_S 04m04_B 04m04_L 04m04_S 04m05_B 04m05_L 
##      39     507     163      65     329     183      57      91     726      33 
## 04m05_S 04m06_B 04m06_L 04m06_S 04m07_L 04m07_S 04m08_L 04m08_S 04m09_L 04m09_S 
##     325     241      84     215      30     478     326     528     200     310 
## 04m10_B 04m10_L 04m10_S 04m11_B 04m11_L 04m11_S 04m12_B 04m12_L 04m12_S 04m13_B 
##      95      23     111     127      94     286      62      19     356      49 
## 04m13_L 04m13_S 04t01_B 04t01_L 04t01_S 04t02_B 04t02_L 04t02_S 04w01_B 04w01_L 
##      73     472     133      42     244     181      78      62      43      18 
## 04w01_S 04w02_B 04w02_L 04w02_S 04w03_B 04w03_S 04w04_L 04w04_S 20m01_L 20m01_S 
##     288      10      34      99     228     406      94     296     108     132 
## 20m02_B 20m02_L 20m02_S 20m03_B 20m03_L 20m03_S 20m04_B 20m04_L 20m04_S 20m05_L 
##     394     102     101     109      44     277     630      89     145      81 
## 20m05_S sfm01_B sfm01_L sfm01_S sfm02_B sfm02_L sfm02_S sfm03_B sfm03_L sfm04_B 
##     194     197      55     158     453      31     194     322      20     106 
## sfm04_L sfm04_S sfm05_B sfm05_L sfm05_S sfm06_L sfm06_S sfm07_B sfm07_L sfm07_S 
##      90     254     343      81     378     177     125     301      54     127 
## Sft01_B Sft01_L Sft01_S Sft02_B Sft02_S 
##     172     106     338     192     578
#Add a row of "unclassified" to the family count table
family_and_unidentified_counts_tab <- rbind(family_counts_tab, 
                                            "Unclassified_family"=unclassified_family_counts)
write.csv(family_and_unidentified_counts_tab, "family raw abundance_rar.csv")
#Check that all seqs are accounted for.

identical(colSums(family_and_unidentified_counts_tab), rowSums(asv_counts))
## [1] TRUE
#Convert totals to relative abundance
family_proportions_tab <- apply(family_and_unidentified_counts_tab, 2, function(x) x/sum(x)*100)
write.csv(family_proportions_tab, "family relative abundance_rar.csv")
#Merge metadata, phylum, and family abundances
#phy_and_fam <- merge(t(major_taxa_counts_tab), t(family_and_unidentified_counts_tab),
#                  by="row.names", all=TRUE)
phy_and_fam <- merge(t(major_taxa_proportions_tab), t(family_proportions_tab),
                  by="row.names", all=TRUE)
phyfam <- phy_and_fam[,-1]
rownames(phyfam) <- phy_and_fam[,1]
tax_merge <- merge(samdftest, phyfam,
                  by="row.names", all=TRUE)
taxmerge <- tax_merge[,-1]
rownames(taxmerge) <- tax_merge[,1]
write.csv(tax_merge, "1216R_03.08.2025_taxmerge.csv")

summary stats about major taxa

colnames(taxmerge)
##   [1] "siteid"                                      
##   [2] "Sample"                                      
##   [3] "substrate"                                   
##   [4] "Site"                                        
##   [5] "sticID"                                      
##   [6] "wet_dry"                                     
##   [7] "n_wet"                                       
##   [8] "n_total"                                     
##   [9] "prc_missing"                                 
##  [10] "prc_wet"                                     
##  [11] "tempC_mean"                                  
##  [12] "LeafSpecies1"                                
##  [13] "LeafSpecies2"                                
##  [14] "LeafSpecies3"                                
##  [15] "Elm"                                         
##  [16] "Populus"                                     
##  [17] "Oak"                                         
##  [18] "Locust"                                      
##  [19] "Graminales"                                  
##  [20] "Elderberry"                                  
##  [21] "Rubrus"                                      
##  [22] "Forb"                                        
##  [23] "Shrub"                                       
##  [24] "Unknown"                                     
##  [25] "Sediment.Texture.Description"                
##  [26] "Percent.Rocks"                               
##  [27] "Percent.Leaf.Litter"                         
##  [28] "Percent.Sediment"                            
##  [29] "meanN2Ar"                                    
##  [30] "meanO2Ar"                                    
##  [31] "meanO2"                                      
##  [32] "project"                                     
##  [33] "date"                                        
##  [34] "rType"                                       
##  [35] "rep"                                         
##  [36] "sublocation"                                 
##  [37] "month"                                       
##  [38] "time_cst"                                    
##  [39] "sub_watershed"                               
##  [40] "burn_area"                                   
##  [41] "burn_interval"                               
##  [42] "stream_order"                                
##  [43] "elevation"                                   
##  [44] "flow_state"                                  
##  [45] "conductivity"                                
##  [46] "canopy_cover_percent"                        
##  [47] "long"                                        
##  [48] "lat"                                         
##  [49] "stic_sublocation"                            
##  [50] "stream_temp_C_1wk_avg"                       
##  [51] "stream_temp_C_2wk_avg"                       
##  [52] "stream_temp_C_3wk_avg"                       
##  [53] "percent_wet_1wk_avg"                         
##  [54] "percent_wet_2wk_avg"                         
##  [55] "percent_wet_3wk_avg"                         
##  [56] "twi"                                         
##  [57] "distance_from_outlet"                        
##  [58] "drainage_area"                               
##  [59] "wetted_width"                                
##  [60] "slope_percent"                               
##  [61] "weather"                                     
##  [62] "pH"                                          
##  [63] "crewBGC"                                     
##  [64] "crewMicro"                                   
##  [65] "wetdrybin"                                   
##  [66] "alpha.cent"                                  
##  [67] "page.rank"                                   
##  [68] "imp.closeness.cent"                          
##  [69] "betweenness.cent"                            
##  [70] "n.nodes.in.paths"                            
##  [71] "n.paths"                                     
##  [72] "upstream.network.length"                     
##  [73] "path.length.mean"                            
##  [74] "path.length.var"                             
##  [75] "path.length.skew"                            
##  [76] "path.length.kurt"                            
##  [77] "path.degree.mean"                            
##  [78] "path.degree.var"                             
##  [79] "path.degree.skew"                            
##  [80] "path.degree.kurt"                            
##  [81] "in.eccentricity"                             
##  [82] "mean.efficiency"                             
##  [83] "alpha.cent.wt"                               
##  [84] "flowing.upstream.length.m"                   
##  [85] "W_Chl.a_ug_per_mL"                           
##  [86] "rock_area"                                   
##  [87] "B_Chl.a_ug_per_cm2"                          
##  [88] "W_AFDM"                                      
##  [89] "B_AFDM"                                      
##  [90] "S_AFDM"                                      
##  [91] "LL_AFDM"                                     
##  [92] "pw_cluster"                                  
##  [93] "wet_dist_cluster"                            
##  [94] "burn_freq"                                   
##  [95] "lndrainage_area"                             
##  [96] "p__Basidiomycota"                            
##  [97] "p__Blastocladiomycota"                       
##  [98] "p__Mortierellomycota"                        
##  [99] "p__Kickxellomycota"                          
## [100] "p__Rozellomycota"                            
## [101] "p__Aphelidiomycota"                          
## [102] "p__Basidiobolomycota"                        
## [103] "p__Mucoromycota"                             
## [104] "p__Chytridiomycota"                          
## [105] "p__Calcarisporiellomycota"                   
## [106] "p__Olpidiomycota"                            
## [107] "p__Neocallimastigomycota"                    
## [108] "p__Glomeromycota"                            
## [109] "p__Entorrhizomycota"                         
## [110] "Unclassified_Phylum"                         
## [111] "c__Dothideomycetes"                          
## [112] "c__Leotiomycetes"                            
## [113] "c__Sordariomycetes"                          
## [114] "c__Eurotiomycetes"                           
## [115] "c__Orbiliomycetes"                           
## [116] "c__Pezizomycotina_cls_Incertae_sedis"        
## [117] "c__Saccharomycetes"                          
## [118] "c__Lecanoromycetes"                          
## [119] "c__Pezizomycetes"                            
## [120] "c__Laboulbeniomycetes"                       
## [121] "c__Taphrinomycetes"                          
## [122] "c__Schizosaccharomycetes"                    
## [123] "c__Geoglossomycetes"                         
## [124] "c__Candelariomycetes"                        
## [125] "c__Arthoniomycetes"                          
## [126] "Unclassified_Ascomycetes"                    
## [127] "f__Pleosporaceae"                            
## [128] "f__Cladosporiaceae"                          
## [129] "f__Phallaceae"                               
## [130] "f__Mycosphaerellaceae"                       
## [131] "f__Phaeosphaeriaceae"                        
## [132] "f__Helotiales_fam_Incertae_sedis"            
## [133] "f__Didymosphaeriaceae"                       
## [134] "f__Cucurbitariaceae"                         
## [135] "f__Helotiaceae"                              
## [136] "f__Gnomoniaceae"                             
## [137] "f__Phacidiaceae"                             
## [138] "f__Chaetomellaceae"                          
## [139] "f__Calloriaceae"                             
## [140] "f__Blastocladiales_fam_Incertae_sedis"       
## [141] "f__Sporocadaceae"                            
## [142] "f__Cylindrosympodiaceae"                     
## [143] "f__Venturiaceae"                             
## [144] "f__Mortierellaceae"                          
## [145] "f__Didymellaceae"                            
## [146] "f__Sebacinaceae"                             
## [147] "f__Hyaloscyphaceae"                          
## [148] "f__Filobasidiaceae"                          
## [149] "f__Xylariaceae"                              
## [150] "f__Verrucariaceae"                           
## [151] "f__Helicogoniaceae"                          
## [152] "f__Saccotheciaceae"                          
## [153] "f__Phanerochaetaceae"                        
## [154] "f__Piskurozymaceae"                          
## [155] "f__Tubulicrinaceae"                          
## [156] "f__Coniothyriaceae"                          
## [157] "f__Leptosphaeriaceae"                        
## [158] "f__Tricholomataceae"                         
## [159] "f__Thelephoraceae"                           
## [160] "f__Cystofilobasidiaceae"                     
## [161] "f__Microsporomycetaceae"                     
## [162] "f__Inocybaceae"                              
## [163] "f__Hymenogastraceae"                         
## [164] "f__Discosiaceae"                             
## [165] "f__Dictyosporiaceae"                         
## [166] "f__Sporormiaceae"                            
## [167] "f__Symmetrosporaceae"                        
## [168] "f__Mrakiaceae"                               
## [169] "f__Melanommataceae"                          
## [170] "f__Auriculariales_fam_Incertae_sedis"        
## [171] "f__Leotiaceae"                               
## [172] "f__Teratosphaeriaceae"                       
## [173] "f__Kickxellomycota_fam_Incertae_sedis"       
## [174] "f__Neodevriesiaceae"                         
## [175] "f__Hygrophoraceae"                           
## [176] "f__Thelebolaceae"                            
## [177] "f__Orbiliaceae"                              
## [178] "f__Trichomeriaceae"                          
## [179] "f__Corticiaceae"                             
## [180] "f__Strophariaceae"                           
## [181] "f__GS11_fam_Incertae_sedis"                  
## [182] "f__Nectriaceae"                              
## [183] "f__Mortierellales_fam_Incertae_sedis"        
## [184] "f__Cylindriaceae"                            
## [185] "f__Pezizomycotina_fam_Incertae_sedis"        
## [186] "f__Dothioraceae"                             
## [187] "f__Russulaceae"                              
## [188] "f__Neopyrenochaetaceae"                      
## [189] "f__Rhynchogastremataceae"                    
## [190] "f__Dothideales_fam_Incertae_sedis"           
## [191] "f__Botryosphaeriaceae"                       
## [192] "f__Bulleribasidiaceae"                       
## [193] "f__Rickenellaceae"                           
## [194] "f__Aliquandostipitaceae"                     
## [195] "f__Amniculicolaceae"                         
## [196] "f__Tricladiaceae"                            
## [197] "f__Debaryomycetaceae"                        
## [198] "f__Erythrobasidiaceae"                       
## [199] "f__Rutstroemiaceae"                          
## [200] "f__Ascobolaceae"                             
## [201] "f__Irpicaceae"                               
## [202] "f__Sordariales_fam_Incertae_sedis"           
## [203] "f__Lentitheciaceae"                          
## [204] "f__Pannariaceae"                             
## [205] "f__Diaporthaceae"                            
## [206] "f__Amphisphaeriaceae"                        
## [207] "f__Nothodactylariaceae"                      
## [208] "f__Trematosphaeriaceae"                      
## [209] "f__Gastrosporiaceae"                         
## [210] "f__Niessliaceae"                             
## [211] "f__Periconiaceae"                            
## [212] "f__Sebacinales_fam_Incertae_sedis"           
## [213] "f__Basidiomycota_fam_Incertae_sedis"         
## [214] "f__Lycoperdaceae"                            
## [215] "f__Serendipitaceae"                          
## [216] "f__Aphelidiomycota_fam_Incertae_sedis"       
## [217] "f__Bionectriaceae"                           
## [218] "f__Pseudeurotiaceae"                         
## [219] "f__Geastraceae"                              
## [220] "f__Extremaceae"                              
## [221] "f__Hebelomataceae"                           
## [222] "f__Meruliaceae"                              
## [223] "f__Phaeotremellaceae"                        
## [224] "f__Pezizaceae"                               
## [225] "f__Chaetomiaceae"                            
## [226] "f__Psathyrellaceae"                          
## [227] "f__Tuberaceae"                               
## [228] "f__Hydnodontaceae"                           
## [229] "f__Catenariaceae"                            
## [230] "f__Herpotrichiellaceae"                      
## [231] "f__Tarzettaceae"                             
## [232] "f__Glomerellaceae"                           
## [233] "f__Hypocreaceae"                             
## [234] "f__Crepidotaceae"                            
## [235] "f__Physalacriaceae"                          
## [236] "f__Russulales_fam_Incertae_sedis"            
## [237] "f__Pyxidiophoraceae"                         
## [238] "f__Ganodermataceae"                          
## [239] "f__Lasiosphaeriaceae"                        
## [240] "f__Acrocalymmaceae"                          
## [241] "f__Lophiostomataceae"                        
## [242] "f__Boletaceae"                               
## [243] "f__Clavicipitaceae"                          
## [244] "f__Sporidiobolaceae"                         
## [245] "f__Hypocreales_fam_Incertae_sedis"           
## [246] "f__Massarinaceae"                            
## [247] "f__Podoscyphaceae"                           
## [248] "f__Sclerococcaceae"                          
## [249] "f__Sympoventuriaceae"                        
## [250] "f__Trichosporonaceae"                        
## [251] "f__Schizoporaceae"                           
## [252] "f__Pezizales_fam_Incertae_sedis"             
## [253] "f__Buckleyzymaceae"                          
## [254] "f__Aspergillaceae"                           
## [255] "f__Agaricales_fam_Incertae_sedis"            
## [256] "f__Taphrinaceae"                             
## [257] "f__Bartaliniaceae"                           
## [258] "f__Schizosaccharomycetaceae"                 
## [259] "f__Stachybotryaceae"                         
## [260] "f__Valsariaceae"                             
## [261] "f__Cordycipitaceae"                          
## [262] "f__Amorosiaceae"                             
## [263] "f__Dermateaceae"                             
## [264] "f__Cystobasidiales_fam_Incertae_sedis"       
## [265] "f__Polyporaceae"                             
## [266] "f__Cystobasidiaceae"                         
## [267] "f__Hyaloriaceae"                             
## [268] "f__Sclerotiniaceae"                          
## [269] "f__Erythrobasidiales_fam_Incertae_sedis"     
## [270] "f__Discinellaceae"                           
## [271] "f__Strelitzianaceae"                         
## [272] "f__Pestalotiopsidaceae"                      
## [273] "f__Schizoparmaceae"                          
## [274] "f__Exidiaceae"                               
## [275] "f__Peniophoraceae"                           
## [276] "f__Agaricomycotina_fam_Incertae_sedis"       
## [277] "f__Tzeananiaceae"                            
## [278] "f__Nigrogranaceae"                           
## [279] "f__Massariaceae"                             
## [280] "f__Microbotryaceae"                          
## [281] "f__Geastrales_fam_Incertae_sedis"            
## [282] "f__Omphalotaceae"                            
## [283] "f__Orbiliomycetes_fam_Incertae_sedis"        
## [284] "f__Cystofilobasidiales_fam_Incertae_sedis"   
## [285] "f__Chrysozymaceae"                           
## [286] "f__Pleosporales_fam_Incertae_sedis"          
## [287] "f__Aplosporellaceae"                         
## [288] "f__Aphelidiomycetes_fam_Incertae_sedis"      
## [289] "f__Hysteriaceae"                             
## [290] "f__Kondoaceae"                               
## [291] "f__Neocelosporiaceae"                        
## [292] "f__Stephanosporaceae"                        
## [293] "f__Geminibasidiaceae"                        
## [294] "f__Entolomataceae"                           
## [295] "f__Trichosphaeriaceae"                       
## [296] "f__Onygenales_fam_Incertae_sedis"            
## [297] "f__Acrospermaceae"                           
## [298] "f__GS05_fam_Incertae_sedis"                  
## [299] "f__Steccherinaceae"                          
## [300] "f__Bolbitiaceae"                             
## [301] "f__Basidiobolomycota_fam_Incertae_sedis"     
## [302] "f__Cunninghamellaceae"                       
## [303] "f__Magnaporthaceae"                          
## [304] "f__GS08_fam_Incertae_sedis"                  
## [305] "f__Bulleraceae"                              
## [306] "f__Gelatinodiscaceae"                        
## [307] "f__Lipomycetaceae"                           
## [308] "f__Microstromataceae"                        
## [309] "f__Naviculisporaceae"                        
## [310] "f__Laboulbeniomycetes_fam_Incertae_sedis"    
## [311] "f__Cryphonectriaceae"                        
## [312] "f__Phaeoseptaceae"                           
## [313] "f__Malasseziaceae"                           
## [314] "f__Chaetothyriales_fam_Incertae_sedis"       
## [315] "f__Libertasomycetaceae"                      
## [316] "f__Cyphellophoraceae"                        
## [317] "f__Geoglossaceae"                            
## [318] "f__Pulvinulaceae"                            
## [319] "f__Blastocladiomycota_fam_Incertae_sedis"    
## [320] "f__GS13_fam_Incertae_sedis"                  
## [321] "f__Candelariaceae"                           
## [322] "f__Cryptocoryneaceae"                        
## [323] "f__Lophiotremataceae"                        
## [324] "f__Sordariaceae"                             
## [325] "f__Physciaceae"                              
## [326] "f__Saccharomycetaceae"                       
## [327] "f__Dothideomycetes_fam_Incertae_sedis"       
## [328] "f__Pyronemataceae"                           
## [329] "f__Sclerodermataceae"                        
## [330] "f__Ascodesmidaceae"                          
## [331] "f__Gomphaceae"                               
## [332] "f__Endogonomycetes_fam_Incertae_sedis"       
## [333] "f__Torulaceae"                               
## [334] "f__Tremellaceae"                             
## [335] "f__Hymenochaetaceae"                         
## [336] "f__Phaffomycetaceae"                         
## [337] "f__Bombardiaceae"                            
## [338] "f__Atheliaceae"                              
## [339] "f__Fomitopsidaceae"                          
## [340] "f__Basidiobolales_fam_Incertae_sedis"        
## [341] "f__Mucoraceae"                               
## [342] "f__Hyponectriaceae"                          
## [343] "f__Pseudoperisporiaceae"                     
## [344] "f__Hyphodermataceae"                         
## [345] "f__Thyridiaceae"                             
## [346] "f__Capnodiaceae"                             
## [347] "f__Melanogastraceae"                         
## [348] "f__Aphelidiales_fam_Incertae_sedis"          
## [349] "f__Dothideaceae"                             
## [350] "f__Helminthosphaeriaceae"                    
## [351] "f__Acrospermales_fam_Incertae_sedis"         
## [352] "f__Agaricomycetes_fam_Incertae_sedis"        
## [353] "f__Agaricaceae"                              
## [354] "f__Pluteaceae"                               
## [355] "f__Orbiliales_fam_Incertae_sedis"            
## [356] "f__Hamatocanthoscyphaceae"                   
## [357] "f__Sclerogastraceae"                         
## [358] "f__Podosporaceae"                            
## [359] "f__Stictidaceae"                             
## [360] "f__Paraphysodermataceae"                     
## [361] "f__Xylariales_fam_Incertae_sedis"            
## [362] "f__Saksenaeaceae"                            
## [363] "f__Eurotiomycetes_fam_Incertae_sedis"        
## [364] "f__Halosphaeriaceae"                         
## [365] "f__Microstromatales_fam_Incertae_sedis"      
## [366] "f__Ophiocordycipitaceae"                     
## [367] "f__Branch02_fam_Incertae_sedis"              
## [368] "f__Calcarisporiellaceae"                     
## [369] "f__Tremellales_fam_Incertae_sedis"           
## [370] "f__Phaeococcomycetaceae"                     
## [371] "f__Radulomycetaceae"                         
## [372] "f__Saccharomycetales_fam_Incertae_sedis"     
## [373] "f__Roccellaceae"                             
## [374] "f__Planistromellaceae"                       
## [375] "f__Tubeufiales_fam_Incertae_sedis"           
## [376] "f__Ophiostomataceae"                         
## [377] "f__Mortierellomycota_fam_Incertae_sedis"     
## [378] "f__GS19_fam_Incertae_sedis"                  
## [379] "f__Hydnaceae"                                
## [380] "f__Spiculogloeaceae"                         
## [381] "f__Trimorphomycetaceae"                      
## [382] "f__Phaeomoniellaceae"                        
## [383] "f__Cryptococcaceae"                          
## [384] "f__Xenasmataceae"                            
## [385] "f__Acarosporaceae"                           
## [386] "f__Mycenastraceae"                           
## [387] "f__Plectosphaerellaceae"                     
## [388] "f__Apiosporaceae"                            
## [389] "f__Neophaeosphaeriaceae"                     
## [390] "f__Ramicandelaberaceae"                      
## [391] "f__Tubeufiaceae"                             
## [392] "f__Hypoxylaceae"                             
## [393] "f__Lachnaceae"                               
## [394] "f__Arthoniaceae"                             
## [395] "f__Lyophyllaceae"                            
## [396] "f__Incrustoporiaceae"                        
## [397] "f__Aporpiaceae"                              
## [398] "f__Tremellodendropsidales_fam_Incertae_sedis"
## [399] "f__Typhulaceae"                              
## [400] "f__GS07_fam_Incertae_sedis"                  
## [401] "f__Chaetosphaeriales_fam_Incertae_sedis"     
## [402] "f__Graphostromataceae"                       
## [403] "f__Dacryobolaceae"                           
## [404] "f__Capnodiales_fam_Incertae_sedis"           
## [405] "f__Olpidiaceae"                              
## [406] "f__Mortierellomycetes_fam_Incertae_sedis"    
## [407] "f__Kriegeriaceae"                            
## [408] "f__Olpidiomycota_fam_Incertae_sedis"         
## [409] "f__Microsphaeropsidaceae"                    
## [410] "f__Phomatosporaceae"                         
## [411] "f__Mycocaliciales_fam_Incertae_sedis"        
## [412] "f__Elsinoaceae"                              
## [413] "f__Cortinariaceae"                           
## [414] "f__Pileolariaceae"                           
## [415] "f__Mucorales_fam_Incertae_sedis"             
## [416] "f__Asterinales_fam_Incertae_sedis"           
## [417] "f__Stereaceae"                               
## [418] "f__Tilletiaceae"                             
## [419] "f__Microdochiaceae"                          
## [420] "f__Tubakiaceae"                              
## [421] "f__Diversisporales_fam_Incertae_sedis"       
## [422] "f__Microthyriales_fam_Incertae_sedis"        
## [423] "f__Sirobasidiaceae"                          
## [424] "f__Thelebolales_fam_Incertae_sedis"          
## [425] "f__Microbotryomycetes_fam_Incertae_sedis"    
## [426] "f__Reticulascaceae"                          
## [427] "f__Castanediellaceae"                        
## [428] "f__Tremellomycetes_fam_Incertae_sedis"       
## [429] "f__Fenestellaceae"                           
## [430] "f__Anteagloniaceae"                          
## [431] "f__Ploettnerulaceae"                         
## [432] "f__Dacrymycetaceae"                          
## [433] "f__Mytilinidales_fam_Incertae_sedis"         
## [434] "f__Myriangiales_fam_Incertae_sedis"          
## [435] "f__Mytilinidiales_fam_Incertae_sedis"        
## [436] "f__Trichomonascaceae"                        
## [437] "f__Marasmiaceae"                             
## [438] "f__Dactylosporaceae"                         
## [439] "f__Naohideaceae"                             
## [440] "f__Neocallimastigomycota_fam_Incertae_sedis" 
## [441] "f__Geoglossales_fam_Incertae_sedis"          
## [442] "f__Porodiplodiaceae"                         
## [443] "f__Lachnocladiaceae"                         
## [444] "f__GS16_fam_Incertae_sedis"                  
## [445] "f__Pterulaceae"                              
## [446] "f__Boletinellaceae"                          
## [447] "f__Panaceae"                                 
## [448] "f__Schizophyllaceae"                         
## [449] "f__Sakaguchiaceae"                           
## [450] "f__Pisorisporiales_fam_Incertae_sedis"       
## [451] "f__Pervetustaceae"                           
## [452] "f__Lopadostomataceae"                        
## [453] "f__Neoschizotheciaceae"                      
## [454] "f__Tubariaceae"                              
## [455] "f__Cyclothyriellaceae"                       
## [456] "f__Microascaceae"                            
## [457] "f__Glomerellales_fam_Incertae_sedis"         
## [458] "f__Chaetosphaeriaceae"                       
## [459] "f__Myrmecridiaceae"                          
## [460] "f__Auriculariaceae"                          
## [461] "f__Wallemiaceae"                             
## [462] "f__Limnoperdaceae"                           
## [463] "f__Pilobolaceae"                             
## [464] "f__Rozellomycota_fam_Incertae_sedis"         
## [465] "f__Glomosporiaceae"                          
## [466] "f__Bloxamiaceae"                             
## [467] "f__Gymnoascaceae"                            
## [468] "f__Teichosporaceae"                          
## [469] "f__Pycnoraceae"                              
## [470] "f__Onygenaceae"                              
## [471] "f__Melampsoraceae"                           
## [472] "f__Gloeophyllaceae"                          
## [473] "f__Juglanconidaceae"                         
## [474] "f__Amphisphaeriales_fam_Incertae_sedis"      
## [475] "f__Schizothyriaceae"                         
## [476] "f__Rhizopogonaceae"                          
## [477] "f__Gyroporaceae"                             
## [478] "f__Cyphellaceae"                             
## [479] "f__Carcinomycetaceae"                        
## [480] "f__Pleuroascaceae"                           
## [481] "f__Entorrhizaceae"                           
## [482] "f__Sphaerobolaceae"                          
## [483] "f__Amanitaceae"                              
## [484] "f__Chionosphaeraceae"                        
## [485] "f__Meripilaceae"                             
## [486] "f__Calosphaeriaceae"                         
## [487] "f__Coryneliaceae"                            
## [488] "f__Mollisiaceae"                             
## [489] "f__Sordariomycetes_fam_Incertae_sedis"       
## [490] "f__Wiesneriomycetaceae"                      
## [491] "f__Umbelopsidaceae"                          
## [492] "f__Minutisphaeraceae"                        
## [493] "f__Diatrypaceae"                             
## [494] "f__Coniochaetaceae"                          
## [495] "f__Tulasnellaceae"                           
## [496] "f__Ceratosphaeriaceae"                       
## [497] "f__Testudinaceae"                            
## [498] "f__Corticiales_fam_Incertae_sedis"           
## [499] "f__Sarcosomataceae"                          
## [500] "f__Sarocladiaceae"                           
## [501] "f__Rhizophydiales_fam_Incertae_sedis"        
## [502] "f__Pichiaceae"                               
## [503] "f__Ramalinaceae"                             
## [504] "f__Clavariaceae"                             
## [505] "f__Sporidiobolales_fam_Incertae_sedis"       
## [506] "f__Neoantennariellaceae"                     
## [507] "f__Agaricostilbomycetes_fam_Incertae_sedis"  
## [508] "f__Neocamarosporiaceae"                      
## [509] "f__Pleurotaceae"                             
## [510] "f__Eremomycetaceae"                          
## [511] "f__Tympanidaceae"                            
## [512] "f__Lentariaceae"                             
## [513] "f__Xenodactylariaceae"                       
## [514] "f__Alphamycetaceae"                          
## [515] "f__Teloschistaceae"                          
## [516] "f__Jianyuniaceae"                            
## [517] "f__Venturiales_fam_Incertae_sedis"           
## [518] "f__GS22_fam_Incertae_sedis"                  
## [519] "f__Mycenaceae"                               
## [520] "f__Lichtheimiaceae"                          
## [521] "f__Septobasidiaceae"                         
## [522] "Unclassified_family"
### SUMMARY ACROSS ALL SAMPLES

mean(rowSums(taxmerge[,c("c__Dothideomycetes","c__Leotiomycetes","c__Sordariomycetes","c__Eurotiomycetes","c__Orbiliomycetes","c__Pezizomycotina_cls_Incertae_sedis","c__Saccharomycetes","c__Lecanoromycetes","c__Pezizomycetes","c__Laboulbeniomycetes","c__Taphrinomycetes","c__Schizosaccharomycetes","c__Candelariomycetes","c__Arthoniomycetes","c__Geoglossomycetes","Unclassified_Ascomycetes")]))
## [1] 69.41205
sd(rowSums(taxmerge[,c("c__Dothideomycetes","c__Leotiomycetes","c__Sordariomycetes","c__Eurotiomycetes","c__Orbiliomycetes","c__Pezizomycotina_cls_Incertae_sedis","c__Saccharomycetes","c__Lecanoromycetes","c__Pezizomycetes","c__Laboulbeniomycetes","c__Taphrinomycetes","c__Schizosaccharomycetes","c__Candelariomycetes","c__Arthoniomycetes","c__Geoglossomycetes","Unclassified_Ascomycetes")]))
## [1] 21.72563
### SUMMARY ACROSS LEAF SAMPLES
###mean/sd percent abundance of Ascomycota in leaf
mean(rowSums(taxmerge[taxmerge$substrate=='L',c("c__Dothideomycetes","c__Leotiomycetes","c__Sordariomycetes","c__Eurotiomycetes","c__Orbiliomycetes","c__Pezizomycotina_cls_Incertae_sedis","c__Saccharomycetes","c__Lecanoromycetes","c__Pezizomycetes","c__Laboulbeniomycetes","c__Taphrinomycetes","c__Schizosaccharomycetes","c__Candelariomycetes","c__Arthoniomycetes","c__Geoglossomycetes","Unclassified_Ascomycetes")]))
## [1] 85.33998
sd(rowSums(taxmerge[taxmerge$substrate=='L',c("c__Dothideomycetes","c__Leotiomycetes","c__Sordariomycetes","c__Eurotiomycetes","c__Orbiliomycetes","c__Pezizomycotina_cls_Incertae_sedis","c__Saccharomycetes","c__Lecanoromycetes","c__Pezizomycetes","c__Laboulbeniomycetes","c__Taphrinomycetes","c__Schizosaccharomycetes","c__Candelariomycetes","c__Arthoniomycetes","c__Geoglossomycetes","Unclassified_Ascomycetes")]))
## [1] 9.380394
######################################################

### SUMMARY ACROSS EPILITHON SAMPLES
###mean/sd percent abundance of Ascomycota in epilithon
mean(rowSums(taxmerge[taxmerge$substrate=='B',c("c__Dothideomycetes","c__Leotiomycetes","c__Sordariomycetes","c__Eurotiomycetes","c__Orbiliomycetes","c__Pezizomycotina_cls_Incertae_sedis","c__Saccharomycetes","c__Lecanoromycetes","c__Pezizomycetes","c__Laboulbeniomycetes","c__Taphrinomycetes","c__Schizosaccharomycetes","c__Candelariomycetes","c__Arthoniomycetes","c__Geoglossomycetes","Unclassified_Ascomycetes")]))
## [1] 76.53626
sd(rowSums(taxmerge[taxmerge$substrate=='B',c("c__Dothideomycetes","c__Leotiomycetes","c__Sordariomycetes","c__Eurotiomycetes","c__Orbiliomycetes","c__Pezizomycotina_cls_Incertae_sedis","c__Saccharomycetes","c__Lecanoromycetes","c__Pezizomycetes","c__Laboulbeniomycetes","c__Taphrinomycetes","c__Schizosaccharomycetes","c__Candelariomycetes","c__Arthoniomycetes","c__Geoglossomycetes","Unclassified_Ascomycetes")]))
## [1] 12.79824
######################################################

### SUMMARY ACROSS SEDIMENT SAMPLES
###mean/sd percent abundance of Ascomycota in sediment
mean(rowSums(taxmerge[taxmerge$substrate=='S',c("c__Dothideomycetes","c__Leotiomycetes","c__Sordariomycetes","c__Eurotiomycetes","c__Orbiliomycetes","c__Pezizomycotina_cls_Incertae_sedis","c__Saccharomycetes","c__Lecanoromycetes","c__Pezizomycetes","c__Laboulbeniomycetes","c__Taphrinomycetes","c__Schizosaccharomycetes","c__Candelariomycetes","c__Arthoniomycetes","c__Geoglossomycetes","Unclassified_Ascomycetes")]))
## [1] 47.87911
sd(rowSums(taxmerge[taxmerge$substrate=='S',c("c__Dothideomycetes","c__Leotiomycetes","c__Sordariomycetes","c__Eurotiomycetes","c__Orbiliomycetes","c__Pezizomycotina_cls_Incertae_sedis","c__Saccharomycetes","c__Lecanoromycetes","c__Pezizomycetes","c__Laboulbeniomycetes","c__Taphrinomycetes","c__Schizosaccharomycetes","c__Candelariomycetes","c__Arthoniomycetes","c__Geoglossomycetes","Unclassified_Ascomycetes")]))
## [1] 18.79491
###non-ascomycetes in sediment
mean(rowSums(taxmerge[taxmerge$substrate=='S',c("p__Basidiomycota","p__Blastocladiomycota","p__Mortierellomycota","p__Kickxellomycota","p__Rozellomycota","p__Aphelidiomycota","p__Basidiobolomycota","p__Chytridiomycota","p__Mucoromycota","p__Calcarisporiellomycota","p__Olpidiomycota","p__Glomeromycota","p__Neocallimastigomycota","p__Entorrhizomycota","Unclassified_Phylum")]))
## [1] 52.12089
sd(rowSums(taxmerge[taxmerge$substrate=='S',c("p__Basidiomycota","p__Blastocladiomycota","p__Mortierellomycota","p__Kickxellomycota","p__Rozellomycota","p__Aphelidiomycota","p__Basidiobolomycota","p__Chytridiomycota","p__Mucoromycota","p__Calcarisporiellomycota","p__Olpidiomycota","p__Glomeromycota","p__Neocallimastigomycota","p__Entorrhizomycota","Unclassified_Phylum")]))
## [1] 18.79491
### basidiomycota in sediment
mean(taxmerge[taxmerge$substrate=='S',c("p__Basidiomycota")])
## [1] 30.31288
sd(taxmerge[taxmerge$substrate=='S',c("p__Basidiomycota")])
## [1] 19.14144
### blastocladiomycota in sediment
mean(taxmerge[taxmerge$substrate=='S',c("p__Blastocladiomycota")])
## [1] 2.66455
sd(taxmerge[taxmerge$substrate=='S',c("p__Blastocladiomycota")])
## [1] 3.661561
### Mortierellomycota in sediment
mean(taxmerge[taxmerge$substrate=='S',c("p__Mortierellomycota")])
## [1] 10.0309
sd(taxmerge[taxmerge$substrate=='S',c("p__Mortierellomycota")])
## [1] 5.926307
### Kickxellomycota in sediment
mean(taxmerge[taxmerge$substrate=='S',c("p__Kickxellomycota")])
## [1] 2.221596
sd(taxmerge[taxmerge$substrate=='S',c("p__Kickxellomycota")])
## [1] 3.543442
### rozellomycota in sediment
mean(taxmerge[taxmerge$substrate=='S',c("p__Rozellomycota")])
## [1] 0.468558
sd(taxmerge[taxmerge$substrate=='S',c("p__Rozellomycota")])
## [1] 0.7883253
### no phylum in sediment
mean(taxmerge[taxmerge$substrate=='S',c("Unclassified_Phylum")])
## [1] 5.826676
sd(taxmerge[taxmerge$substrate=='S',c("Unclassified_Phylum")])
## [1] 4.233832
### trace levels of zoosporic fungi
#mean(taxmerge$p__Neocallimastigomycota)
#sd(taxmerge$p__Neocallimastigomycota)
mean(taxmerge$p__Rozellomycota)
## [1] 0.2039237
sd(taxmerge$p__Rozellomycota)
## [1] 0.5154182
mean(taxmerge$p__Aphelidiomycota)
## [1] 0.4436555
sd(taxmerge$p__Aphelidiomycota)
## [1] 1.953913
mean(taxmerge$p__Basidiobolomycota)
## [1] 0.02245588
sd(taxmerge$p__Basidiobolomycota)
## [1] 0.06423416
mean(taxmerge$p__Chytridiomycota)
## [1] 0.01062103
sd(taxmerge$p__Chytridiomycota)
## [1] 0.0548174
mean(taxmerge$p__Mucoromycota)
## [1] 0.08496821
sd(taxmerge$p__Mucoromycota)
## [1] 0.224308
mean(taxmerge$c__Dothideomycetes)
## [1] 46.82902
sd(taxmerge$c__Dothideomycetes)
## [1] 19.25747
#mean(taxmerge[,97])
#sd(taxmerge[,97])

### identifying sites with neocallimastigomycetes
neocalsites<- taxmerge[taxmerge$p__Neocallimastigomycota>0,]
neocalsites$siteid
## [1] "04M03" "04M04" "04W03"

###Phylum-Class BARPLOT

#Phylum
#Select taxa that make up >90% of the total sequences
phylatrim <- data.frame(major_taxa_proportions_tab[c("p__Basidiomycota","p__Mortierellomycota","p__Blastocladiomycota","p__Aphelidiomycota","p__Kickxellomycota","p__Rozellomycota","Unclassified_Phylum","c__Dothideomycetes","c__Leotiomycetes","c__Sordariomycetes","c__Eurotiomycetes", "Unclassified_Ascomycetes"
                                                     #, "p__Ochrophyta", "p__Oomycota"
                                                     ), ])
#write.csv(phylatrim_t,"/Users/chunk/Documents/DADA2/DADA2_package_test/Kz_Syn_ITS/run_2/outputs/phylatrim.csv")
#write.csv(major_taxa_proportions_tab,"/Users/chunk/Documents/DADA2/DADA2_package_test/Kz_Syn_ITS/majortaxa.csv")
#majortaxa <- read.csv("~/Documents/DADA2/DADA2_package_test/Kz_Syn_ITS/majortaxa.csv", row.names=1)
#View(majortaxa)
#phylatrim <- read.csv("~/Documents/DADA2/DADA2_package_test/Kz_Syn_ITS/phylatrimt.csv", row.names=1)
#View(phylatrim)

#Create an "other" category for the phyla not retained
filtered_proportions <- colSums(major_taxa_proportions_tab) - 
  colSums(phylatrim)
phylatrim <- rbind(phylatrim, "Other"=filtered_proportions)
phylatrim
##                             X01m01_B    X01m01_L   X01m01_S   X01m02_B
## p__Basidiomycota         12.08521098 18.47603441 24.8258910 11.1429742
## p__Mortierellomycota      0.04096682  0.08193363 15.4035231  3.5231463
## p__Blastocladiomycota     0.00000000  0.00000000  2.7447767  0.2867677
## p__Aphelidiomycota       21.63047931  0.12290045  0.0000000  0.6554691
## p__Kickxellomycota        0.00000000  0.04096682  3.0725113  0.0000000
## p__Rozellomycota          0.00000000  0.00000000  0.1638673  0.0000000
## Unclassified_Phylum       6.67759115  0.28676772  3.0725113  1.4748054
## c__Dothideomycetes       28.55387136 30.56124539 36.0507989 22.4088488
## c__Leotiomycetes          0.61450225 37.68947153  2.7038099  1.7206063
## c__Sordariomycetes        1.59770586  8.35723064  4.1786153  2.3760754
## c__Eurotiomycetes        24.17042196  3.80991397  0.3277345 48.2998771
## Unclassified_Ascomycetes  4.38344941  0.08193363  0.7374027  5.8582548
## Other                     0.24580090  0.49160180  6.7185580  2.2531749
##                            X01m02_L   X01m02_S   X01m03_B    X01m03_L
## p__Basidiomycota          7.2920934 28.7587054 18.8857026 24.12945514
## p__Mortierellomycota      0.0000000 13.6829168  3.3592790  0.08193363
## p__Blastocladiomycota     0.0000000 11.3068415  1.9664072  0.00000000
## p__Aphelidiomycota        0.0000000  0.1229005  1.5157722  0.20483408
## p__Kickxellomycota        0.0000000  0.0000000  0.5735354  0.00000000
## p__Rozellomycota          0.0000000  0.2458009  0.6964359  0.00000000
## Unclassified_Phylum       0.1638673  2.5809095 16.8783286  0.69643589
## c__Dothideomycetes       66.4481770 20.9750102 34.0434248 49.40598116
## c__Leotiomycetes          6.8004916 11.8394101  2.4170422 14.91192134
## c__Sordariomycetes       17.7386317  2.7857435  3.8099140  9.91396968
## c__Eurotiomycetes         0.2048341  1.2290045  7.7017616  0.04096682
## Unclassified_Ascomycetes  0.2048341  0.0000000  6.7595248  0.28676772
## Other                     1.1470709  6.4727571  1.3928718  0.32773454
##                            X01m03_S    X01m04_B   X01m04_L   X01m04_S
## p__Basidiomycota         40.5161819 29.74190905 17.0012290 25.8090946
## p__Mortierellomycota      9.4223679  1.72060631  0.2867677 19.3773044
## p__Blastocladiomycota     2.7447767  0.00000000  0.0000000  7.9885293
## p__Aphelidiomycota        0.1229005  0.04096682  0.0000000  2.3351086
## p__Kickxellomycota        2.3351086  0.00000000  0.0000000  3.8099140
## p__Rozellomycota          0.1229005  0.00000000  0.0000000  0.3277345
## Unclassified_Phylum      21.9172470  5.36665301  0.6554691  5.2027857
## c__Dothideomycetes       13.6829168 53.70749693 55.9197050 21.4256452
## c__Leotiomycetes          1.8435068  0.86030315  1.4338386  2.0893077
## c__Sordariomycetes        3.6460467  1.59770586 22.9414175  6.0630889
## c__Eurotiomycetes         1.3519050  0.24580090  0.5325686  0.2048341
## Unclassified_Ascomycetes  0.7783695  5.61245391  0.1638673  1.3928718
## Other                     1.5157722  1.10610406  1.0651372  3.9737812
##                            X01m05_B    X01m05_L    X01m05_S  X01m06_B
## p__Basidiomycota         10.3646047 18.23023351 24.41622286 20.770176
## p__Mortierellomycota      6.9643589  0.32773454 12.20811143  0.000000
## p__Blastocladiomycota     1.1880377  0.28676772  2.25317493  0.000000
## p__Aphelidiomycota        3.4002458  0.04096682  0.16386727  2.458009
## p__Kickxellomycota        0.0000000  0.04096682  2.82671036  4.137649
## p__Rozellomycota          0.0000000  0.00000000  0.08193363  0.000000
## Unclassified_Phylum       5.5714871  0.57353544  5.07988529  7.455961
## c__Dothideomycetes       59.4018845 59.56575174 33.38795576 47.275707
## c__Leotiomycetes          4.6702171  8.35723064  2.33510856  1.392872
## c__Sordariomycetes        3.6460467 11.75747644  8.48013109  4.014748
## c__Eurotiomycetes         0.2048341  0.12290045  0.53256862  7.292093
## Unclassified_Ascomycetes  1.4748054  0.20483408  4.34248259  4.055715
## Other                     3.1134781  0.49160180  3.89184760  1.147071
##                             X01m06_L    X01m06_S    X02m01_L    X02m01_S
## p__Basidiomycota          7.78369521 35.96886522 12.49487915 86.19418271
## p__Mortierellomycota      0.12290045 16.42769357  0.24580090  3.31831217
## p__Blastocladiomycota     0.00000000  0.08193363  0.86030315  0.00000000
## p__Aphelidiomycota        0.00000000  0.08193363  0.00000000  0.00000000
## p__Kickxellomycota        0.00000000  2.08930766  0.08193363  0.04096682
## p__Rozellomycota          0.00000000  0.45063499  0.00000000  0.08193363
## Unclassified_Phylum       0.08193363  5.07988529  1.35190496  3.72798034
## c__Dothideomycetes       42.64645637 20.89307661 58.66448177  3.07251127
## c__Leotiomycetes         45.02253175  4.13764850 11.55264236  1.39287177
## c__Sordariomycetes        2.90864400  8.07046293 13.15034822  1.18803769
## c__Eurotiomycetes         0.28676772  1.55673904  0.24580090  0.12290045
## Unclassified_Ascomycetes  0.12290045  0.16386727  0.00000000  0.00000000
## Other                     1.02417042  4.99795166  1.35190496  0.86030315
##                            X02m02_B    X02m02_L    X02m02_S    X02m03_B
## p__Basidiomycota         15.9770586  8.39819746 79.39369111 14.54321999
## p__Mortierellomycota      0.0000000  0.61450225  4.34248259  0.20483408
## p__Blastocladiomycota     0.4096682  0.53256862  0.98320361  0.04096682
## p__Aphelidiomycota        0.0000000  0.04096682  0.00000000  0.00000000
## p__Kickxellomycota        0.0000000  0.00000000  0.28676772  0.08193363
## p__Rozellomycota          0.0000000  0.00000000  0.08193363  0.00000000
## Unclassified_Phylum       0.7374027  1.06513724  1.47480541  0.94223679
## c__Dothideomycetes       68.5374846 82.75297009  7.04629250 74.47767308
## c__Leotiomycetes          6.8824252  2.45800901  1.67963949  6.26792298
## c__Sordariomycetes        0.4506350  3.11347808  1.76157313  0.49160180
## c__Eurotiomycetes         3.2363785  0.04096682  0.12290045  0.73740270
## Unclassified_Ascomycetes  1.5977059  0.16386727  0.40966817  0.28676772
## Other                     2.1712413  0.81933634  2.41704220  1.92544039
##                             X02m03_L   X02m03_S   X02m04_L    X02m04_S
## p__Basidiomycota         25.89102827 80.6636624  5.0798853 33.67472347
## p__Mortierellomycota      0.53256862  2.9905776  0.1229005 16.71446129
## p__Blastocladiomycota     0.16386727  0.1229005  0.3687014  0.86030315
## p__Aphelidiomycota        0.00000000  0.0000000  0.0000000  0.00000000
## p__Kickxellomycota        0.08193363  0.6145023  0.0000000  1.18803769
## p__Rozellomycota          0.08193363  0.0000000  0.0000000  0.08193363
## Unclassified_Phylum       0.65546907  3.0315444  1.6386727  4.46538304
## c__Dothideomycetes       43.83449406  3.6050799 62.2695617 34.37115936
## c__Leotiomycetes          4.30151577  0.5735354 25.3174928  3.52314625
## c__Sordariomycetes       22.69561655  2.7038099  1.0651372  1.84350676
## c__Eurotiomycetes         0.61450225  0.6554691  0.0000000  0.36870135
## Unclassified_Ascomycetes  0.08193363  0.1638673  0.1229005  0.73740270
## Other                     1.06513724  4.8750512  4.0147481  2.17124129
##                             X02m05_B    X02m05_L   X02m06_B    X02m06_L
## p__Basidiomycota         13.39614912  4.42441622  9.8320361 14.99385498
## p__Mortierellomycota      0.40966817  0.04096682  1.4338386  0.08193363
## p__Blastocladiomycota     0.32773454  0.00000000  0.9832036  0.08193363
## p__Aphelidiomycota        0.45063499  0.00000000  0.1229005  0.00000000
## p__Kickxellomycota        0.00000000  0.00000000  0.2048341  0.00000000
## p__Rozellomycota          0.08193363  0.00000000  0.2458009  0.00000000
## Unclassified_Phylum      29.37320770  0.94223679  6.8824252  1.76157313
## c__Dothideomycetes       40.39328144 85.66161409 63.3756657 52.72429332
## c__Leotiomycetes          2.13027448  4.34248259  6.1040557  5.61245391
## c__Sordariomycetes        1.76157313  3.68701352  7.4559607 16.05899222
## c__Eurotiomycetes         0.00000000  0.32773454  0.2867677  0.36870135
## Unclassified_Ascomycetes 11.34780828  0.32773454  1.6386727  1.02417042
## Other                     0.32773454  0.24580090  1.4338386  7.29209340
##                             X02m06_S    X02m07_B    X02m07_L   X02m07_S
## p__Basidiomycota         21.83531340 10.11880377 21.99918066 46.8660385
## p__Mortierellomycota      8.31626383  0.61450225  0.08193363  1.9664072
## p__Blastocladiomycota     2.78574355  0.04096682  0.00000000  3.1954117
## p__Aphelidiomycota        0.04096682  0.28676772  0.00000000  0.1638673
## p__Kickxellomycota        1.92544039  0.00000000  0.00000000  0.2867677
## p__Rozellomycota          0.53256862  0.40966817  0.00000000  1.5977059
## Unclassified_Phylum       5.28471938 10.24170422  0.69643589  2.6628431
## c__Dothideomycetes       40.14748054 67.34944695 64.76853748 28.9635395
## c__Leotiomycetes          4.01474805  3.64604670  6.02212208  3.1134781
## c__Sordariomycetes        8.97173290  4.01474805  6.14502253  6.7595248
## c__Eurotiomycetes         0.90126997  0.20483408  0.04096682  0.9422368
## Unclassified_Ascomycetes  1.63867268  1.67963949  0.00000000  0.7374027
## Other                     3.60507989  1.39287177  0.24580090  2.7447767
##                            X02m08_L   X02m08_S    X02m09_B    X02m09_L
## p__Basidiomycota         29.6190086 10.0368701 11.22490782  9.54526833
## p__Mortierellomycota      0.0000000  6.2679230  0.61450225  0.08193363
## p__Blastocladiomycota     0.0000000  0.4096682  0.00000000  0.00000000
## p__Aphelidiomycota        0.0000000  0.0000000  0.00000000  0.00000000
## p__Kickxellomycota        0.0000000 21.9991807  0.49160180  0.00000000
## p__Rozellomycota          0.0000000  0.1229005  0.00000000  0.00000000
## Unclassified_Phylum       0.9422368 12.5358460  4.17861532  0.57353544
## c__Dothideomycetes       51.3723884 43.9164277 73.08480131 39.00040967
## c__Leotiomycetes         14.0925850  1.5567390  4.54731667 46.21056944
## c__Sordariomycetes        2.5399426  0.5325686  2.66284310  2.25317493
## c__Eurotiomycetes         0.1229005  1.1470709  0.04096682  0.94223679
## Unclassified_Ascomycetes  0.4096682  0.4916018  1.39287177  1.22900451
## Other                     0.9012700  0.9832036  1.76157313  0.16386727
##                            X02m09_S    X02m10_B    X02m10_L   X02m10_S
## p__Basidiomycota         21.1388775  8.76689881  3.15444490 16.1818927
## p__Mortierellomycota      2.9905776  0.00000000  0.00000000  5.7763212
## p__Blastocladiomycota     7.3330602  0.04096682  0.00000000  0.4916018
## p__Aphelidiomycota        0.0000000  0.00000000  0.00000000  0.7783695
## p__Kickxellomycota        1.5977059  0.00000000  0.00000000  0.5735354
## p__Rozellomycota          0.6964359  0.00000000  0.00000000  0.1229005
## Unclassified_Phylum       6.2269562  1.72060631  0.00000000  2.8267104
## c__Dothideomycetes       35.7640311 77.18148300 31.58541581 40.5981155
## c__Leotiomycetes          4.7931176  8.97173290  8.35723064 21.4666120
## c__Sordariomycetes        4.7931176  0.57353544 56.45227366  7.6607948
## c__Eurotiomycetes         1.4338386  0.65546907  0.04096682  0.4506350
## Unclassified_Ascomycetes  3.6870135  1.02417042  0.08193363  0.6554691
## Other                     9.5452683  1.06513724  0.32773454  2.4170422
##                            X02m11_B    X02m11_S    X04m01_B    X04m01_L
## p__Basidiomycota         11.0200737 10.85620647 14.21548546 15.60835723
## p__Mortierellomycota      0.3687014  7.12822614  0.40966817  0.73740270
## p__Blastocladiomycota     0.0000000  8.07046293  1.67963949  0.20483408
## p__Aphelidiomycota        0.0000000  0.04096682  0.04096682  0.00000000
## p__Kickxellomycota        0.0000000  0.98320361  0.00000000  0.12290045
## p__Rozellomycota          0.0000000  0.04096682  0.24580090  0.08193363
## Unclassified_Phylum       0.1638673  6.51372388  3.19541172  0.86030315
## c__Dothideomycetes       73.3715690 38.95944285 65.17820565 55.10036870
## c__Leotiomycetes          3.8099140  8.72593200 12.12617780  4.91601803
## c__Sordariomycetes        1.3928718 13.96968456  0.53256862 19.90987300
## c__Eurotiomycetes         5.8172880  0.36870135  0.69643589  0.04096682
## Unclassified_Ascomycetes  3.2363785  1.14707087  0.65546907  0.20483408
## Other                     0.8193363  3.19541172  1.02417042  2.21220811
##                            X04m01_S   X04m02_B    X04m02_L   X04m02_S
## p__Basidiomycota         18.2712003 11.4297419  2.82671036 30.7251127
## p__Mortierellomycota      6.8824252  0.5325686  0.12290045 14.8709545
## p__Blastocladiomycota     8.6439984  0.4916018  0.00000000 11.2658746
## p__Aphelidiomycota        0.2458009  0.6145023  0.00000000  0.2458009
## p__Kickxellomycota        0.3277345  0.0000000  0.04096682  1.0241704
## p__Rozellomycota          0.7374027  0.0000000  0.00000000  0.3277345
## Unclassified_Phylum      10.5284719  6.1040557  0.40966817 16.3867268
## c__Dothideomycetes       40.3113478 58.0499795 82.50716919 13.3551823
## c__Leotiomycetes          2.4580090  4.9160180  1.22900451  1.8025399
## c__Sordariomycetes        3.7689472  1.6386727 12.33101188  5.8582548
## c__Eurotiomycetes         0.9422368 13.9696846  0.04096682  0.1229005
## Unclassified_Ascomycetes  2.5399426  1.3928718  0.16386727  2.1302745
## Other                     4.3424826  0.8603032  0.32773454  1.8844736
##                            X04m03_B    X04m03_L    X04m03_S    X04m04_B
## p__Basidiomycota         11.5526424 13.84678410 21.63047931 55.67390414
## p__Mortierellomycota      0.4096682  0.16386727  5.65342073  2.37607538
## p__Blastocladiomycota     0.0000000  0.00000000  3.35927898  0.12290045
## p__Aphelidiomycota        0.0000000  0.00000000  0.08193363  0.61450225
## p__Kickxellomycota        0.4916018  0.00000000  1.76157313  0.08193363
## p__Rozellomycota          0.0000000  0.04096682  0.32773454  0.36870135
## Unclassified_Phylum       3.7689472  1.02417042  6.84145842  5.89922163
## c__Dothideomycetes       45.9238017 67.59524785 31.33961491 29.49610815
## c__Leotiomycetes          3.0315444  6.63662433 13.47808275  1.18803769
## c__Sordariomycetes        2.0073740  3.97378124  6.18598935  1.14707087
## c__Eurotiomycetes        30.6841458  6.06308890  0.65546907  0.00000000
## Unclassified_Ascomycetes  0.8603032  0.00000000  1.55673904  1.06513724
## Other                     1.2699713  0.65546907  7.12822614  1.96640721
##                             X04m04_L    X04m04_S    X04m05_B    X04m05_L
## p__Basidiomycota          4.62925031 80.58172880 10.81523966 17.57476444
## p__Mortierellomycota      0.28676772  6.51372388  2.29414175  0.00000000
## p__Blastocladiomycota     0.00000000  0.00000000  0.08193363  0.00000000
## p__Aphelidiomycota        0.08193363  0.04096682  2.78574355  0.00000000
## p__Kickxellomycota        0.04096682  1.10610406  0.24580090  0.00000000
## p__Rozellomycota          0.04096682  0.45063499  0.00000000  0.00000000
## Unclassified_Phylum       1.59770586  2.00737403 23.39205244  0.45063499
## c__Dothideomycetes       62.84309709  2.94961082 27.20196641 56.32937321
## c__Leotiomycetes         15.77222450  0.61450225  1.59770586 10.89717329
## c__Sordariomycetes       14.25645227  0.49160180  1.02417042 13.64195002
## c__Eurotiomycetes         0.00000000  0.32773454 24.62105694  0.53256862
## Unclassified_Ascomycetes  0.12290045  1.35190496  5.65342073  0.04096682
## Other                     0.32773454  3.56411307  0.28676772  0.53256862
##                            X04m05_S    X04m06_B   X04m06_L    X04m06_S
## p__Basidiomycota         31.2576813 25.23555920  6.8414584 20.31954117
## p__Mortierellomycota      5.4076198  0.36870135  0.0000000  8.11142974
## p__Blastocladiomycota     0.5325686  0.00000000  0.0000000  0.12290045
## p__Aphelidiomycota        0.0000000  2.66284310  0.0000000  0.04096682
## p__Kickxellomycota        1.5977059  0.00000000  0.0000000  1.47480541
## p__Rozellomycota          0.2867677  0.00000000  0.0000000  0.73740270
## Unclassified_Phylum       9.5452683  8.39819746  0.2048341  2.53994265
## c__Dothideomycetes       34.0024580 56.69807456 77.6730848 44.24416223
## c__Leotiomycetes          5.0798853  3.48217943 13.3551823 11.06104056
## c__Sordariomycetes        3.6050799  1.63867268  0.7783695  3.89184760
## c__Eurotiomycetes         1.4748054  0.69643589  0.0000000  0.86030315
## Unclassified_Ascomycetes  0.9832036  0.77836952  0.2867677  1.55673904
## Other                     6.2269562  0.04096682  0.8603032  5.03891848
##                             X04m07_L   X04m07_S   X04m08_L   X04m08_S
## p__Basidiomycota         10.44653830 19.8689062  4.3015158 11.5526424
## p__Mortierellomycota      0.28676772  3.6870135  0.2867677  3.1544449
## p__Blastocladiomycota     0.00000000  5.2437526  0.0000000  0.0000000
## p__Aphelidiomycota        0.00000000  0.8603032  0.3277345  1.1061041
## p__Kickxellomycota        0.00000000  0.0000000  0.0000000  1.4338386
## p__Rozellomycota          0.04096682  0.3277345  0.0000000  0.0000000
## Unclassified_Phylum       0.73740270 11.2658746  1.5977059 10.8562065
## c__Dothideomycetes       83.81810733 46.5792708 45.6780008 52.2326915
## c__Leotiomycetes          3.07251127  3.2363785 42.0319541  3.4821794
## c__Sordariomycetes        0.94223679  1.4748054  1.7206063  4.6702171
## c__Eurotiomycetes         0.45063499  0.2048341  0.0000000  0.4916018
## Unclassified_Ascomycetes  0.00000000  6.3498566  2.7447767  8.9307661
## Other                     0.20483408  0.9012700  1.3109381  2.0893077
##                             X04m09_L  X04m09_S   X04m10_B    X04m10_L
## p__Basidiomycota          9.54526833 14.543220 11.8394101 23.14625154
## p__Mortierellomycota      0.24580090  1.925440  0.4096682  0.08193363
## p__Blastocladiomycota     0.12290045  0.000000  0.0000000  0.00000000
## p__Aphelidiomycota        0.04096682  0.000000  0.0000000  0.00000000
## p__Kickxellomycota        0.00000000  1.188038  0.0000000  0.00000000
## p__Rozellomycota          0.00000000  1.556739  0.2048341  0.20483408
## Unclassified_Phylum       0.86030315  4.956985  1.1470709  0.49160180
## c__Dothideomycetes       43.75256043 55.673904 72.7570668 53.09299467
## c__Leotiomycetes         40.43424826  4.260549  8.9307661 22.04014748
## c__Sordariomycetes        3.64604670  7.251127  0.6145023  0.69643589
## c__Eurotiomycetes         0.00000000  0.450635  2.8267104  0.00000000
## Unclassified_Ascomycetes  1.02417042  4.588283  0.0000000  0.16386727
## Other                     0.32773454  3.605080  1.2699713  0.08193363
##                            X04m10_S    X04m11_B   X04m11_L    X04m11_S
## p__Basidiomycota         53.5436297 11.22490782  3.6460467  9.91396968
## p__Mortierellomycota     15.2396559  0.86030315  0.1638673  8.80786563
## p__Blastocladiomycota     2.7038099  0.04096682  0.0000000  5.69438755
## p__Aphelidiomycota        0.2048341  0.24580090  0.0000000  0.69643589
## p__Kickxellomycota        1.5157722  0.00000000  0.0000000  2.29414175
## p__Rozellomycota          4.9569848  0.24580090  0.0000000  0.08193363
## Unclassified_Phylum       2.5399426  3.76894715  0.2048341  3.11347808
## c__Dothideomycetes        9.3404342 49.36501434 70.5038918 40.47521508
## c__Leotiomycetes          1.7615731  4.79311757 19.3363376  6.88242524
## c__Sordariomycetes        4.5882835  0.20483408  2.9905776 15.15772224
## c__Eurotiomycetes         0.3277345 28.30807046  0.0000000  0.81933634
## Unclassified_Ascomycetes  0.6964359  0.73740270  0.2867677  2.86767718
## Other                     2.5809095  0.20483408  2.8676772  3.19541172
##                             X04m12_B    X04m12_L    X04m12_S   X04m13_B
## p__Basidiomycota         10.07783695  2.53994265 31.21671446  4.5063499
## p__Mortierellomycota      0.98320361  0.20483408  9.01269971  0.0000000
## p__Blastocladiomycota     0.00000000  0.00000000  2.37607538  1.4748054
## p__Aphelidiomycota        0.00000000  0.08193363  0.16386727  0.1638673
## p__Kickxellomycota        0.00000000  0.08193363  0.98320361  0.0000000
## p__Rozellomycota          0.00000000  0.00000000  0.08193363  0.0000000
## Unclassified_Phylum       0.04096682  0.16386727  4.30151577  0.0000000
## c__Dothideomycetes       75.62474396 25.93199508 26.75133142 29.7009422
## c__Leotiomycetes          8.23433019 70.09422368  4.50634986  2.4989758
## c__Sordariomycetes        1.35190496  0.16386727  7.70176157  1.2699713
## c__Eurotiomycetes         0.86030315  0.04096682  0.57353544 57.3945104
## Unclassified_Ascomycetes  2.49897583  0.16386727  5.57148710  1.7615731
## Other                     0.32773454  0.53256862  6.75952478  1.2290045
##                             X04m13_L   X04m13_S   X04t01_B    X04t01_L
## p__Basidiomycota         25.27652601 26.6693978  5.6534207  6.71855797
## p__Mortierellomycota      0.00000000  9.4223679  0.4506350  0.12290045
## p__Blastocladiomycota     0.00000000  0.5325686  0.8603032  2.53994265
## p__Aphelidiomycota        0.00000000  2.8267104  0.0000000  0.00000000
## p__Kickxellomycota        0.00000000  0.3687014  0.0000000  0.00000000
## p__Rozellomycota          0.00000000  0.4096682  0.0000000  0.00000000
## Unclassified_Phylum       0.08193363  4.1376485  2.2531749  0.40966817
## c__Dothideomycetes       34.45309299 35.7230643 47.6853748 42.93322409
## c__Leotiomycetes         38.01720606  7.4149939  2.6628431 33.18312167
## c__Sordariomycetes        1.55673904  5.4895535  2.6628431 13.23228185
## c__Eurotiomycetes         0.04096682  0.1638673 36.6653011  0.08193363
## Unclassified_Ascomycetes  0.00000000  2.7857435  0.4916018  0.45063499
## Other                     0.57353544  4.0557149  0.6145023  0.32773454
##                             X04t01_S    X04t02_B    X04t02_L    X04t02_S
## p__Basidiomycota         22.61368292  8.76689881  3.19541172  8.07046293
## p__Mortierellomycota     10.32363785  0.81933634  0.24580090  1.80253994
## p__Blastocladiomycota     1.39287177  0.04096682  0.04096682  0.12290045
## p__Aphelidiomycota        0.00000000  0.00000000  0.00000000  0.00000000
## p__Kickxellomycota        6.14502253  0.04096682  0.00000000  0.40966817
## p__Rozellomycota          0.08193363  0.04096682  0.04096682  0.04096682
## Unclassified_Phylum       7.25112659  3.23637853  2.41704220  1.22900451
## c__Dothideomycetes       35.14952888 73.00286768 38.46784105 84.22777550
## c__Leotiomycetes          4.17861532  3.60507989 49.20114707  1.67963949
## c__Sordariomycetes        6.47275707  1.88447358  1.51577222  1.10610406
## c__Eurotiomycetes         2.29414175  3.76894715  0.00000000  0.24580090
## Unclassified_Ascomycetes  0.69643589  2.78574355  0.36870135  0.77836952
## Other                     3.40024580  2.00737403  4.50634986  0.28676772
##                             X04w01_B    X04w01_L    X04w01_S   X04w02_B
## p__Basidiomycota         14.13355182 13.35518230 22.69561655  6.1040557
## p__Mortierellomycota      0.16386727  0.00000000  4.99795166  0.0000000
## p__Blastocladiomycota     0.24580090  0.00000000  2.82671036  0.0000000
## p__Aphelidiomycota        0.00000000  0.00000000  0.00000000  0.0000000
## p__Kickxellomycota        0.00000000  0.00000000  0.94223679  0.0000000
## p__Rozellomycota          0.00000000  0.00000000  0.04096682  0.0000000
## Unclassified_Phylum       0.36870135  0.04096682  8.35723064  0.4096682
## c__Dothideomycetes       50.22531749 31.70831626 45.59606719 60.9586235
## c__Leotiomycetes          1.35190496 54.11716510  2.45800901  3.1954117
## c__Sordariomycetes        0.40966817  0.28676772  5.20278574 16.9192954
## c__Eurotiomycetes        32.28185170  0.04096682  1.47480541  6.1859893
## Unclassified_Ascomycetes  0.77836952  0.16386727  0.86030315  0.0000000
## Other                     0.04096682  0.28676772  4.54731667  6.2269562
##                             X04w02_L   X04w02_S  X04w03_B   X04w03_S   X04w04_L
## p__Basidiomycota         20.27857435 25.3174928 20.688243 11.8394101  9.8320361
## p__Mortierellomycota      0.49160180 19.5002048  0.000000  7.9065957  0.2867677
## p__Blastocladiomycota     1.22900451 14.9528882  0.000000  9.5452683  0.0000000
## p__Aphelidiomycota        0.00000000  0.0000000  0.000000  0.0000000  0.0000000
## p__Kickxellomycota        0.00000000  1.9254404  0.000000  1.3109381  0.0000000
## p__Rozellomycota          0.00000000  0.2048341  0.000000  0.2458009  0.0000000
## Unclassified_Phylum       0.61450225  2.4170422  0.000000 11.6755428  0.1638673
## c__Dothideomycetes       52.92912741 25.8090946 54.485866 43.1380582 41.5403523
## c__Leotiomycetes         22.36788202  3.1544449  7.128226  4.8340844 38.4268742
## c__Sordariomycetes        0.81933634  4.1376485  0.000000  5.6124539  8.5620647
## c__Eurotiomycetes         0.04096682  0.6964359 12.863580  0.7783695  0.4916018
## Unclassified_Ascomycetes  0.16386727  0.3687014  3.072511  1.1880377  0.4096682
## Other                     1.06513724  1.5157722  1.761573  1.9254404  0.2867677
##                           X04w04_S    X20m01_L   X20m01_S   X20m02_B
## p__Basidiomycota         30.807046 36.91110201 34.6579271 25.9729619
## p__Mortierellomycota     14.379353  1.92544039 14.4612864  0.5735354
## p__Blastocladiomycota     0.000000  0.00000000  0.1229005  0.0000000
## p__Aphelidiomycota        1.802540  0.00000000  0.0000000  0.4916018
## p__Kickxellomycota        0.000000  0.00000000  4.0147481  0.1638673
## p__Rozellomycota          0.000000  0.04096682  0.7783695  0.0000000
## Unclassified_Phylum       2.007374  0.73740270  3.3592790 11.7574764
## c__Dothideomycetes       27.201966 32.19991807 29.9057763 35.3543630
## c__Leotiomycetes         14.584187 14.05161819  4.0147481  2.7857435
## c__Sordariomycetes        6.063089 13.35518230  4.4653830  0.9012700
## c__Eurotiomycetes         1.515772  0.04096682  1.3109381 19.9918066
## Unclassified_Ascomycetes  1.638673  0.04096682  0.5325686  1.5567390
## Other                     0.000000  0.69643589  2.3760754  0.4506350
##                             X20m02_L   X20m02_S    X20m03_B    X20m03_L
## p__Basidiomycota         43.21999181 34.4940598 10.65137239  4.01474805
## p__Mortierellomycota      0.81933634 20.2785744  0.20483408  0.20483408
## p__Blastocladiomycota     0.00000000  0.0000000  0.00000000  0.00000000
## p__Aphelidiomycota        0.00000000  0.0000000  0.16386727  0.00000000
## p__Kickxellomycota        0.00000000  1.4338386  0.08193363  0.00000000
## p__Rozellomycota          0.00000000  0.2048341  0.08193363  0.00000000
## Unclassified_Phylum       0.81933634  2.7447767  1.96640721  0.04096682
## c__Dothideomycetes       49.40598116 19.7460057 71.52806227 42.15485457
## c__Leotiomycetes          5.20278574  3.5641131  1.31093814 34.86276116
## c__Sordariomycetes        0.16386727  5.2847194  2.58090946 17.08316264
## c__Eurotiomycetes         0.00000000  9.0126997  9.50430152  0.28676772
## Unclassified_Ascomycetes  0.28676772  0.1638673  0.49160180  0.12290045
## Other                     0.08193363  3.0725113  1.43383859  1.22900451
##                             X20m03_S   X20m04_B    X20m04_L    X20m04_S
## p__Basidiomycota         21.87628021 11.5116755 12.61777960 10.28267104
## p__Mortierellomycota     17.00122900  0.3687014  0.08193363 25.15362556
## p__Blastocladiomycota     0.08193363  0.0000000  0.00000000  0.61450225
## p__Aphelidiomycota        0.04096682  0.0000000  0.00000000  0.08193363
## p__Kickxellomycota        2.74477673  0.0000000  0.00000000  6.14502253
## p__Rozellomycota          0.49160180  0.3277345  0.00000000  2.08930766
## Unclassified_Phylum       8.02949611 20.5243753  0.98320361  3.23637853
## c__Dothideomycetes       28.06226956 57.7632118 40.96681688 23.76075379
## c__Leotiomycetes          4.79311757  2.6218763 42.27775502  8.76689881
## c__Sordariomycetes       11.22490782  1.8435068  1.88447358 12.49487915
## c__Eurotiomycetes         1.55673904  0.2458009  0.08193363  1.22900451
## Unclassified_Ascomycetes  0.49160180  3.1134781  0.24580090  0.24580090
## Other                     3.60507989  1.6796395  0.86030315  5.89922163
##                             X20m05_L   X20m05_S     sfm01_B     sfm01_L
## p__Basidiomycota          4.83408439 24.5800901 15.69029086 12.33101188
## p__Mortierellomycota      0.00000000  4.8750512  1.59770586  0.65546907
## p__Blastocladiomycota     0.04096682  1.5567390  0.45063499  0.04096682
## p__Aphelidiomycota        0.00000000  0.1638673  0.36870135  0.00000000
## p__Kickxellomycota        0.00000000 11.9213437  0.04096682  0.00000000
## p__Rozellomycota          0.12290045  0.9422368  0.28676772  0.08193363
## Unclassified_Phylum       0.36870135  4.4653830  4.58828349  0.77836952
## c__Dothideomycetes       65.66980746 40.3113478 66.16140926 36.41950020
## c__Leotiomycetes         19.62310528  3.2773454  4.95698484 32.15895125
## c__Sordariomycetes        5.65342073  4.9160180  1.63867268 16.63252765
## c__Eurotiomycetes         0.16386727  0.7783695  0.28676772  0.00000000
## Unclassified_Ascomycetes  0.86030315  0.6964359  1.76157313  0.12290045
## Other                     2.66284310  1.5157722  2.17124129  0.77836952
##                             sfm01_S     sfm02_B     sfm02_L     sfm02_S
## p__Basidiomycota         29.6599754 20.85210979  3.72798034 52.88816059
## p__Mortierellomycota      9.7910692  2.45800901  0.04096682 18.02539943
## p__Blastocladiomycota     1.3928718  0.04096682  0.00000000  1.02417042
## p__Aphelidiomycota        0.1638673  1.67963949  0.00000000  0.04096682
## p__Kickxellomycota        2.4580090  0.12290045  0.00000000  0.65546907
## p__Rozellomycota          0.4096682  0.20483408  0.00000000  0.24580090
## Unclassified_Phylum       2.7447767  8.27529701  0.77836952  6.39082343
## c__Dothideomycetes       39.6558787 50.18435068 70.09422368  7.21015977
## c__Leotiomycetes          3.6460467  2.29414175 22.98238427  1.22900451
## c__Sordariomycetes        4.3015158  1.26997132  1.51577222  6.80049160
## c__Eurotiomycetes         0.5325686  0.08193363  0.28676772  1.31093814
## Unclassified_Ascomycetes  2.0073740  8.15239656  0.00000000  0.36870135
## Other                     3.2363785  4.38344941  0.57353544  3.80991397
##                             sfm03_B     sfm03_L    sfm04_B     sfm04_L
## p__Basidiomycota         15.6493240  9.87300287  8.0704629 10.44653830
## p__Mortierellomycota      0.6964359  0.08193363  0.1229005  0.45063499
## p__Blastocladiomycota     0.0000000  0.00000000  0.0000000 12.53584596
## p__Aphelidiomycota        0.0000000  0.00000000  0.0000000  0.00000000
## p__Kickxellomycota        0.0000000  0.00000000  0.0000000  0.00000000
## p__Rozellomycota          0.0000000  0.00000000  0.1638673  0.08193363
## Unclassified_Phylum       7.3740270  0.24580090  3.6050799  1.59770586
## c__Dothideomycetes       66.7349447 74.72347399 59.4838181 59.48381811
## c__Leotiomycetes          1.4748054 12.33101188  8.4801311  4.83408439
## c__Sordariomycetes        1.9254404  0.16386727  1.7615731  8.52109791
## c__Eurotiomycetes         0.9422368  0.36870135 16.3047931  0.16386727
## Unclassified_Ascomycetes  4.7931176  0.00000000  0.5735354  0.28676772
## Other                     0.4096682  2.21220811  1.4338386  1.59770586
##                             sfm04_S     sfm05_B    sfm05_L     sfm05_S
## p__Basidiomycota         17.0012290 18.02539943  9.3814011 51.33142155
## p__Mortierellomycota      3.4412126  1.76157313  0.7374027 12.12617780
## p__Blastocladiomycota     0.0000000  0.94223679  1.4748054  0.00000000
## p__Aphelidiomycota        0.2867677  2.49897583  0.6145023  0.40966817
## p__Kickxellomycota        0.1638673  0.04096682  0.0000000  1.96640721
## p__Rozellomycota          0.2867677  0.12290045  0.0000000  0.04096682
## Unclassified_Phylum       5.1208521  6.96435887  0.6554691 13.76485047
## c__Dothideomycetes       61.2863580 56.53420729 72.5931995 11.63457599
## c__Leotiomycetes          3.5231463  2.37607538  8.6439984  2.62187628
## c__Sordariomycetes        3.1954117  4.46538304  4.5063499  3.23637853
## c__Eurotiomycetes         0.3687014  0.08193363  0.1229005  0.00000000
## Unclassified_Ascomycetes  2.9496108  5.73535436  0.3277345  0.16386727
## Other                     2.3760754  0.45063499  0.9422368  2.70380991
##                              sfm06_L     sfm06_S    sfm07_B     sfm07_L
## p__Basidiomycota         14.99385498 30.88897993 15.1167554 16.38672675
## p__Mortierellomycota      0.73740270 12.00327735  2.2122081  0.73740270
## p__Blastocladiomycota     0.69643589  0.65546907  1.1880377  1.22900451
## p__Aphelidiomycota        0.04096682  0.04096682  1.8844736  0.00000000
## p__Kickxellomycota        0.04096682  1.39287177  0.1229005  0.00000000
## p__Rozellomycota          0.04096682  0.20483408  0.2458009  0.04096682
## Unclassified_Phylum       0.90126997  2.17124129  6.8004916  0.69643589
## c__Dothideomycetes       56.20647276 38.71364195 56.0016387 53.50266284
## c__Leotiomycetes         17.00122900  5.48955346  2.3760754 17.45186399
## c__Sordariomycetes        2.78574355  4.01474805  7.5378943  2.41704220
## c__Eurotiomycetes         0.08193363  0.32773454  2.4170422  0.73740270
## Unclassified_Ascomycetes  4.54731667  1.14707087  2.9086440  0.20483408
## Other                     1.92544039  2.94961082  1.1880377  6.59565752
##                              sfm07_S     Sft01_B     Sft01_L     Sft01_S
## p__Basidiomycota         23.76075379 12.90454732 13.10938140 31.38058173
## p__Mortierellomycota     20.72920934  1.59770586  0.45063499 11.71650963
## p__Blastocladiomycota     0.08193363  2.17124129  0.04096682  1.67963949
## p__Aphelidiomycota        0.00000000  0.04096682  0.00000000  0.08193363
## p__Kickxellomycota        0.65546907  0.08193363  0.00000000  1.47480541
## p__Rozellomycota          0.28676772  0.00000000  0.04096682  0.32773454
## Unclassified_Phylum       3.52314625  2.70380991  2.04834084  6.10405571
## c__Dothideomycetes       36.00983204 64.31790250 58.74641540 31.87218353
## c__Leotiomycetes          3.44121262  4.01474805 21.95821385  4.75215076
## c__Sordariomycetes        4.79311757  3.03154445  2.29414175  4.42441622
## c__Eurotiomycetes         1.51577222  3.19541172  0.36870135  0.77836952
## Unclassified_Ascomycetes  0.61450225  0.90126997  0.24580090  1.14707087
## Other                     4.58828349  5.03891848  0.69643589  4.26054896
##                              Sft02_B    Sft02_S
## p__Basidiomycota         11.14297419 13.6419500
## p__Mortierellomycota      0.53256862  7.9475625
## p__Blastocladiomycota     0.28676772  0.0000000
## p__Aphelidiomycota        0.00000000  0.0000000
## p__Kickxellomycota        0.04096682  2.1712413
## p__Rozellomycota          0.08193363  0.5325686
## Unclassified_Phylum       1.76157313  4.3834494
## c__Dothideomycetes       77.42728390 39.5739451
## c__Leotiomycetes          2.37607538  3.8508808
## c__Sordariomycetes        2.29414175  5.5714871
## c__Eurotiomycetes         1.59770586  1.2699713
## Unclassified_Ascomycetes  0.40966817 18.0253994
## Other                     2.04834084  3.0315444
#Add taxa names as a column
phylatrim$Major_Taxa <- row.names(phylatrim)
#transform into long format
phylalong <- gather(phylatrim, Sample, Proportion, -Major_Taxa)
phylalong$Sample <- gsub("X","",phylalong$Sample)
## [1] "substrate" "WetDry"
phylamet<-data.frame("Sample"=row.names(samdftest),
                     "Substrate"=samdftest$substrate,
                     "Wet.Dry"=samdftest$wet_dry,
                     stringsAsFactors=T)
#merge metadata with major taxa data
phylalong <- merge(phylalong, phylamet)
#Summarize by depth and hydration
phyla_summary <- 
  phylalong %>% # the names of the new data frame and the data frame to be summarised
  group_by(Substrate, Wet.Dry, Major_Taxa) %>%   # the grouping variable
  summarise(mean_prop = mean(Proportion))  # calculates the mean of each group
## `summarise()` has grouped output by 'Substrate', 'Wet.Dry'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'Depth', 'Hydration'. You can override using the `.groups` argument.
phyla_summary
## # A tibble: 78 × 4
## # Groups:   Substrate, Wet.Dry [6]
##    Substrate Wet.Dry Major_Taxa               mean_prop
##    <fct>     <fct>   <chr>                        <dbl>
##  1 B         DRY     Other                       0.830 
##  2 B         DRY     Unclassified_Ascomycetes    0.881 
##  3 B         DRY     Unclassified_Phylum         1.15  
##  4 B         DRY     c__Dothideomycetes         49.8   
##  5 B         DRY     c__Eurotiomycetes          34.0   
##  6 B         DRY     c__Leotiomycetes            1.96  
##  7 B         DRY     c__Sordariomycetes          1.73  
##  8 B         DRY     p__Aphelidiomycota          0.0819
##  9 B         DRY     p__Basidiomycota            8.74  
## 10 B         DRY     p__Blastocladiomycota       0.645 
## # ℹ 68 more rows
phyla_summary$Substrate <- factor(phyla_summary$Substrate,
                                 levels=c("B","L","S")) #reorder variables
phyla_summary$Wet.Dry <- factor(phyla_summary$Wet.Dry, levels= c("WET","DRY")) #reorder variables
phyla_summary$Major_Taxa <- factor(phyla_summary$Major_Taxa, levels= rev(c("p__Basidiomycota","p__Mortierellomycota","p__Blastocladiomycota","p__Aphelidiomycota","p__Kickxellomycota","p__Rozellomycota","Unclassified_Phylum","c__Dothideomycetes","c__Leotiomycetes","c__Sordariomycetes","c__Eurotiomycetes", "Unclassified_Ascomycetes", #"p__Ochrophyta", "p__Oomycota",
                                                                           "Other")))
#color palette


sublab<- c("Epilithic biofilms","Leaf litter","Benthic sediment")
names(sublab)<- c("B","L","S")

pal12 <- rev(cols25(n=13)) #set n= to the number of taxa you are plotting
#make stacked bar plot
phylum_bar <- ggplot(phyla_summary, aes(x = Wet.Dry, y = mean_prop, fill = Major_Taxa))+
  geom_bar(stat = "identity", col=I("black")) +
  scale_fill_manual(values=pal12)+
  guides(fill=guide_legend(ncol=1))+
  facet_wrap(~Substrate, labeller = labeller(Substrate=sublab), nrow=1, scales="free_x") +
  labs(x=NULL,y="Relative abundance (%)",
       fill="Major taxa")+
  #scale_facet_discrete(labels=c('B'='Epilithic biofilms', 'L'='Leaf litter', 'S'='Benthic sediment', 'W'='Surface water'))+
  theme(axis.text.x = element_text(angle=60, hjust=1), legend.position = "right")+
  theme(text=element_text(size=18), #change font size of all text
        axis.text=element_text(size=16), #change font size of axis text
        axis.title=element_text(size=16), #change font size of axis titles
        plot.title=element_text(size=16), #change font size of plot title
        legend.text=element_text(size=16), #change font size of legend text
        strip.text.x = element_text(size = 16),
        legend.title=element_text(size=16)) #change font size of legend title  
phylum_bar

#c(180,100) *
#  0.0394 * # convert mm to inch
#  600 # convert to pixels
## [1] 4255.2 2364.0
plotout <- "Phylum Barplot_fungi_WetDry_v1_03082025.tiff"
agg_tiff(filename=plotout, width=4255, height=2364, units="px",
         pointsize=10, res=600, compression="lzw", scaling=0.5)
phylum_bar
invisible(dev.off())
## [1] "substrate" "PRC_WET_GROUP", sites kmeans clustered by annual percent wet (k=3)
phylamet<-data.frame("Sample"=row.names(samdftest),
                     "Substrate"=samdftest$substrate,
                     "Site"=samdftest$siteid,
                     stringsAsFactors=T)
#merge metadata with major taxa data
phylalong <- merge(phylalong, phylamet)
phylamet<-data.frame("Sample"=row.names(samdftest),
                     "Drainage_area"=samdftest$drainage_area,
                     "Annual_Percent_Wet"=samdftest$prc_wet)
#merge metadata with major taxa data
phylalong <- merge(phylalong, phylamet)
#Summarize by depth and hydration
phyla_summary <- 
  phylalong %>% # the names of the new data frame and the data frame to be summarised
  group_by(Substrate, Site, Major_Taxa) %>%   # the grouping variable
  summarise(mean_prop = mean(Proportion), drainage_area = Drainage_area) #%>%
## `summarise()` has grouped output by 'Substrate', 'Site'. You can override using
## the `.groups` argument.
 # summarise(drainage_area = Drainage_area)# calculates the mean of each group
## `summarise()` has grouped output by 'Depth', 'Hydration'. You can override using the `.groups` argument.
phyla_summary
## # A tibble: 1,755 × 5
## # Groups:   Substrate, Site [135]
##    Substrate Site  Major_Taxa               mean_prop drainage_area
##    <fct>     <fct> <chr>                        <dbl>         <dbl>
##  1 B         01M01 Other                        0.246          28.3
##  2 B         01M01 Unclassified_Ascomycetes     4.38           28.3
##  3 B         01M01 Unclassified_Phylum          6.68           28.3
##  4 B         01M01 c__Dothideomycetes          28.6            28.3
##  5 B         01M01 c__Eurotiomycetes           24.2            28.3
##  6 B         01M01 c__Leotiomycetes             0.615          28.3
##  7 B         01M01 c__Sordariomycetes           1.60           28.3
##  8 B         01M01 p__Aphelidiomycota          21.6            28.3
##  9 B         01M01 p__Basidiomycota            12.1            28.3
## 10 B         01M01 p__Blastocladiomycota        0              28.3
## # ℹ 1,745 more rows
phyla_summary$Substrate <- factor(phyla_summary$Substrate,
                                 levels=c("B","L","S")) #reorder variables
phyla_summary$Site <- fct_reorder(phyla_summary$Site, phyla_summary$drainage_area)
  
  #factor(phyla_summary$wet_dist_cluster, levels= c("1","2", "3")) #reorder variables
phyla_summary$Major_Taxa <- factor(phyla_summary$Major_Taxa, levels= rev(c("p__Basidiomycota","p__Mortierellomycota","p__Blastocladiomycota","p__Aphelidiomycota","p__Kickxellomycota","p__Rozellomycota","Unclassified_Phylum","c__Dothideomycetes","c__Leotiomycetes","c__Sordariomycetes","c__Eurotiomycetes", "Unclassified_Ascomycetes", #"p__Ochrophyta", "p__Oomycota",
                                                                           "Other")))
#color palette


sublab<- c("Epilithic biofilms","Leaf litter","Benthic sediment")
names(sublab)<- c("B","L","S")

pal12 <- rev(cols25(n=13)) #set n= to the number of taxa you are plotting
#make stacked bar plot 
phylum_bar <- ggplot(phyla_summary, aes(x = Site, y = mean_prop, fill = Major_Taxa))+
  geom_bar(stat = "identity", col=I("black")) +
  scale_fill_manual(values=pal12)+
  guides(fill=guide_legend(ncol=1))+
  facet_wrap(~Substrate, labeller = labeller(Substrate=sublab), nrow=1, scales="free_x") +
  labs(x="Sites (ordered from lowest to highest drainage area)",y="Relative abundance (%)",
       fill="Major taxa")+
  #scale_facet_discrete(labels=c('B'='Epilithic biofilms', 'L'='Leaf litter', 'S'='Benthic sediment', 'W'='Surface water'))+
  theme(axis.text.x = element_text(angle=60, hjust=1), legend.position = "right")+
  theme(text=element_text(size=20), #change font size of all text
        axis.text.x=element_text(size=7), #change font size of axis text
       # axis.title=element_text(size=16), #change font size of axis titles
        #plot.title=element_text(size=16), #change font size of plot title
        legend.text=element_text(size=16), #change font size of legend text
       # strip.text.x = element_text(size = 10),
        legend.title=element_text(size=16)) #change font size of legend title  
phylum_bar

#c(180,100) *
#  0.0394 * # convert mm to inch
#  600 # convert to pixels
## [1] 4255.2 2364.0
plotout <- "Phylum Barplot_fungi_sites_by_drainage_area_03142025.tiff"
agg_tiff(filename=plotout, width=6000, height=2750, units="px",
         pointsize=10, res=600, compression="lzw", scaling=0.5)
phylum_bar
invisible(dev.off())

Differential abundance analysis via GLLVM (generalized linear latent variable models)

library(stringr)
## making new phyloseq object to play with
pseqtestITS_spp <- pseqtest

### trimming prefixes off taxa 
tax_table(pseqtestITS_spp)[,"Species"] <- sapply(str_replace(tax_table(pseqtestITS_spp)[,"Species"], "s__", ""),`[`, 1)
tax_table(pseqtestITS_spp)[,"Genus"] <- sapply(str_replace(tax_table(pseqtestITS_spp)[,"Genus"], "g__", ""),`[`, 1)
tax_table(pseqtestITS_spp)[,"Family"] <- sapply(str_replace(tax_table(pseqtestITS_spp)[,"Family"], "f__", ""),`[`, 1)
tax_table(pseqtestITS_spp)[,"Order"] <- sapply(str_replace(tax_table(pseqtestITS_spp)[,"Order"], "o__", ""),`[`, 1)
tax_table(pseqtestITS_spp)[,"Class"] <- sapply(str_replace(tax_table(pseqtestITS_spp)[,"Class"], "c__", ""),`[`, 1)
tax_table(pseqtestITS_spp)[,"Phylum"] <- sapply(str_replace(tax_table(pseqtestITS_spp)[,"Phylum"], "p__", ""),`[`, 1)
tax_table(pseqtestITS_spp)[,"Kingdom"] <- sapply(str_replace(tax_table(pseqtestITS_spp)[,"Kingdom"], "k__", ""),`[`, 1)

### Now we want to merge our taxa to the lowest possible taxonomic level (species, or genus, or family, etc.)

### Name NA spp. "sp."
na.sp = !is.na(tax_table(pseqtestITS_spp)[,"Genus"]) & is.na(tax_table(pseqtestITS_spp)[,"Species"])
tax_table(pseqtestITS_spp)[na.sp][,"Species"] <- "sp."
### good

### Now, make "Species" <--- "Genus species"
# Genus and Species is not NA
no.na <- !is.na(tax_table(pseqtestITS_spp)[,"Genus"]) & !is.na(tax_table(pseqtestITS_spp)[,"Species"])
# Replace Species with full name
tax_table(pseqtestITS_spp)[no.na][,"Species"] <- paste(tax_table(pseqtestITS_spp)[no.na][,"Genus"], tax_table(pseqtestITS_spp)[no.na][,"Species"])

### Now, if genus and species are NA, how to name it for the taxonomic ranking?
View(tax_table(pseqtestITS_spp))

### agglomerate counts by pseudospecies
spp_counts_tab <- otu_table(tax_glom(pseqtestITS_spp, taxrank = "Species"), taxa_are_rows = FALSE)
spp_counts_tab <- t(spp_counts_tab)
#make vector of species names to set as row names
spp_tax_vec <- as.vector(tax_table(tax_glom(pseqtestITS_spp, taxrank="Species"))[,7]) 
rownames(spp_counts_tab) <- as.vector(spp_tax_vec)
#spp_counts_tab
#write.csv(spp_counts_tab, 'spp_counts_rar.csv')

asv_counts <- pseqtestITS_spp@otu_table
#determine the number of unclassified seqs at the species level
unclassified_spp_counts <- colSums(t(asv_counts)) - colSums(spp_counts_tab)
#Add a row of "unclassified" to the species count table
species_and_unidentified_counts_tab <- rbind(spp_counts_tab, "Unclassified_species"=unclassified_spp_counts)

## test all counts are accounted for
identical(colSums(species_and_unidentified_counts_tab), rowSums(asv_counts))
## [1] TRUE
## convert counts to percent abundance:
#species_proportions <- apply(species_and_unidentified_counts_tab, 2, function(x) x/sum(x)*100)

#Merge with metadata
species_merge <- merge(t(species_and_unidentified_counts_tab), samdftest,
                  by="row.names", all=TRUE)
rownames(species_merge) <- species_merge[,1]
species_merge <- species_merge[,-1]

#species_merge <- merge(species_merge, alpha[,94:102],
#                  by="row.names", all=TRUE)
#rownames(species_merge) <- species_merge[,1]
#species_merge <- species_merge[,-1]

write.csv(species_merge, "KzSyn_ITS_pseudospeciescountsmerge_03082025.csv")

gglvm of top leaf taxa

library(mvabund)
library(gllvm)
## Loading required package: TMB
## 
## Attaching package: 'gllvm'
## The following object is masked from 'package:mvabund':
## 
##     coefplot
## The following object is masked from 'package:vegan':
## 
##     ordiplot
## The following object is masked from 'package:stats':
## 
##     simulate
library(tidyverse)

species_merge$annual_percent_wet<- species_merge$prc_wet

sppmerge_L<- species_merge[species_merge$substrate=='L',]
sppmerge_L<- sppmerge_L[!is.na(sppmerge_L$alpha.cent.wt),]
gn<- nrow(species_and_unidentified_counts_tab)
gn
## [1] 1660
spptemp_L<- sppmerge_L[,1:gn]
spptemp_L<-spptemp_L[,colSums(spptemp_L)>0]
#Reorder data table from most abundant to least abundant
spptemp_L <- spptemp_L[,order(colSums(-spptemp_L,na.rm=TRUE))]
spptemp_L <- spptemp_L[,apply(spptemp_L,2,function(x) sum(x > 0))>1]


sppmerge_L <- merge(spptemp_L, samdftest,
                  by="row.names", all=FALSE)
rownames(sppmerge_L) <- sppmerge_L[,1]
sppmerge_L <- sppmerge_L[,-1]
sppmerge_L<- sppmerge_L[,colnames(sppmerge_L)!="Unclassified_species"]
sppmerge_L$annual_percent_wet<- sppmerge_L$prc_wet
#detach("package:linkET", unload=TRUE)
#sppmerge_L$percentwet_11month<- sppmerge_L$percentwet_bonus
L_abun<-sppmerge_L[,1:40]
X <- as.matrix(sppmerge_L[,c("annual_percent_wet","alpha.cent.wt","tempC_mean","burn_interval")])
y<-as.matrix(as.tibble(L_abun))
## Warning: `as.tibble()` was deprecated in tibble 2.0.0.
## ℹ Please use `as_tibble()` instead.
## ℹ The signature and semantics have changed, see `?as_tibble`.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
gllvm(y, family = "poisson") 
## Warning in matrix(fa$scores[, 1:num.lv], n, num.lv): data length [82] is not a
## sub-multiple or multiple of the number of rows [40]
## Call: 
## gllvm(y = y, family = "poisson")
## family: 
## [1] "poisson"
## method: 
## [1] "VA"
## 
## log-likelihood:  -37631.93 
## Residual degrees of freedom:  1481 
## AIC:  75501.87 
## AICc:  75521.17 
## BIC:  76141.82
gllvm(y, family = "negative.binomial") 
## Warning in matrix(fa$scores[, 1:num.lv], n, num.lv): data length [82] is not a
## sub-multiple or multiple of the number of rows [40]
## Call: 
## gllvm(y = y, family = "negative.binomial")
## family: 
## [1] "negative.binomial"
## method: 
## [1] "VA"
## 
## log-likelihood:  -5445.994 
## Residual degrees of freedom:  1441 
## AIC:  11209.99 
## AICc:  11245.32 
## BIC:  12065.05
###
gllvm(y, X, family = "negative.binomial", num.lv = 1,
                 formula = ~ alpha.cent.wt+annual_percent_wet
                 , seed = 1995)
## Warning in matrix(fa$scores[, 1:num.lv], n, num.lv): data length [41] is not a
## sub-multiple or multiple of the number of rows [40]
## Call: 
## gllvm(y = y, X = X, formula = ~alpha.cent.wt + annual_percent_wet, 
##     family = "negative.binomial", num.lv = 1, seed = 1995)
## family: 
## [1] "negative.binomial"
## method: 
## [1] "VA"
## 
## log-likelihood:  -5443.119 
## Residual degrees of freedom:  1400 
## AIC:  11286.24 
## AICc:  11343.71 
## BIC:  12361.79
#fit_ord<- gllvm(y, family = "negative.binomial")
#ordiplot(fit_ord, biplot=TRUE, ind.spp=14)

fit_env <- gllvm(y, X, family = "negative.binomial", num.lv = 1,
                 formula = ~ alpha.cent.wt+annual_percent_wet
                 , seed = 1995)
## Warning in matrix(fa$scores[, 1:num.lv], n, num.lv): data length [41] is not a
## sub-multiple or multiple of the number of rows [40]
coefplot(fit_env, cex.ylab = 0.7, mar = c(4, 9, 2, 1), mfrow=c(1,1))

pdf("Pseudospeciesplot_L_03.15.2025.pdf", 
    )
coefplot(fit_env, cex.ylab = 0.7, mar = c(4, 12, 2, 1), mfrow=c(1,1))
dev.off()
## quartz_off_screen 
##                 2
sppmerge_B<- species_merge[species_merge$substrate=='B',]
sppmerge_B<- sppmerge_B[!is.na(sppmerge_B$alpha.cent.wt),]
gn<- nrow(species_and_unidentified_counts_tab)
gn
## [1] 1660
spptemp_B<- sppmerge_B[,1:gn]
spptemp_B<-spptemp_B[,colSums(spptemp_B)>0]
#Reorder data table from most abundant to least abundant
spptemp_B <- spptemp_B[,order(colSums(-spptemp_B,na.rm=TRUE))]
spptemp_B <- spptemp_B[,apply(spptemp_B,2,function(x) sum(x > 0))>1]


sppmerge_B <- merge(spptemp_B, samdftest,
                  by="row.names", all=FALSE)
rownames(sppmerge_B) <- sppmerge_B[,1]
sppmerge_B <- sppmerge_B[,-1]
sppmerge_B<- sppmerge_B[,colnames(sppmerge_B)!="Unclassified_species"]

sppmerge_B$annual_percent_wet<- sppmerge_B$prc_wet

B_abun<-sppmerge_B[,1:40]
X <- scale(as.matrix(sppmerge_B[,c("alpha.cent.wt","annual_percent_wet","tempC_mean","burn_interval","canopy_cover_percent"
                                   )]))
y<-as.matrix(as.tibble(B_abun))

gllvm(y, family = "poisson")
## Call: 
## gllvm(y = y, family = "poisson")
## family: 
## [1] "poisson"
## method: 
## [1] "VA"
## 
## log-likelihood:  -17071.4 
## Residual degrees of freedom:  1241 
## AIC:  34380.8 
## AICc:  34403.83 
## BIC:  35001.41
gllvm(y, family = "negative.binomial")
## Call: 
## gllvm(y = y, family = "negative.binomial")
## family: 
## [1] "negative.binomial"
## method: 
## [1] "VA"
## 
## log-likelihood:  -4849.454 
## Residual degrees of freedom:  1201 
## AIC:  10016.91 
## AICc:  10059.31 
## BIC:  10846.13
gllvm(y, X, family = "negative.binomial", num.lv = 1,
                 formula = ~ alpha.cent.wt+annual_percent_wet
                 , seed = 1995)
## Call: 
## gllvm(y = y, X = X, formula = ~alpha.cent.wt + annual_percent_wet, 
##     family = "negative.binomial", num.lv = 1, seed = 1995)
## family: 
## [1] "negative.binomial"
## method: 
## [1] "VA"
## 
## log-likelihood:  -4862.078 
## Residual degrees of freedom:  1160 
## AIC:  10124.16 
## AICc:  10193.53 
## BIC:  11167.2
fit_env <- gllvm(y, X, family = "negative.binomial", num.lv = 1,
                 formula = ~ alpha.cent.wt+annual_percent_wet
                 , seed = 1995)
coefplot(fit_env, cex.ylab = 0.7, mar = c(4, 9, 2, 1), mfrow=c(1,1))

pdf("Pseudospeciesplot_B_03.15.2025.pdf", 
    )
coefplot(fit_env, cex.ylab = 0.7, mar = c(4, 12, 2, 1), mfrow=c(1,1))
dev.off()
## quartz_off_screen 
##                 2
sppmerge_S<- species_merge[species_merge$substrate=='S',]
sppmerge_S<- sppmerge_S[!is.na(sppmerge_S$alpha.cent.wt),]
gn<- nrow(species_and_unidentified_counts_tab)
gn
## [1] 1660
spptemp_S<- sppmerge_S[,1:gn]
spptemp_S<-spptemp_S[,colSums(spptemp_S)>0]
#Reorder data table from most abundant to least abundant
spptemp_S <- spptemp_S[,order(colSums(-spptemp_S,na.rm=TRUE))]
spptemp_S <- spptemp_S[,apply(spptemp_S,2,function(x) sum(x > 0))>1]


sppmerge_S <- merge(spptemp_S, samdftest,
                  by="row.names", all=FALSE)
rownames(sppmerge_S) <- sppmerge_S[,1]
sppmerge_S <- sppmerge_S[,-1]
sppmerge_S<- sppmerge_S[,colnames(sppmerge_S)!="Unclassified_species"]
sppmerge_S$annual_percent_wet<- sppmerge_S$prc_wet

S_abun<-sppmerge_S[,1:40]
X <- as.matrix(sppmerge_S[,c("annual_percent_wet","alpha.cent.wt","tempC_mean","B_Chl.a_ug_per_cm2")])
y<-as.matrix(as.tibble(S_abun))

gllvm(y, family = "poisson")
## Warning in matrix(fa$scores[, 1:num.lv], n, num.lv): data length [82] is not a
## sub-multiple or multiple of the number of rows [40]
## Call: 
## gllvm(y = y, family = "poisson")
## family: 
## [1] "poisson"
## method: 
## [1] "VA"
## 
## log-likelihood:  -25072.04 
## Residual degrees of freedom:  1481 
## AIC:  50382.08 
## AICc:  50401.37 
## BIC:  51022.03
gllvm(y, family = "negative.binomial")
## Warning in matrix(fa$scores[, 1:num.lv], n, num.lv): data length [82] is not a
## sub-multiple or multiple of the number of rows [40]
## Call: 
## gllvm(y = y, family = "negative.binomial")
## family: 
## [1] "negative.binomial"
## method: 
## [1] "VA"
## 
## log-likelihood:  -5468.074 
## Residual degrees of freedom:  1441 
## AIC:  11254.15 
## AICc:  11289.48 
## BIC:  12109.21
fit_ord<- gllvm(y, family = "negative.binomial")
## Warning in matrix(fa$scores[, 1:num.lv], n, num.lv): data length [82] is not a
## sub-multiple or multiple of the number of rows [40]
ordiplot(fit_ord, biplot=TRUE, ind.spp=14)

gllvm(y, X, family = "negative.binomial", num.lv = 1,
                 formula = ~ alpha.cent.wt+annual_percent_wet
                 , seed = 1234)
## Warning in matrix(fa$scores[, 1:num.lv], n, num.lv): data length [41] is not a
## sub-multiple or multiple of the number of rows [40]
## Call: 
## gllvm(y = y, X = X, formula = ~alpha.cent.wt + annual_percent_wet, 
##     family = "negative.binomial", num.lv = 1, seed = 1234)
## family: 
## [1] "negative.binomial"
## method: 
## [1] "VA"
## 
## log-likelihood:  -5453.458 
## Residual degrees of freedom:  1400 
## AIC:  11306.92 
## AICc:  11364.39 
## BIC:  12382.47
fit_env <- gllvm(y, X, family = "negative.binomial", num.lv = 1,
                 formula = ~ alpha.cent.wt+annual_percent_wet
                 , seed = 1234)
## Warning in matrix(fa$scores[, 1:num.lv], n, num.lv): data length [41] is not a
## sub-multiple or multiple of the number of rows [40]
coefplot(fit_env, cex.ylab = 0.7, mar = c(4, 9, 2, 1), mfrow=c(1,1))

pdf("Pseudospeciesplot_S_03.15.2025.pdf", 
    )
coefplot(fit_env, cex.ylab = 0.7, mar = c(4, 12, 2, 1), mfrow=c(1,1))
dev.off()
## quartz_off_screen 
##                 2
# TAXONOMIC COMPOSITION: Genus level

#setwd("/Users/chunk/Documents/DADA2/DADA2_package_test/Kz_Syn_ITS/run_2/outputs")
#make taxonomy object by genus
gen_counts_tab <- otu_table(tax_glom(pseqtest, taxrank = "Genus"), taxa_are_rows = FALSE)
gen_counts_tab <- t(gen_counts_tab)
#make vector of genus names to set as row names
gen_tax_vec <- as.vector(tax_table(tax_glom(pseqtest, taxrank="Genus"))[,6]) 
rownames(gen_counts_tab) <- as.vector(gen_tax_vec)
#gen_counts_tab
#write.csv(gen_counts_tab, 'gen_counts_rar.csv')

asv_counts <- pseqtest@otu_table
#determine the number of unclassified seqs at the genus level
unclassified_gen_counts <- colSums(t(asv_counts)) - colSums(gen_counts_tab)
#Add a row of "unclassified" to the genus count table
genus_and_unidentified_counts_tab <- rbind(gen_counts_tab, "Unclassified_genus"=unclassified_gen_counts)

## test all counts are accounted for
identical(colSums(genus_and_unidentified_counts_tab), rowSums(asv_counts))
## [1] TRUE
## convert counts to percent abundance:
genus_proportions <- apply(genus_and_unidentified_counts_tab, 2, function(x) x/sum(x)*100)

#Merge metadata
#phy_and_fam <- merge(t(major_taxa_counts_tab), t(family_and_unidentified_counts_tab),
#                  by="row.names", all=TRUE)
genus_merge <- merge(t(genus_proportions), samdftest,
                  by="row.names", all=TRUE)
rownames(genus_merge) <- genus_merge[,1]
genus_merge <- genus_merge[,-1]
genus_merge <- merge(genus_merge, alpha[,94:103],
                  by="row.names", all=TRUE)
write.csv(genus_merge, "1216R_03.08.2025_genusmerge.csv")

Supplementary table: top ten families by substrate

top 20 family

fam<-t(family_proportions_tab)
#fam <- fam[,-1]
#rownames(phyfam) <- phy_and_fam[,1]
#Merge metadata, phylum, and family abundances
#phy_and_fam <- merge(t(major_taxa_counts_tab), t(family_and_unidentified_counts_tab),
#                  by="row.names", all=TRUE)
fam_merge <- merge(samdftest, fam,
                  by="row.names", all=TRUE)
rownames(fam_merge) <- fam_merge[,1]
fam_merge <- fam_merge[,-1]

### Just checking this out
### "f__Pleosporaceae" in epilithon
mean(fam_merge[fam_merge$substrate=='B',"f__Pleosporaceae"])
## [1] 7.477468
sd(fam_merge[fam_merge$substrate=='B',"f__Pleosporaceae"])
## [1] 5.86229
### "f__Pleosporaceae" in leaf
mean(fam_merge[fam_merge$substrate=='L',"f__Pleosporaceae"])
## [1] 12.23688
sd(fam_merge[fam_merge$substrate=='L',"f__Pleosporaceae"])
## [1] 8.771812
### "f__Pleosporaceae" in sediment
mean(fam_merge[fam_merge$substrate=='S',"f__Pleosporaceae"])
## [1] 4.648027
sd(fam_merge[fam_merge$substrate=='S',"f__Pleosporaceae"])
## [1] 3.735487

Now, to generate tables with mean percent abundance and standard deviation for the top 20 families and genera in each substrate, we’ll want to 1) seperate the datasets by substrate, 2) sort the families by average percent abuundance by substrate, and 3) then generate a table with means and st.dev. for each of the top 20.

##Family, biofilm

fam_merge_B <- fam_merge[fam_merge$substrate=='B',]
fammertemp<- fam_merge_B[,96:ncol(fam_merge_B)]
colnames(fammertemp) <- sapply(str_replace(colnames(fammertemp), "f__", ""),`[`, 1)

#Reorder from most abundant to least abundant
fammertemp <- fammertemp[,order(colSums(-fammertemp,na.rm=TRUE))]
fammertemp<- fammertemp[,colnames(fammertemp)!="Unclassified_family"]
fammertemp <-fammertemp[,1:20]

fam_long_B <- gather(fammertemp, key = "Family", value = "Percent_Abundance")
fam_long_B$Family <- factor(fam_long_B$Family, levels = names(sort(colMeans(fammertemp), decreasing = TRUE)))
#fammertemp$fam<-row.names(fammertemp)
#fammertemp$fam <- factor(fammertemp$fam, levels = fammertemp$fam[order(fammertemp$Mean_percent_abundance, decreasing = TRUE)])

topfam_box_B<- ggplot(fam_long_B, aes(x=Family, y=Percent_Abundance))+
  geom_boxplot()+#fill = "skyblue", color = "black") +
  labs(y = "Percent Abundance", title = "Epilithic biofilms") +
  theme_minimal() +
    scale_y_continuous(labels = scales::percent_format(scale = 1))+
  theme(axis.text.x = element_text(angle = 60, hjust = 1))  
topfam_box_B

#mean percent abundance for each family
Mean_percent_abundance<-colMeans(fammertemp)
St.Dev<- sapply(fammertemp, sd)
name_rab<- colnames(fammertemp)

### Table of family mean percent abundance & st. deviation
topfam_table_B<- data.frame(#name_rab,
  Mean_percent_abundance,St.Dev)
#topfam_table_B<-topfam_table_B[topfam_table_B$Mean_percent_abundance>0,]
topfam_table_B
##                                    Mean_percent_abundance    St.Dev
## Phaeosphaeriaceae                              12.7253175  7.216881
## Mycosphaerellaceae                             10.1577222 13.478017
## Verrucariaceae                                  7.7345350 12.559767
## Cucurbitariaceae                                7.5634986  6.671809
## Pleosporaceae                                   7.4774683  5.862290
## Didymosphaeriaceae                              4.4285129  3.167097
## Didymellaceae                                   4.0680049  2.323612
## Phallaceae                                      1.9950840  1.872980
## Trichomeriaceae                                 1.5546907  2.577346
## Sebacinaceae                                    1.4440803  2.150855
## Cladosporiaceae                                 1.3303974  1.554360
## Helotiales_fam_Incertae_sedis                   1.2832855  1.671701
## Thelephoraceae                                  1.2822614  5.701749
## Bulleribasidiaceae                              1.2054486  1.600488
## Psathyrellaceae                                 1.1317083  1.369086
## Helotiaceae                                     1.0999590  1.122404
## Saccotheciaceae                                 1.0692339  5.037862
## Mortierellaceae                                 1.0170012  1.314377
## Aphelidiomycota_fam_Incertae_sedis              1.0159771  3.273406
## Dictyosporiaceae                                0.8582548  4.335758

##Family, leaf

fam_merge_L <- fam_merge[fam_merge$substrate=='L',]
fammertemp<- fam_merge_L[,96:ncol(fam_merge_L)]
colnames(fammertemp) <- sapply(str_replace(colnames(fammertemp), "f__", ""),`[`, 1)

#Reorder from most abundant to least abundant
fammertemp <- fammertemp[,order(colSums(-fammertemp,na.rm=TRUE))]
fammertemp<- fammertemp[,colnames(fammertemp)!="Unclassified_family"]
fammertemp <-fammertemp[,1:20]

fam_long_L <- gather(fammertemp, key = "Family", value = "Percent_Abundance")
fam_long_L$Family <- factor(fam_long_L$Family, levels = names(sort(colMeans(fammertemp), decreasing = TRUE)))
#fammertemp$fam<-row.names(fammertemp)
#fammertemp$fam <- factor(fammertemp$fam, levels = fammertemp$fam[order(fammertemp$Mean_percent_abundance, decreasing = TRUE)])

topfam_box_L<- ggplot(fam_long_L, aes(x=Family, y=Percent_Abundance))+
  geom_boxplot()+#fill = "skyblue", color = "black") +
  labs(y = "Percent Abundance", title = "Leaf litter") +
  theme_minimal() +
  scale_y_continuous(labels = scales::percent_format(scale = 1))+
  theme(axis.text.x = element_text(angle = 60, hjust = 1))  
topfam_box_L

#mean percent abundance for each family
Mean_percent_abundance<-colMeans(fammertemp)
St.Dev<- sapply(fammertemp, sd)
name_rab<- colnames(fammertemp)

### Table of family mean percent abundance & st. deviation
topfam_table_L<- data.frame(#name_rab,
  Mean_percent_abundance,St.Dev)
#topfam_table_L<-topfam_table_L[topfam_table_L$Mean_percent_abundance>0,]
topfam_table_L
##                               Mean_percent_abundance    St.Dev
## Phaeosphaeriaceae                          15.254474 12.796437
## Pleosporaceae                              12.236875  8.771812
## Helotiaceae                                 6.689794 12.110203
## Helotiales_fam_Incertae_sedis               5.913168  8.102259
## Mycosphaerellaceae                          5.769348  6.989446
## Cladosporiaceae                             4.023464  4.066208
## Gnomoniaceae                                3.221561  8.767841
## Didymellaceae                               2.607930  4.099595
## Cucurbitariaceae                            2.466725  2.178688
## Sporocadaceae                               1.887088  3.348231
## Sebacinaceae                                1.861811  2.929838
## Venturiaceae                                1.854838  4.502127
## Hyaloscyphaceae                             1.674410  3.591256
## Cylindrosympodiaceae                        1.316168  2.284686
## Didymosphaeriaceae                          1.283046  1.321612
## Calloriaceae                                1.241207  2.047502
## Filobasidiaceae                             1.236849  4.964168
## Bulleribasidiaceae                          1.182808  1.368445
## Leptosphaeriaceae                           1.113949  1.430365
## Helicogoniaceae                             1.106976  4.134265

##Family, sediment

fam_merge_S <- fam_merge[fam_merge$substrate=='S',]
fammertemp<- fam_merge_S[,96:ncol(fam_merge_S)]
colnames(fammertemp) <- sapply(str_replace(colnames(fammertemp), "f__", ""),`[`, 1)

#Reorder from most abundant to least abundant
fammertemp <- fammertemp[,order(colSums(-fammertemp,na.rm=TRUE))]
fammertemp<- fammertemp[,colnames(fammertemp)!="Unclassified_family"]
fammertemp <-fammertemp[,1:20]

fam_long_S <- gather(fammertemp, key = "Family", value = "Percent_Abundance")
fam_long_S$Family <- factor(fam_long_S$Family, levels = names(sort(colMeans(fammertemp), decreasing = TRUE)))
#fammertemp$fam<-row.names(fammertemp)
#fammertemp$fam <- factor(fammertemp$fam, levels = fammertemp$fam[order(fammertemp$Mean_percent_abundance, decreasing = TRUE)])

topfam_box_S<- ggplot(fam_long_S, aes(x=Family, y=Percent_Abundance))+
  geom_boxplot()+#fill = "skyblue", color = "black") +
  labs(y = "Percent Abundance", title = "Benthic sediment") +
  theme_minimal() +
  scale_y_continuous(labels = scales::percent_format(scale = 1))+
  theme(axis.text.x = element_text(angle = 60, hjust = 1))  
topfam_box_S

#mean percent abundance for each family
Mean_percent_abundance<-colMeans(fammertemp)
St.Dev<- sapply(fammertemp, sd)
name_rab<- colnames(fammertemp)

### Table of family mean percent abundance & st. deviation
topfam_table_S<- data.frame(#name_rab,
  Mean_percent_abundance,St.Dev)
#topfam_table_S<-topfam_table_S[topfam_table_S$Mean_percent_abundance>0,]
topfam_table_S
##                                    Mean_percent_abundance    St.Dev
## Mortierellaceae                                 9.4872320  5.647808
## Phaeosphaeriaceae                               7.9441486  4.481932
## Inocybaceae                                     6.8354841 15.921481
## Cucurbitariaceae                                6.7825686  8.082685
## Phallaceae                                      6.0289499  5.114020
## Pleosporaceae                                   4.6480268  3.735487
## Didymosphaeriaceae                              3.7441964  2.685174
## Thelephoraceae                                  2.4878807  4.648389
## Blastocladiales_fam_Incertae_sedis              2.2702444  3.445328
## Kickxellomycota_fam_Incertae_sedis              2.1806295  3.548990
## Didymellaceae                                   1.9945719  1.506620
## Nectriaceae                                     1.8588693  1.600924
## Psathyrellaceae                                 1.5089444  1.970585
## Sporormiaceae                                   1.4167691  1.279728
## Basidiomycota_fam_Incertae_sedis                1.3886044  2.332366
## Helotiaceae                                     1.3280076  1.431529
## Sebacinaceae                                    1.2025468  2.591431
## Lycoperdaceae                                   1.1786495  1.516167
## Thelebolaceae                                   0.8952956  2.479718
## Helotiales_fam_Incertae_sedis                   0.7979995  1.318732

top genera box plots

gn<- nrow(genus_and_unidentified_counts_tab)+1
library(stringr)

### leaf genera proportions
genmerge_L<- genus_merge[genus_merge$substrate=='L',]
gentemp_L<- genmerge_L[,1:gn]
colnames(gentemp_L) <- sapply(str_replace(colnames(gentemp_L), "g__", ""),`[`, 1)
#colnames(gentemp_L)
rownames(gentemp_L) <- gentemp_L[,1]
gentemp_L <- gentemp_L[,-1]

#Reorder data table from most abundant to least abundant
gentemp_L <- gentemp_L[,order(colSums(-gentemp_L,na.rm=TRUE))]

### Epilithon genera proportions
### arranging top genera counts
genmerge_B<- genus_merge[genus_merge$substrate=='B',]
gentemp_B<- genmerge_B[,1:gn]
colnames(gentemp_B) <- sapply(str_replace(colnames(gentemp_B), "g__", ""),`[`, 1)
#colnames(gentemp_B)
rownames(gentemp_B) <- gentemp_B[,1]
gentemp_B <- gentemp_B[,-1]

#Reorder data table from most abundant to least abundant
gentemp_B <- gentemp_B[,order(colSums(-gentemp_B,na.rm=TRUE))]

### Sediment genera proportions
genmerge_S<- genus_merge[genus_merge$substrate=='S',]
gentemp_S<- genmerge_S[,1:gn]
colnames(gentemp_S) <- sapply(str_replace(colnames(gentemp_S), "g__", ""),`[`, 1)
#colnames(gentemp_S)
rownames(gentemp_S) <- gentemp_S[,1]
gentemp_S <- gentemp_S[,-1]

#Reorder data table from most abundant to least abundant
gentemp_S <- gentemp_S[,order(colSums(-gentemp_S,na.rm=TRUE))]

##genus, biofilm

gentemp_B<- gentemp_B[,colnames(gentemp_B)!="Unclassified_genus"]
gentemp_Bt <-gentemp_B[,1:21]

gen_long_B <- gather(gentemp_Bt, key = "Genus", value = "Percent_Abundance")
gen_long_B$Genus <- factor(gen_long_B$Genus, levels = names(sort(colMeans(gentemp_Bt), decreasing = TRUE)))
#fammertemp$fam<-row.names(fammertemp)
#fammertemp$fam <- factor(fammertemp$fam, levels = fammertemp$fam[order(fammertemp$Mean_percent_abundance, decreasing = TRUE)])

topgen_box_B<- ggplot(gen_long_B, aes(x=Genus, y=Percent_Abundance))+
  geom_boxplot()+#fill = "skyblue", color = "black") +
  labs(y = "Percent Abundance", title = "Epilithic biofilms") +
  theme_minimal() +
    scale_y_continuous(labels = scales::percent_format(scale = 1))+
  theme(axis.text.x = element_text(angle = 60, hjust = 1))  
topgen_box_B

#mean percent abundance for each genily
Mean_percent_abundance<-colMeans(gentemp_Bt)
St.Dev<- sapply(gentemp_Bt, sd)
name_rab<- colnames(gentemp_Bt)

### Table of family mean percent abundance & st. deviation
topgen_table_B<- data.frame(#name_rab,
  Mean_percent_abundance,St.Dev)
#topfam_table_B<-topfam_table_B[topfam_table_B$Mean_percent_abundance>0,]
topgen_table_B
##                                    Mean_percent_abundance    St.Dev
## Ramularia                                       9.1233101 12.292497
## Pyrenochaetopsis                                6.7410897  6.468327
## Alternaria                                      6.3867268  5.770778
## Verrucaria                                      5.8756657 10.895814
## Paraphoma                                       4.7357640  3.522203
## Phaeosphaeria                                   3.0858255  2.056672
## Tremateia                                       3.0510037  2.634761
## Phallus                                         1.9868906  1.878962
## Neosetophoma                                    1.4502253  1.944351
## Cladosporium                                    1.2935272  1.514903
## Epicoccum                                       1.2894306  1.161461
## Tomentella                                      1.2341254  5.692617
## Stagonosporopsis                                1.1880377  1.120118
## Trichomeriaceae_gen_Incertae_sedis              1.1747235  2.220119
## Mycoarthris                                     1.1378533  1.590363
## Didymella                                       1.0866448  0.995253
## Aureobasidium                                   1.0692339  5.037862
## Thelidium                                       1.0241704  2.565566
## Aphelidiomycota_gen_Incertae_sedis              1.0159771  3.273406
## Neoophiobolus                                   0.8869316  1.796551
## Hyphodermella                                   0.8060221  1.172869

##genus, leaf

gentemp_L<- gentemp_L[,colnames(gentemp_L)!="Unclassified_genus"]
gentemp_Lt <-gentemp_L[,1:21]

gen_long_L <- gather(gentemp_Lt, key = "Genus", value = "Percent_Abundance")
gen_long_L$Genus <- factor(gen_long_L$Genus, levels = names(sort(colMeans(gentemp_Lt), decreasing = TRUE)))
#fammertemp$fam<-row.names(fammertemp)
#fammertemp$fam <- factor(fammertemp$fam, levels = fammertemp$fam[order(fammertemp$Mean_percent_abundance, decreasing = TRUE)])

topgen_box_L<- ggplot(gen_long_L, aes(x=Genus, y=Percent_Abundance))+
  geom_boxplot()+#fill = "skyblue", color = "black") +
  labs(y = "Percent Abundance", title = "Leaf litter") +
  theme_minimal() +
    scale_y_continuous(labels = scales::percent_format(scale = 1))+
  theme(axis.text.x = element_text(angle = 60, hjust = 1))  
topgen_box_L

#mean percent abundance for each genily
Mean_percent_abundance<-colMeans(gentemp_Lt)
St.Dev<- sapply(gentemp_Lt, sd)
name_rab<- colnames(gentemp_Lt)

### Table of family mean percent abundance & st. deviation
topgen_table_L<- data.frame(#name_rab,
  Mean_percent_abundance,St.Dev)
#topfam_table_L<-topfam_table_L[topfam_table_L$Mean_percent_abundance>0,]
topgen_table_L
##                                 Mean_percent_abundance   St.Dev
## Alternaria                                   11.895195 8.782032
## Mycoarthris                                   5.682185 8.078487
## Paraphoma                                     4.748664 7.000964
## Ramularia                                     4.372990 6.772981
## Neosetophoma                                  4.046127 3.653187
## Cladosporium                                  3.843908 3.829641
## Phaeosphaeria                                 3.381070 6.196825
## Tetracladium                                  3.262528 8.112430
## Ophiognomonia                                 3.161418 8.764815
## Pyrenochaetopsis                              1.878372 1.914685
## Crocicreas                                    1.822588 8.262448
## Venturia                                      1.590733 4.534351
## Pezizella                                     1.527103 3.554895
## Cylindrosympodium                             1.316168 2.284686
## Efibulobasidium                               1.280431 1.804593
## Calloriaceae_gen_Incertae_sedis               1.239464 2.048242
## Stagonosporopsis                              1.217673 3.578453
## Hymenoscyphus                                 1.166247 3.152743
## Eleutheromyces                                1.106976 4.134265
## Filobasidium                                  1.065137 4.963575
## Phacidium                                     1.052934 7.042910

##genus, sediment

#Reorder from most abundant to least abundant
#fammertemp <- fammertemp[,order(colSums(-fammertemp,na.rm=TRUE))]
gentemp_S<- gentemp_S[,colnames(gentemp_S)!="Unclassified_genus"]
gentemp_St <-gentemp_S[,1:21]

gen_long_S <- gather(gentemp_St, key = "Genus", value = "Percent_Abundance")
gen_long_S$Genus <- factor(gen_long_S$Genus, levels = names(sort(colMeans(gentemp_St), decreasing = TRUE)))
#fammertemp$fam<-row.names(fammertemp)
#fammertemp$fam <- factor(fammertemp$fam, levels = fammertemp$fam[order(fammertemp$Mean_percent_abundance, decreasing = TRUE)])

topgen_box_S<- ggplot(gen_long_S, aes(x=Genus, y=Percent_Abundance))+
  geom_boxplot()+#fill = "skyblue", color = "black") +
  labs(y = "Percent Abundance", title = "Benthic sediment") +
  theme_minimal() +
    scale_y_continuous(labels = scales::percent_format(scale = 1))+
  theme(axis.text.x = element_text(angle = 60, hjust = 1))  
topgen_box_S

#mean percent abundance for each genily
Mean_percent_abundance<-colMeans(gentemp_St)
St.Dev<- sapply(gentemp_St, sd)
name_rab<- colnames(gentemp_St)

### Table of family mean percent abundance & st. deviation
topgen_table_S<- data.frame(#name_rab,
  Mean_percent_abundance,St.Dev)
#topfam_table_S<-topfam_table_S[topfam_table_S$Mean_percent_abundance>0,]
topgen_table_S
##                                    Mean_percent_abundance     St.Dev
## Mortierella                                     7.3040421  5.1409124
## Phallus                                         5.9871296  5.0978485
## Pyrenochaetopsis                                5.9418954  8.0990632
## Paraphoma                                       4.2443329  2.3495793
## Pseudosperma                                    3.8193022 11.0517981
## Alternaria                                      2.5168988  3.0641952
## Tremateia                                       2.4127748  1.9462608
## Blastocladiales_gen_Incertae_sedis              2.2702444  3.4453279
## Kickxellomycota_gen_Incertae_sedis              2.1806295  3.5489901
## Tomentella                                      2.0321248  3.3281893
## Inosperma                                       1.9126383  8.9702269
## Phaeosphaeria                                   1.4483477  1.2119029
## Curvularia                                      1.4329851  2.0640483
## Basidiomycota_gen_Incertae_sedis                1.3886044  2.3323657
## Fusarium                                        1.2989895  1.0000189
## Preussia                                        1.2110815  1.2170898
## Tetracladium                                    1.1965724  1.4487151
## Inocybe                                         1.0591629  1.9272290
## Sebacina                                        0.9473576  2.4086085
## Paraphaeosphaeria                               0.7647139  1.6631427
## Cladosporium                                    0.6810733  0.6745644

table of top families and genera in each substrate

plotout <- "Family_genus_relabun_substrate_03.15.2025.tiff"
agg_tiff(filename=plotout, width=4800, height=5000, units="px",
         pointsize=10, res=600, compression="lzw", scaling=0.5)
plot_grid(topfam_box_B,topgen_box_B,topfam_box_L,topgen_box_L,topfam_box_S,topgen_box_S, labels="AUTO",label_size = 18, ncol = 2)
invisible(dev.off())

write_csv(topgen_table_L, "top20genL_03.15.2025.csv")
write_csv(topgen_table_B, "top20genB_03.15.2025.csv")
write_csv(topgen_table_S, "top20genS_03.15.2025.csv")

Differential abundance tests, Wilcoxon and Spearman

Limited non-parametric tests for differential relative abundances of major taxa.

### Basidiomycetes

cor_summary <- taxmerge %>%
  group_by(substrate) %>%
  summarize(
    spearman_rho = cor(p__Basidiomycota, lndrainage_area, method = "spearman"),
    p_value = cor.test(p__Basidiomycota, lndrainage_area, method = "spearman")$p.value
  )
## Warning: There were 3 warnings in `summarize()`.
## The first warning was:
## ℹ In argument: `p_value = cor.test(p__Basidiomycota, lndrainage_area, method =
##   "spearman")$p.value`.
## ℹ In group 1: `substrate = B`.
## Caused by warning in `cor.test.default()`:
## ! Cannot compute exact p-value with ties
## ℹ Run `dplyr::last_dplyr_warnings()` to see the 2 remaining warnings.
cor_summary
## # A tibble: 3 × 3
##   substrate spearman_rho p_value
##   <fct>            <dbl>   <dbl>
## 1 B                0.478 0.00183
## 2 L                0.124 0.407  
## 3 S                0.365 0.0108
### Asco classes
cor_summary <- taxmerge %>%
  group_by(substrate) %>%
  summarize(
    spearman_rho = cor(c__Leotiomycetes, lndrainage_area, method = "spearman"),
    p_value = cor.test(c__Leotiomycetes, lndrainage_area, method = "spearman")$p.value
  )
## Warning: There were 3 warnings in `summarize()`.
## The first warning was:
## ℹ In argument: `p_value = cor.test(c__Leotiomycetes, lndrainage_area, method =
##   "spearman")$p.value`.
## ℹ In group 1: `substrate = B`.
## Caused by warning in `cor.test.default()`:
## ! Cannot compute exact p-value with ties
## ℹ Run `dplyr::last_dplyr_warnings()` to see the 2 remaining warnings.
cor_summary
## # A tibble: 3 × 3
##   substrate spearman_rho  p_value
##   <fct>            <dbl>    <dbl>
## 1 B               -0.217 0.180   
## 2 L               -0.497 0.000375
## 3 S               -0.358 0.0126
cor_summary <- taxmerge %>%
  group_by(substrate) %>%
  summarize(
    spearman_rho = cor(c__Leotiomycetes, lndrainage_area, method = "spearman"),
    p_value = cor.test(c__Leotiomycetes, lndrainage_area, method = "spearman")$p.value
  )
## Warning: There were 3 warnings in `summarize()`.
## The first warning was:
## ℹ In argument: `p_value = cor.test(c__Leotiomycetes, lndrainage_area, method =
##   "spearman")$p.value`.
## ℹ In group 1: `substrate = B`.
## Caused by warning in `cor.test.default()`:
## ! Cannot compute exact p-value with ties
## ℹ Run `dplyr::last_dplyr_warnings()` to see the 2 remaining warnings.
cor_summary
## # A tibble: 3 × 3
##   substrate spearman_rho  p_value
##   <fct>            <dbl>    <dbl>
## 1 B               -0.217 0.180   
## 2 L               -0.497 0.000375
## 3 S               -0.358 0.0126
cor_summary <- taxmerge %>%
  group_by(substrate) %>%
  summarize(
    spearman_rho = cor(f__Verrucariaceae, prc_wet, method = "spearman"),
    p_value = cor.test(f__Verrucariaceae, prc_wet, method = "spearman")$p.value
  )
## Warning: There were 3 warnings in `summarize()`.
## The first warning was:
## ℹ In argument: `p_value = cor.test(f__Verrucariaceae, prc_wet, method =
##   "spearman")$p.value`.
## ℹ In group 1: `substrate = B`.
## Caused by warning in `cor.test.default()`:
## ! Cannot compute exact p-value with ties
## ℹ Run `dplyr::last_dplyr_warnings()` to see the 2 remaining warnings.
cor_summary
## # A tibble: 3 × 3
##   substrate spearman_rho p_value
##   <fct>            <dbl>   <dbl>
## 1 B              -0.284   0.0758
## 2 L               0.0289  0.847 
## 3 S              -0.167   0.256

FUNGAL TRAITS

Micro-Eco package for heatmaps and FungalTraits

#install.packages('microeco')
#install.packages('file2meco')
library(microeco)
library(file2meco)
##install.packages("file2meco")

microecotest<- phyloseq2meco(pseqtest)
## 25 taxa with 0 abundance are removed from the otu_table ...
microecotest$tidy_dataset()

# show 40 taxa at Genus level
t1 <- trans_abund$new(dataset = microecotest, taxrank = "Family", ntaxa = 15)
## No taxa_abund list found. Calculate relative abundance with cal_abund function ...
## The result is stored in object$taxa_abund ...
## The transformed abundance data is stored in object$data_abund ...
t1$plot_heatmap(facet = "flow_state", xtext_keep = FALSE, withmargin = FALSE)
## Warning in scale_fill_gradientn(colours = color_values, trans =
## plot_colorscale, : log-10 transformation introduced infinite values.

# create trans_func object
t2 <- trans_func$new(microecotest)

# fungi_database = "FungalTraits" for the FungalTraits database
t2$cal_spe_func(fungi_database = "FungalTraits")
## Please also cite:
## FungalTraits: a user-friendly traits database of fungi and fungus-like stramenopiles. Fungal Diversity 105, 1-16 (2020).
## Mapped raw FungalTraits result is stored in object$res_spe_func_raw_FungalTraits ...
## The functional binary table is stored in object$res_spe_func ...
write.csv(t2$res_spe_func,"FungalTraits_ASV_tab_microeco_03.08.2025.csv")

### How many ASVs were assigned functional traits?
## total number of ASVs in rarefied data:
ncol(pseqtest@otu_table)
## [1] 5852
#number of ASVs with functions assigned:
nrow(t2$res_spe_func) ##ASVs checked against fungaltraits
## [1] 5827
rows<- rowSums(t2$res_spe_func)
no.function<- rows[rows==0]
length(no.function) #ASVs with no traits assigned
## [1] 2006
nrow(t2$res_spe_func)-length(no.function)
## [1] 3821
((nrow(t2$res_spe_func)-length(no.function))/nrow(t2$res_spe_func)) #proportion of ASVs assigned traits
## [1] 0.6557405
### ~65% of ASVs assigned traits

# calculate abundance-unweighted functional redundancy of each trait for each network module
t2$cal_spe_func_perc(#use_community = TRUE
  )
## The result table is stored in object$res_spe_func_perc ...
relabun_func<-t2$res_spe_func_perc
#t2$res_spe_func_perc
write.csv(relabun_func, "functional_group_percent_abundance_03.08.2025.csv")

functional analysis

#View(func_relabun)
#relabun_func
perc_func_env<- merge(samdftest,relabun_func,by="row.names")
row.names(perc_func_env) <- perc_func_env$Row.names

### mean percent abundance of dominant groups (out of classified reads)
func_prop<- perc_func_env[96:117]/100 
mean(rowSums(func_prop)) ### mean proportion of total reads classified
## [1] 0.6710554
func_prop<- perc_func_env[96:117]/(100*mean(rowSums(func_prop))) ### for percents out of classified reads, not total reads
mean(func_prop$`primary_lifestyle|litter_saprotroph`)
## [1] 0.2690047
mean(func_prop$`primary_lifestyle|plant_pathogen`)
## [1] 0.3396585
func_perc<- perc_func_env[96:117]/rowSums(perc_func_env[96:117]) 
rowSums(func_perc)
## 01m01_B 01m01_L 01m01_S 01m02_B 01m02_L 01m02_S 01m03_B 01m03_L 01m03_S 01m04_B 
##       1       1       1       1       1       1       1       1       1       1 
## 01m04_L 01m04_S 01m05_B 01m05_L 01m05_S 01m06_B 01m06_L 01m06_S 02m01_L 02m01_S 
##       1       1       1       1       1       1       1       1       1       1 
## 02m02_B 02m02_L 02m02_S 02m03_B 02m03_L 02m03_S 02m04_L 02m04_S 02m05_B 02m05_L 
##       1       1       1       1       1       1       1       1       1       1 
## 02m06_B 02m06_L 02m06_S 02m07_B 02m07_L 02m07_S 02m08_L 02m08_S 02m09_B 02m09_L 
##       1       1       1       1       1       1       1       1       1       1 
## 02m09_S 02m10_B 02m10_L 02m10_S 02m11_B 02m11_S 04m01_B 04m01_L 04m01_S 04m02_B 
##       1       1       1       1       1       1       1       1       1       1 
## 04m02_L 04m02_S 04m03_B 04m03_L 04m03_S 04m04_B 04m04_L 04m04_S 04m05_B 04m05_L 
##       1       1       1       1       1       1       1       1       1       1 
## 04m05_S 04m06_B 04m06_L 04m06_S 04m07_L 04m07_S 04m08_L 04m08_S 04m09_L 04m09_S 
##       1       1       1       1       1       1       1       1       1       1 
## 04m10_B 04m10_L 04m10_S 04m11_B 04m11_L 04m11_S 04m12_B 04m12_L 04m12_S 04m13_B 
##       1       1       1       1       1       1       1       1       1       1 
## 04m13_L 04m13_S 04t01_B 04t01_L 04t01_S 04t02_B 04t02_L 04t02_S 04w01_B 04w01_L 
##       1       1       1       1       1       1       1       1       1       1 
## 04w01_S 04w02_B 04w02_L 04w02_S 04w03_B 04w03_S 04w04_L 04w04_S 20m01_L 20m01_S 
##       1       1       1       1       1       1       1       1       1       1 
## 20m02_B 20m02_L 20m02_S 20m03_B 20m03_L 20m03_S 20m04_B 20m04_L 20m04_S 20m05_L 
##       1       1       1       1       1       1       1       1       1       1 
## 20m05_S sfm01_B sfm01_L sfm01_S sfm02_B sfm02_L sfm02_S sfm03_B sfm03_L sfm04_B 
##       1       1       1       1       1       1       1       1       1       1 
## sfm04_L sfm04_S sfm05_B sfm05_L sfm05_S sfm06_L sfm06_S sfm07_B sfm07_L sfm07_S 
##       1       1       1       1       1       1       1       1       1       1 
## Sft01_B Sft01_L Sft01_S Sft02_B Sft02_S 
##       1       1       1       1       1
func_perc <- merge(samdftest,func_perc,by="row.names")
row.names(func_perc) <- func_perc$Row.names
colnames(func_perc) <- gsub("^.+\\|", "", colnames(func_perc))


library(rstatix)
### lichen by substrate
stat.test <- func_perc %>%
wilcox_test(lichenized ~ substrate) %>%
 adjust_pvalue(method = "bonferroni") %>%
  add_significance()
stat.test
## # A tibble: 3 × 9
##   .y.        group1 group2    n1    n2 statistic          p   p.adj p.adj.signif
##   <chr>      <chr>  <chr>  <int> <int>     <dbl>      <dbl>   <dbl> <chr>       
## 1 lichenized B      L         40    47     1574.    5.22e-8 1.57e-7 ****        
## 2 lichenized B      S         40    48     1569     2.97e-7 8.91e-7 ****        
## 3 lichenized L      S         47    48     1039     4.99e-1 1   e+0 ns
effsize <- func_perc %>%
  wilcox_effsize(lichenized ~substrate)
effsize
## # A tibble: 3 × 7
##   .y.        group1 group2 effsize    n1    n2 magnitude
## * <chr>      <chr>  <chr>    <dbl> <int> <int> <ord>    
## 1 lichenized B      L       0.584     40    47 large    
## 2 lichenized B      S       0.547     40    48 large    
## 3 lichenized L      S       0.0697    47    48 small
### litter sap by substrate
stat.test <- func_perc %>%
wilcox_test(litter_saprotroph ~ substrate) %>%
 adjust_pvalue(method = "bonferroni") %>%
  add_significance()
stat.test
## # A tibble: 3 × 9
##   .y.         group1 group2    n1    n2 statistic        p    p.adj p.adj.signif
##   <chr>       <chr>  <chr>  <int> <int>     <dbl>    <dbl>    <dbl> <chr>       
## 1 litter_sap… B      L         40    47        80 2.44e-17 7.32e-17 ****        
## 2 litter_sap… B      S         40    48      1462 1.53e- 5 4.59e- 5 ****        
## 3 litter_sap… L      S         47    48      2237 1.3 e-24 3.90e-24 ****
effsize <- func_perc %>%
  wilcox_effsize(litter_saprotroph ~substrate)
effsize
## # A tibble: 3 × 7
##   .y.               group1 group2 effsize    n1    n2 magnitude
## * <chr>             <chr>  <chr>    <dbl> <int> <int> <ord>    
## 1 litter_saprotroph B      L        0.785    40    47 large    
## 2 litter_saprotroph B      S        0.448    40    48 moderate 
## 3 litter_saprotroph L      S        0.847    47    48 large
### soil saprotroph by substrate
stat.test <- func_perc %>%
wilcox_test(soil_saprotroph ~ substrate) %>%
 adjust_pvalue(method = "bonferroni") %>%
  add_significance()
stat.test
## # A tibble: 3 × 9
##   .y.         group1 group2    n1    n2 statistic        p    p.adj p.adj.signif
##   <chr>       <chr>  <chr>  <int> <int>     <dbl>    <dbl>    <dbl> <chr>       
## 1 soil_sapro… B      L         40    47      1124 1.18e- 1 3.54e- 1 ns          
## 2 soil_sapro… B      S         40    48        77 8.83e-18 2.65e-17 ****        
## 3 soil_sapro… L      S         47    48        38 9.12e-23 2.74e-22 ****
effsize <- func_perc %>%
  wilcox_effsize(soil_saprotroph ~substrate)
effsize
## # A tibble: 3 × 7
##   .y.             group1 group2 effsize    n1    n2 magnitude
## * <chr>           <chr>  <chr>    <dbl> <int> <int> <ord>    
## 1 soil_saprotroph B      L        0.168    40    47 small    
## 2 soil_saprotroph B      S        0.789    40    48 large    
## 3 soil_saprotroph L      S        0.832    47    48 large
### ectomycorrhizae by substrate
stat.test <- func_perc %>%
wilcox_test(ectomycorrhizal ~ substrate) %>%
 adjust_pvalue(method = "bonferroni") %>%
  add_significance()
stat.test
## # A tibble: 3 × 9
##   .y.         group1 group2    n1    n2 statistic        p    p.adj p.adj.signif
##   <chr>       <chr>  <chr>  <int> <int>     <dbl>    <dbl>    <dbl> <chr>       
## 1 ectomycorr… B      L         40    47      1278 3   e- 3 9   e- 3 **          
## 2 ectomycorr… B      S         40    48       335 1.53e- 7 4.59e- 7 ****        
## 3 ectomycorr… L      S         47    48       204 3.77e-12 1.13e-11 ****
effsize <- func_perc %>%
  wilcox_effsize(ectomycorrhizal ~substrate)
effsize
## # A tibble: 3 × 7
##   .y.             group1 group2 effsize    n1    n2 magnitude
## * <chr>           <chr>  <chr>    <dbl> <int> <int> <ord>    
## 1 ectomycorrhizal B      L        0.318    40    47 moderate 
## 2 ectomycorrhizal B      S        0.560    40    48 large    
## 3 ectomycorrhizal L      S        0.713    47    48 large
## [1] "substrate" "PRC_WET_GROUP", sites kmeans clustered by annual percent wet (k=3)
phylamet<-data.frame("Sample"=row.names(samdftest),
                     "Substrate"=samdftest$substrate,
                     "Site"=samdftest$siteid,
                     stringsAsFactors=T)
#merge metadata with major taxa data
phylalong <- merge(phylalong, phylamet)
phylamet<-data.frame("Sample"=row.names(samdftest),
                     "Drainage_area"=samdftest$drainage_area,
                     "Annual_Percent_Wet"=samdftest$prc_wet)
#merge metadata with major taxa data
phylalong <- merge(phylalong, phylamet)
#Summarize by depth and hydration
phyla_summary <- 
  phylalong %>% # the names of the new data frame and the data frame to be summarised
  group_by(Substrate, Site, Major_Taxa) %>%   # the grouping variable
  summarise(mean_prop = mean(Proportion), drainage_area = Drainage_area) #%>%
## `summarise()` has grouped output by 'Substrate', 'Site'. You can override using
## the `.groups` argument.
 # summarise(drainage_area = Drainage_area)# calculates the mean of each group
## `summarise()` has grouped output by 'Depth', 'Hydration'. You can override using the `.groups` argument.
phyla_summary
## # A tibble: 1,755 × 5
## # Groups:   Substrate, Site [135]
##    Substrate Site  Major_Taxa               mean_prop drainage_area
##    <fct>     <fct> <chr>                        <dbl>         <dbl>
##  1 B         01M01 Other                        0.246          28.3
##  2 B         01M01 Unclassified_Ascomycetes     4.38           28.3
##  3 B         01M01 Unclassified_Phylum          6.68           28.3
##  4 B         01M01 c__Dothideomycetes          28.6            28.3
##  5 B         01M01 c__Eurotiomycetes           24.2            28.3
##  6 B         01M01 c__Leotiomycetes             0.615          28.3
##  7 B         01M01 c__Sordariomycetes           1.60           28.3
##  8 B         01M01 p__Aphelidiomycota          21.6            28.3
##  9 B         01M01 p__Basidiomycota            12.1            28.3
## 10 B         01M01 p__Blastocladiomycota        0              28.3
## # ℹ 1,745 more rows
phyla_summary$Substrate <- factor(phyla_summary$Substrate,
                                 levels=c("B","L","S")) #reorder variables
phyla_summary$Site <- fct_reorder(phyla_summary$Site, phyla_summary$drainage_area)
ptab<- otu_table(pseqtest)
rowSums(ptab)
## 01m01_B 01m01_L 01m01_S 01m02_B 01m02_L 01m02_S 01m03_B 01m03_L 01m03_S 01m04_B 
##    2441    2441    2441    2441    2441    2441    2441    2441    2441    2441 
## 01m04_L 01m04_S 01m05_B 01m05_L 01m05_S 01m06_B 01m06_L 01m06_S 02m01_L 02m01_S 
##    2441    2441    2441    2441    2441    2441    2441    2441    2441    2441 
## 02m02_B 02m02_L 02m02_S 02m03_B 02m03_L 02m03_S 02m04_L 02m04_S 02m05_B 02m05_L 
##    2441    2441    2441    2441    2441    2441    2441    2441    2441    2441 
## 02m06_B 02m06_L 02m06_S 02m07_B 02m07_L 02m07_S 02m08_L 02m08_S 02m09_B 02m09_L 
##    2441    2441    2441    2441    2441    2441    2441    2441    2441    2441 
## 02m09_S 02m10_B 02m10_L 02m10_S 02m11_B 02m11_S 04m01_B 04m01_L 04m01_S 04m02_B 
##    2441    2441    2441    2441    2441    2441    2441    2441    2441    2441 
## 04m02_L 04m02_S 04m03_B 04m03_L 04m03_S 04m04_B 04m04_L 04m04_S 04m05_B 04m05_L 
##    2441    2441    2441    2441    2441    2441    2441    2441    2441    2441 
## 04m05_S 04m06_B 04m06_L 04m06_S 04m07_L 04m07_S 04m08_L 04m08_S 04m09_L 04m09_S 
##    2441    2441    2441    2441    2441    2441    2441    2441    2441    2441 
## 04m10_B 04m10_L 04m10_S 04m11_B 04m11_L 04m11_S 04m12_B 04m12_L 04m12_S 04m13_B 
##    2441    2441    2441    2441    2441    2441    2441    2441    2441    2441 
## 04m13_L 04m13_S 04t01_B 04t01_L 04t01_S 04t02_B 04t02_L 04t02_S 04w01_B 04w01_L 
##    2441    2441    2441    2441    2441    2441    2441    2441    2441    2441 
## 04w01_S 04w02_B 04w02_L 04w02_S 04w03_B 04w03_S 04w04_L 04w04_S 20m01_L 20m01_S 
##    2441    2441    2441    2441    2441    2441    2441    2441    2441    2441 
## 20m02_B 20m02_L 20m02_S 20m03_B 20m03_L 20m03_S 20m04_B 20m04_L 20m04_S 20m05_L 
##    2441    2441    2441    2441    2441    2441    2441    2441    2441    2441 
## 20m05_S sfm01_B sfm01_L sfm01_S sfm02_B sfm02_L sfm02_S sfm03_B sfm03_L sfm04_B 
##    2441    2441    2441    2441    2441    2441    2441    2441    2441    2441 
## sfm04_L sfm04_S sfm05_B sfm05_L sfm05_S sfm06_L sfm06_S sfm07_B sfm07_L sfm07_S 
##    2441    2441    2441    2441    2441    2441    2441    2441    2441    2441 
## Sft01_B Sft01_L Sft01_S Sft02_B Sft02_S 
##    2441    2441    2441    2441    2441
# Remove any prefix followed by '|'
colnames(perc_func_env) <- gsub("^.+\\|", "", colnames(perc_func_env))

func_prop<- perc_func_env[97:118]/100 ###rowSums(perc_func_env[127:148])
rowSums(func_prop)
## 01m01_B 01m01_L 01m01_S 01m02_B 01m02_L 01m02_S 01m03_B 01m03_L 01m03_S 01m04_B 
##  0.7425  0.8570  0.7752  0.6964  0.8104  0.7247  0.7308  0.8499  0.6797  0.7779 
## 01m04_L 01m04_S 01m05_B 01m05_L 01m05_S 01m06_B 01m06_L 01m06_S 02m01_L 02m01_S 
##  0.8011  0.6513  0.7733  0.8319  0.6830  0.7661  0.8430  0.6835  0.7959  0.7502 
## 02m02_B 02m02_L 02m02_S 02m03_B 02m03_L 02m03_S 02m04_L 02m04_S 02m05_B 02m05_L 
##  0.8187  0.7977  0.6787  0.8381  0.8287  0.6753  0.7880  0.7110  0.7390  0.8317 
## 02m06_B 02m06_L 02m06_S 02m07_B 02m07_L 02m07_S 02m08_L 02m08_S 02m09_B 02m09_L 
##  0.7492  0.8052  0.7052  0.7844  0.8619  0.7127  0.8464  0.7085  0.8184  0.8553 
## 02m09_S 02m10_B 02m10_L 02m10_S 02m11_B 02m11_S 04m01_B 04m01_L 04m01_S 04m02_B 
##  0.6874  0.8214  0.8659  0.7293  0.8289  0.6462  0.7694  0.8000  0.6988  0.7654 
## 04m02_L 04m02_S 04m03_B 04m03_L 04m03_S 04m04_B 04m04_L 04m04_S 04m05_B 04m05_L 
##  0.8332  0.5639  0.8223  0.8208  0.6613  0.7077  0.8017  0.5869  0.6990  0.8091 
## 04m05_S 04m06_B 04m06_L 04m06_S 04m07_L 04m07_S 04m08_L 04m08_S 04m09_L 04m09_S 
##  0.6892  0.8154  0.8245  0.6985  0.8290  0.6726  0.7670  0.7165  0.8008  0.7728 
## 04m10_B 04m10_L 04m10_S 04m11_B 04m11_L 04m11_S 04m12_B 04m12_L 04m12_S 04m13_B 
##  0.8257  0.8820  0.6631  0.7977  0.8605  0.6703  0.9000  0.8644  0.6211  0.8689 
## 04m13_L 04m13_S 04t01_B 04t01_L 04t01_S 04t02_B 04t02_L 04t02_S 04w01_B 04w01_L 
##  0.8314  0.6689  0.7632  0.7978  0.6549  0.7388  0.7800  0.7500  0.8228  0.8649 
## 04w01_S 04w02_B 04w02_L 04w02_S 04w03_B 04w03_S 04w04_L 04w04_S 20m01_L 20m01_S 
##  0.7144  0.8750  0.7847  0.6856  0.8167  0.6318  0.8626  0.6972  0.8500  0.7131 
## 20m02_B 20m02_L 20m02_S 20m03_B 20m03_L 20m03_S 20m04_B 20m04_L 20m04_S 20m05_L 
##  0.7835  0.8469  0.7500  0.7794  0.8245  0.6627  0.7551  0.7906  0.6864  0.8151 
## 20m05_S sfm01_B sfm01_L sfm01_S sfm02_B sfm02_L sfm02_S sfm03_B sfm03_L sfm04_B 
##  0.7463  0.7473  0.7728  0.6967  0.7472  0.8443  0.7480  0.7884  0.8327  0.7873 
## sfm04_L sfm04_S sfm05_B sfm05_L sfm05_S sfm06_L sfm06_S sfm07_B sfm07_L sfm07_S 
##  0.7986  0.7650  0.7351  0.7681  0.6707  0.7848  0.7399  0.7373  0.7909  0.7199 
## Sft01_B Sft01_L Sft01_S Sft02_B Sft02_S 
##  0.6931  0.7657  0.6319  0.7455  0.6867
#func_prop <- func_prop
#Add taxa names as a column
func_prop$functional_groups <- row.names(func_prop)

#transform into long format
func_proplong <- gather(func_prop, Sample, Proportion, -functional_groups)
colnames(func_proplong)<- c("Sample", "functional_groups", "Proportion")
## [1] "substrate" "WetDry"
funcmet<-data.frame("Sample"=row.names(perc_func_env),
                     "Substrate"=perc_func_env$substrate,
                     "Site"=perc_func_env$siteid,
                     stringsAsFactors=T)
row.names(funcmet)<- funcmet$Sample

func_proplong <- merge(func_proplong, funcmet, by="Sample")
funcmet<-data.frame("Sample"=row.names(perc_func_env),
                     "Drainage_area"=perc_func_env$drainage_area,
                     "Annual_Percent_Wet"=perc_func_env$prc_wet)

#merge metadata with major taxa data
func_proplong <- merge(func_proplong, funcmet, by="Sample")
#Summarize by depth and hydration
phyla_summary <- 
  func_proplong %>% # the names of the new data frame and the data frame to be summarised
  group_by(Substrate, Site, functional_groups) %>%   # the grouping variable
  summarise(mean_prop = mean(Proportion), drainage_area = Drainage_area)  # calculates the mean of each group
## `summarise()` has grouped output by 'Substrate', 'Site'. You can override using
## the `.groups` argument.
## `summarise()` has grouped output by 'Depth', 'Hydration'. You can override using the `.groups` argument.
phyla_summary
## # A tibble: 2,970 × 5
## # Groups:   Substrate, Site [135]
##    Substrate Site  functional_groups      mean_prop drainage_area
##    <fct>     <fct> <chr>                      <dbl>         <dbl>
##  1 B         01M01 algal_parasite            0               28.3
##  2 B         01M01 animal-associated         0               28.3
##  3 B         01M01 animal_parasite           0               28.3
##  4 B         01M01 arbuscular_mycorrhizal    0               28.3
##  5 B         01M01 arthropod-associated      0               28.3
##  6 B         01M01 dung_saprotroph           0.0198          28.3
##  7 B         01M01 ectomycorrhizal           0               28.3
##  8 B         01M01 epiphyte                  0               28.3
##  9 B         01M01 foliar_endophyte          0.0297          28.3
## 10 B         01M01 lichen_parasite           0.0099          28.3
## # ℹ 2,960 more rows
phyla_summary$Substrate <- factor(phyla_summary$Substrate,
                                 levels=c( "B", "L","S")) #reorder variables
phyla_summary$Site <- fct_reorder(phyla_summary$Site, phyla_summary$drainage_area)
#phyla_summary$Wet.Dry <- factor(phyla_summary$Wet.Dry, levels= c("WET","DRY")) #reorder variables
phyla_summary$functional_groups <- factor(phyla_summary$functional_groups)

sublab<- c("Epilithic biofilms", "Leaf litter", "Benthic sediment")
names(sublab)<- c("B","L","S")

pal12 <- rev(cols25(n=22)) #set n= to the number of taxa you are plotting
#make stacked bar plot
phylum_bar <- ggplot(phyla_summary, aes(x = Site, y = mean_prop, fill = functional_groups))+
  geom_bar(stat = "identity", col=I("black")) +
  scale_fill_manual(values=pal12)+
  guides(fill=guide_legend(ncol=1))+
  facet_wrap(~Substrate, labeller = labeller(Substrate=sublab), nrow=1, scales="free_x") +
  scale_y_continuous(labels = scales::percent_format(scale = 100))+
  labs(x="Substrate", y="Percentage of Identified ITS Sequence Copies",
       fill="functional_groups")+
  #scale_facet_discrete(labels=c('B'='Epilithic biofilms', 'L'='Leaf litter', 'S'='Benthic sediment', 'W'='Surface water'))+
    theme(axis.text.x = element_text(angle=60, hjust=1), legend.position = "right")+
  theme(text=element_text(size=20), #change font size of all text
        axis.text.x=element_text(size=7), #change font size of axis text
       # axis.title=element_text(size=16), #change font size of axis titles
        #plot.title=element_text(size=16), #change font size of plot title
        legend.text=element_text(size=16), #change font size of legend text
       # strip.text.x = element_text(size = 10),
        legend.title=element_text(size=16)) #change font size of legend title  
phylum_bar

  #######
 
#c(180,100) *
#  0.0394 * # convert mm to inch
#  600 # convert to pixels
## [1] 4255.2 2364.0
plotout <- "Functional Barplot_site_drainage_03.15.2025.tiff"
agg_tiff(filename=plotout, width=6000, height=2750, units="px",
         pointsize=10, res=600, compression="lzw", scaling=0.5)
phylum_bar
invisible(dev.off())

Plot aquatic!!!

func_prop<- perc_func_env[171:174]/100
rowSums(func_prop)
## 01m01_B 01m01_L 01m01_S 01m02_B 01m02_L 01m02_S 01m03_B 01m03_L 01m03_S 01m04_B 
##  0.7722  0.9191  0.8194  0.7144  0.8974  0.7826  0.7443  0.9251  0.6834  0.8334 
## 01m04_L 01m04_S 01m05_B 01m05_L 01m05_S 01m06_B 01m06_L 01m06_S 02m01_L 02m01_S 
##  0.8195  0.6639  0.8128  0.8835  0.6864  0.7851  0.9285  0.7126  0.8503  0.7651 
## 02m02_B 02m02_L 02m02_S 02m03_B 02m03_L 02m03_S 02m04_L 02m04_S 02m05_B 02m05_L 
##  0.8724  0.8321  0.6943  0.9191  0.9101  0.7015  0.8695  0.7535  0.7636  0.8889 
## 02m06_B 02m06_L 02m06_S 02m07_B 02m07_L 02m07_S 02m08_L 02m08_S 02m09_B 02m09_L 
##  0.7749  0.8615  0.7319  0.8392  0.9595  0.7311  0.8856  0.7025  0.9698  0.9408 
## 02m09_S 02m10_B 02m10_L 02m10_S 02m11_B 02m11_S 04m01_B 04m01_L 04m01_S 04m02_B 
##  0.6953  0.8714  0.9808  0.7829  0.8422  0.6795  0.8121  0.8983  0.7207  0.8047 
## 04m02_L 04m02_S 04m03_B 04m03_L 04m03_S 04m04_B 04m04_L 04m04_S 04m05_B 04m05_L 
##  0.9815  0.5917  0.8500  0.8774  0.7015  0.7465  0.8986  0.5869  0.7373  0.8893 
## 04m05_S 04m06_B 04m06_L 04m06_S 04m07_L 04m07_S 04m08_L 04m08_S 04m09_L 04m09_S 
##  0.6999  0.8615  0.9317  0.7083  0.9183  0.6728  0.8195  0.7305  0.8686  0.8051 
## 04m10_B 04m10_L 04m10_S 04m11_B 04m11_L 04m11_S 04m12_B 04m12_L 04m12_S 04m13_B 
##  0.8852  1.0108  0.7216  0.8786  0.9442  0.7064  1.0200  0.9660  0.6613  0.9167 
## 04m13_L 04m13_S 04t01_B 04t01_L 04t01_S 04t02_B 04t02_L 04t02_S 04w01_B 04w01_L 
##  0.8832  0.7247  0.7870  0.8853  0.6655  0.7631  0.8182  0.7755  0.8514  0.9257 
## 04w01_S 04w02_B 04w02_L 04w02_S 04w03_B 04w03_S 04w04_L 04w04_S 20m01_L 20m01_S 
##  0.7168  0.9250  0.8453  0.7095  0.9167  0.6533  0.9241  0.7121  0.8658  0.7228 
## 20m02_B 20m02_L 20m02_S 20m03_B 20m03_L 20m03_S 20m04_B 20m04_L 20m04_S 20m05_L 
##  0.8029  0.9280  0.7437  0.8256  0.9171  0.6676  0.7763  0.9012  0.7260  0.8992 
## 20m05_S sfm01_B sfm01_L sfm01_S sfm02_B sfm02_L sfm02_S sfm03_B sfm03_L sfm04_B 
##  0.7646  0.8007  0.8181  0.7077  0.7690  0.9517  0.7482  0.8176  0.9206  0.8189 
## sfm04_L sfm04_S sfm05_B sfm05_L sfm05_S sfm06_L sfm06_S sfm07_B sfm07_L sfm07_S 
##  0.8554  0.8032  0.7672  0.8610  0.7018  0.8338  0.7526  0.7565  0.8360  0.7563 
## Sft01_B Sft01_L Sft01_S Sft02_B Sft02_S 
##  0.7256  0.8133  0.6779  0.7807  0.6899
#func_prop <- func_prop
#Add taxa names as a column
func_prop$functional_groups <- row.names(func_prop)

#transform into long format
func_proplong <- gather(func_prop, Sample, Proportion, -functional_groups)
colnames(func_proplong)<- c("Sample", "functional_groups", "Proportion")
## [1] "substrate" "WetDry"
funcmet<-data.frame("Sample"=row.names(perc_func_env),
                     "Substrate"=perc_func_env$substrate,
                     "Wet.Dry"=perc_func_env$wet_dry,
                     stringsAsFactors=T)
row.names(funcmet)<- funcmet$Sample
#merge metadata with major taxa data
func_proplong <- merge(func_proplong, funcmet, by="Sample")
#Summarize by depth and hydration
phyla_summary <- 
  func_proplong %>% # the names of the new data frame and the data frame to be summarised
  group_by(Substrate, Wet.Dry, functional_groups) %>%   # the grouping variable
  summarise(mean_prop = mean(Proportion))  # calculates the mean of each group
## `summarise()` has grouped output by 'Substrate', 'Wet.Dry'. You can override
## using the `.groups` argument.
## `summarise()` has grouped output by 'Depth', 'Hydration'. You can override using the `.groups` argument.
phyla_summary
## # A tibble: 24 × 4
## # Groups:   Substrate, Wet.Dry [6]
##    Substrate Wet.Dry functional_groups mean_prop
##    <fct>     <fct>   <chr>                 <dbl>
##  1 B         DRY     freshwater          0.0597 
##  2 B         DRY     marine              0.00968
##  3 B         DRY     non-aquatic         0.424  
##  4 B         DRY     partly_aquatic      0.352  
##  5 B         WET     freshwater          0.0614 
##  6 B         WET     marine              0.0139 
##  7 B         WET     non-aquatic         0.454  
##  8 B         WET     partly_aquatic      0.291  
##  9 L         DRY     freshwater          0.0938 
## 10 L         DRY     marine              0.00594
## # ℹ 14 more rows
phyla_summary$Substrate <- factor(phyla_summary$Substrate,
                                 levels=c( "B", "L","S")) #reorder variables
phyla_summary$Wet.Dry <- factor(phyla_summary$Wet.Dry, levels= c("WET","DRY")) #reorder variables
phyla_summary$functional_groups <- factor(phyla_summary$functional_groups)

sublab<- c("Epilithic biofilms", "Leaf litter", "Benthic sediment")
names(sublab)<- c("B","L","S")
phyla_summary$functional_groups <- factor(phyla_summary$functional_groups, levels=c("freshwater","partly_aquatic","marine","non-aquatic"))

pal12 <- cols25(n=5) #set n= to the number of taxa you are plotting
#make stacked bar plot
phylum_bar <- ggplot(phyla_summary, aes(x = Wet.Dry, y = mean_prop, fill = functional_groups))+
  geom_bar(stat = "identity", col=I("black")) +
  scale_fill_manual(values=pal12)+
  guides(fill=guide_legend(ncol=1))+
  facet_wrap(~Substrate, labeller = labeller(Substrate=sublab), nrow=1, scales="free_x") +
  labs(x="Substrate", y="Percentage of Identified ITS Sequence Copies",
       fill="functional_groups")+
  #scale_facet_discrete(labels=c('B'='Epilithic biofilms', 'L'='Leaf litter', 'S'='Benthic sediment', 'W'='Surface water'))+
  theme(axis.text.x = element_text(angle=60, hjust=1), legend.position = "right")+
  theme(text=element_text(size=16), #change font size of all text
        axis.text=element_text(size=11), #change font size of axis text
        axis.title=element_text(size=11), #change font size of axis titles
        plot.title=element_text(size=11), #change font size of plot title
        legend.text=element_text(size=11), #change font size of legend text
        legend.title=element_text(size=11)) #change font size of legend title  
phylum_bar

#c(180,100) *
#  0.0394 * # convert mm to inch
#  600 # convert to pixels
## [1] 4255.2 2364.0
plotout <- "Functional Barplot_aquatic_WetDry002_03162025.tiff"
agg_tiff(filename=plotout, width=3200, height=1800, units="px",
         pointsize=10, res=600, compression="lzw", scaling=0.5)
phylum_bar
invisible(dev.off())

GLLVM of functional groups

trait_prc<- relabun_func %>% dplyr::mutate( Litter_saprotrophic= `primary_lifestyle|litter_saprotroph`+
                  `Secondary_lifestyle|litter_saprotroph`,
                  Wood_saprotrophic= `primary_lifestyle|wood_saprotroph`+
                   `Secondary_lifestyle|wood_saprotroph`,
                  Plant_pathogenic= `primary_lifestyle|plant_pathogen`+
                   `Secondary_lifestyle|plant_pathogen`,
                  Mycoparasitic= `primary_lifestyle|mycoparasite`,
                  Decay_substrate_Leaf.Fruit.Seed=`Decay_substrate|leaf/fruit/seed`,
                  Decay_substrate_Wood=`Decay_substrate|wood`,
                  Decay_substrate_Roots=`Decay_substrate|roots`,
                  Decay_substrate_Soil=`Decay_substrate|soil`,
                  Decay_substrate_Algae=`Decay_substrate|algal_material`,
                  Aquatic=`Aquatic_habitat|aquatic`,
                  Non.aquatic=`Aquatic_habitat|non-aquatic`,
                  Freshwater=`Aquatic_habitat|freshwater`,
                  Endophytic=`Endophytic_interaction_capability|foliar_endophyte`+
                    `Endophytic_interaction_capability|root_endophyte`+ 
                    `Endophytic_interaction_capability|class1_clavicipitaceous_endophyte`+
                    `Endophytic_interaction_capability|root_endophyte_dark_septate`,
                  Non.endophytic=`Endophytic_interaction_capability|no_endophytic_capacity`,
                  Root_associated=`Endophytic_interaction_capability|root-associated`,#)
                  Ectomycorrhizal= `primary_lifestyle|ectomycorrhizal`,
                  Soil_saprotrophic= `primary_lifestyle|soil_saprotroph`,
                  Epiphytic= `primary_lifestyle|epiphyte`,
                  Lichen= `primary_lifestyle|lichenized`,
                  Lichen_parasite= `primary_lifestyle|lichen_parasite`)
tn<- ncol(trait_prc)-128
tn
## [1] 19
#View(func_relabun)
#relabun_func
trait_prct<- merge(samdftest,trait_prc[,128:ncol(trait_prc)],by="row.names")
row.names(trait_prct) <- trait_prct$Row.names
#trait_prct <- trait_prct %>% mutate_at(c('alpha.cent.wt', 'prc_wet'), ~(scale(.) %>% as.vector))
#trait_prct

Traits GLLVM Leaf

library(mvabund)
library(gllvm)
library(tidyverse)


trait_L<- trait_prct[trait_prct$substrate=='L',]
trait_L<- trait_prct[trait_prct$substrate=='L',]
trait_L<- trait_L[!is.na(trait_L$alpha.cent.wt),]

traitemp_L<- trait_L[,97:116]
traitemp_L<-traitemp_L[,colSums(traitemp_L)>0]
#Reorder data table from most abundant to least abundant
traitemp_L <- traitemp_L[,order(colSums(-traitemp_L,na.rm=TRUE))]
traitemp_L <- traitemp_L[,apply(traitemp_L,2,function(x) sum(x > 0))>1]


trait_L <- merge(traitemp_L, samdftest,
                  by="row.names", all=FALSE)
rownames(trait_L) <- trait_L[,1]
trait_L <- trait_L[,-1]
trait_L$annual_percent_wet<- trait_L$prc_wet
#detach("package:linkET", unload=TRUE)
#trait_L$percentwet_11month<- trait_L$percentwet_bonus

L_abun<-trait_L[,1:19]

## select functional groups that make up at least 5% of reads
L_abun<-L_abun[,colMeans(L_abun)>1]
X <- as.matrix(trait_L[,c("annual_percent_wet","alpha.cent.wt","tempC_mean","burn_interval")])
#y<-as.numeric(as.matrix(L_abun))
y<-as.matrix(as.tibble(L_abun))

gllvm(y, family = "poisson") 
## Call: 
## gllvm(y = y, family = "poisson")
## family: 
## [1] "poisson"
## method: 
## [1] "VA"
## 
## log-likelihood:  -1492.286 
## Residual degrees of freedom:  556 
## AIC:  3072.572 
## AICc:  3079.707 
## BIC:  3266.037
#gllvm(y, family = "negative.binomial") 

## selecting poisson due to lower AIC

### lv 1 has lowest AIC
gllvm(y, X, family = "poisson", num.lv = 0,
                 formula = ~ alpha.cent.wt+annual_percent_wet
                 , seed = 1995)
## Call: 
## gllvm(y = y, X = X, formula = ~alpha.cent.wt + annual_percent_wet, 
##     family = "poisson", num.lv = 0, seed = 1995)
## family: 
## [1] "poisson"
## method: 
## [1] "VA"
## 
## log-likelihood:  -1503.346 
## Residual degrees of freedom:  555 
## AIC:  3096.691 
## AICc:  3104.164 
## BIC:  3294.553
gllvm(y, X, family = "poisson", num.lv = 1,
                 formula = ~ alpha.cent.wt+annual_percent_wet
                 , seed = 1995)
## Call: 
## gllvm(y = y, X = X, formula = ~alpha.cent.wt + annual_percent_wet, 
##     family = "poisson", num.lv = 1, seed = 1995)
## family: 
## [1] "poisson"
## method: 
## [1] "VA"
## 
## log-likelihood:  -1487.238 
## Residual degrees of freedom:  540 
## AIC:  3094.476 
## AICc:  3108.057 
## BIC:  3358.292
gllvm(y, X, family = "poisson", num.lv = 2,
                 formula = ~ alpha.cent.wt+annual_percent_wet
                 , seed = 1995)
## Call: 
## gllvm(y = y, X = X, formula = ~alpha.cent.wt + annual_percent_wet, 
##     family = "poisson", num.lv = 2, seed = 1995)
## family: 
## [1] "poisson"
## method: 
## [1] "VA"
## 
## log-likelihood:  -1483.841 
## Residual degrees of freedom:  526 
## AIC:  3115.682 
## AICc:  3136.825 
## BIC:  3441.055
#fit_ord<- gllvm(y, family = "negative.binomial")
#ordiplot(fit_ord, biplot=TRUE, ind.spp=14)

fit_env <- gllvm(y, X, family = "poisson", num.lv = 1,
                 formula = ~ alpha.cent.wt+annual_percent_wet
                 , seed = 1995)
coefplot(fit_env, cex.ylab = 0.7, mar = c(4, 9, 2, 1), mfrow=c(1,1))

pdf("GLLVM_trait_L_06.12.2025.pdf", 
    )
coefplot(fit_env, cex.ylab = 0.7, mar = c(4, 12, 2, 1), mfrow=c(1,1))
dev.off()
## quartz_off_screen 
##                 2

Traits GLLVM Biofilm

library(mvabund)
library(gllvm)
library(tidyverse)

trait_B<- trait_prct[trait_prct$substrate=='B',]
trait_B<- trait_B[!is.na(trait_B$alpha.cent.wt),]

traitemp_B<- trait_B[,97:116]
traitemp_B<-traitemp_B[,colSums(traitemp_B)>0]
#Reorder data table from most abundant to least abundant
traitemp_B <- traitemp_B[,order(colSums(-traitemp_B,na.rm=TRUE))]
traitemp_B <- traitemp_B[,apply(traitemp_B,2,function(x) sum(x > 0))>1]


trait_B <- merge(traitemp_B, samdftest,
                  by="row.names", all=FALSE)
rownames(trait_B) <- trait_B[,1]
trait_B <- trait_B[,-1]
trait_B$annual_percent_wet<- trait_B$prc_wet
#detach("package:linkET", unload=TRUE)
#trait_B$percentwet_11month<- trait_B$percentwet_bonus

B_abun<-trait_B[,1:19]
## select functional groups that make up at least 5% of reads
B_abun<-B_abun[,colMeans(B_abun)>1]
X <- as.matrix(trait_B[,c("annual_percent_wet","alpha.cent.wt","tempC_mean","burn_interval")])
#y<-as.numeric(as.matrix(B_abun))
y<-as.matrix(as.tibble(B_abun))

gllvm(y, family = "poisson") 
## Call: 
## gllvm(y = y, family = "poisson")
## family: 
## [1] "poisson"
## method: 
## [1] "VA"
## 
## log-likelihood:  -1443.161 
## Residual degrees of freedom:  559 
## AIC:  2992.322 
## AICc:  3002.58 
## BIC:  3226.409
gllvm(y, family = "negative.binomial") 
## Call: 
## gllvm(y = y, family = "negative.binomial")
## family: 
## [1] "negative.binomial"
## method: 
## [1] "VA"
## 
## log-likelihood:  -1471.335 
## Residual degrees of freedom:  541 
## AIC:  3084.669 
## AICc:  3103.603 
## BIC:  3398.257
## selecting poisson due to lower AIC

### lv 1 has lowest AIC
gllvm(y, X, family = "poisson", num.lv = 0,
                 formula = ~ alpha.cent.wt+annual_percent_wet
                 , seed = 1995)
## Call: 
## gllvm(y = y, X = X, formula = ~alpha.cent.wt + annual_percent_wet, 
##     family = "poisson", num.lv = 0, seed = 1995)
## family: 
## [1] "poisson"
## method: 
## [1] "VA"
## 
## log-likelihood:  -1493.292 
## Residual degrees of freedom:  558 
## AIC:  3094.584 
## AICc:  3105.248 
## BIC:  3333.087
gllvm(y, X, family = "poisson", num.lv = 1,
                 formula = ~ alpha.cent.wt+annual_percent_wet
                 , seed = 1995)
## Call: 
## gllvm(y = y, X = X, formula = ~alpha.cent.wt + annual_percent_wet, 
##     family = "poisson", num.lv = 1, seed = 1995)
## family: 
## [1] "poisson"
## method: 
## [1] "VA"
## 
## log-likelihood:  -1447.652 
## Residual degrees of freedom:  540 
## AIC:  3039.304 
## AICc:  3058.807 
## BIC:  3357.309
gllvm(y, X, family = "poisson", num.lv = 2,
                 formula = ~ alpha.cent.wt+annual_percent_wet
                 , seed = 1995)
## Call: 
## gllvm(y = y, X = X, formula = ~alpha.cent.wt + annual_percent_wet, 
##     family = "poisson", num.lv = 2, seed = 1995)
## family: 
## [1] "poisson"
## method: 
## [1] "VA"
## 
## log-likelihood:  -1426.64 
## Residual degrees of freedom:  523 
## AIC:  3031.28 
## AICc:  3061.969 
## BIC:  3424.369
#fit_ord<- gllvm(y, family = "negative.binomial")
#ordiplot(fit_ord, biplot=TRUE, ind.spp=14)

fit_env <- gllvm(y, X, family = "poisson", num.lv = 1,
                 formula = ~ alpha.cent.wt+annual_percent_wet
                 , seed = 1995)
coefplot(fit_env, cex.ylab = 0.7, mar = c(4, 9, 2, 1), mfrow=c(1,1))

pdf("GLLVM_trait_B_06.12.2025.pdf", 
    )
coefplot(fit_env, cex.ylab = 0.7, mar = c(4, 12, 2, 1), mfrow=c(1,1))
dev.off()
## quartz_off_screen 
##                 2

Sediment

library(mvabund)
library(gllvm)
library(tidyverse)

trait_S<- trait_prct[trait_prct$substrate=='S',]
trait_S<- trait_S[!is.na(trait_S$alpha.cent.wt),]

traitemp_S<- trait_S[,97:116]
traitemp_S<-traitemp_S[,colSums(traitemp_S)>0]
#Reorder data table from most abundant to least abundant
traitemp_S <- traitemp_S[,order(colSums(-traitemp_S,na.rm=TRUE))]
traitemp_S <- traitemp_S[,apply(traitemp_S,2,function(x) sum(x > 0))>1]


trait_S <- merge(traitemp_S, samdftest,
                  by="row.names", all=FALSE)
rownames(trait_S) <- trait_S[,1]
trait_S <- trait_S[,-1]
trait_S$annual_percent_wet<- trait_S$prc_wet
#detach("package:linkET", unload=TRUE)
#trait_S$percentwet_11month<- trait_S$percentwet_bonus

S_abun<-trait_S[,1:19]
## select functional groups that make up at least 5% of reads
S_abun<-S_abun[,colMeans(S_abun)>1]
X <- as.matrix(trait_S[,c("annual_percent_wet","alpha.cent.wt","tempC_mean","burn_interval")])
#y<-as.numeric(as.matrix(S_abun))
y<-as.matrix(as.tibble(S_abun))

gllvm(y, family = "poisson") 
## Call: 
## gllvm(y = y, family = "poisson")
## family: 
## [1] "poisson"
## method: 
## [1] "VA"
## 
## log-likelihood:  -1571.522 
## Residual degrees of freedom:  593 
## AIC:  3237.045 
## AICc:  3244.666 
## BIC:  3446.734
gllvm(y, family = "negative.binomial") 
## Call: 
## gllvm(y = y, family = "negative.binomial")
## family: 
## [1] "negative.binomial"
## method: 
## [1] "VA"
## 
## log-likelihood:  -1604.561 
## Residual degrees of freedom:  577 
## AIC:  3335.123 
## AICc:  3349.123 
## BIC:  3616.195
## selecting poisson due to lower AIC

### lv 1 has lowest AIC
gllvm(y, X, family = "poisson", num.lv = 0,
                 formula = ~ alpha.cent.wt+annual_percent_wet
                 , seed = 1995)
## Call: 
## gllvm(y = y, X = X, formula = ~alpha.cent.wt + annual_percent_wet, 
##     family = "poisson", num.lv = 0, seed = 1995)
## family: 
## [1] "poisson"
## method: 
## [1] "VA"
## 
## log-likelihood:  -1593.036 
## Residual degrees of freedom:  592 
## AIC:  3282.072 
## AICc:  3290.032 
## BIC:  3496.223
gllvm(y, X, family = "poisson", num.lv = 1,
                 formula = ~ alpha.cent.wt+annual_percent_wet
                 , seed = 1995)
## Call: 
## gllvm(y = y, X = X, formula = ~alpha.cent.wt + annual_percent_wet, 
##     family = "poisson", num.lv = 1, seed = 1995)
## family: 
## [1] "poisson"
## method: 
## [1] "VA"
## 
## log-likelihood:  -1551.05 
## Residual degrees of freedom:  576 
## AIC:  3230.101 
## AICc:  3244.57 
## BIC:  3515.635
gllvm(y, X, family = "poisson", num.lv = 2,
                 formula = ~ alpha.cent.wt+annual_percent_wet
                 , seed = 1995)
## Call: 
## gllvm(y = y, X = X, formula = ~alpha.cent.wt + annual_percent_wet, 
##     family = "poisson", num.lv = 2, seed = 1995)
## family: 
## [1] "poisson"
## method: 
## [1] "VA"
## 
## log-likelihood:  -1551.05 
## Residual degrees of freedom:  561 
## AIC:  3260.101 
## AICc:  3282.672 
## BIC:  3612.557
#fit_ord<- gllvm(y, family = "negative.binomial")
#ordiplot(fit_ord, biplot=TRUE, ind.spp=14)

fit_env <- gllvm(y, X, family = "poisson", num.lv = 1,
                 formula = ~ alpha.cent.wt+annual_percent_wet
                 , seed = 1995)
coefplot(fit_env, cex.ylab = 0.7, mar = c(4, 9, 2, 1), mfrow=c(1,1))

pdf("GLLVM_trait_S_06.12.2025.pdf", 
    )
coefplot(fit_env, cex.ylab = 0.7, mar = c(4, 12, 2, 1), mfrow=c(1,1))
dev.off()
## quartz_off_screen 
##                 2