-
Notifications
You must be signed in to change notification settings - Fork 0
/
009_AlphaDiversity_Fungi.R
149 lines (108 loc) · 6.16 KB
/
009_AlphaDiversity_Fungi.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# Script for comparing alpha diversity (Observed, Simpson, and Shannon)
# 1. With filtered ITS data as a check.
# permanova of alpha diversity values
set.seed(18)
library(tidyverse)
library(devtools)
#devtools::install_github("jbisanz/qiime2R")
library(qiime2R)
library(ggplot2)
library(phyloseq)
library(gridExtra)
library(vegan)
library(dplyr)
library(scales)
library(grid)
library(reshape2)
library(ggpubr)
#turn off scientific notation
options(scipen=999)
setwd("//wsl.localhost/Ubuntu-18.04/home/crschul/IndigoAgMicrobiome")
# Read in the data
metadata <- read.csv("Metadata_Indigo_Clean.tsv", header = TRUE, sep = "\t")
load("phy_filtered.rdata")
phy_filtered
# have to remove the sloth fur sample
phy_filtered = subset_samples(phy_filtered, tissue != "Sloth fur")
# try with rareified data
phy_filtered <- rarefy_even_depth(phy_filtered, sample.size = 500, replace = FALSE)
soil <- subset_samples(phy_filtered, tissue=="Soil")
rootwash <- subset_samples(phy_filtered, tissue=="Root wash")
root <- subset_samples(phy_filtered, tissue=="Root")
leaf <- subset_samples(phy_filtered, tissue=="Leaf")
alpha_plot1 <- plot_richness(phy_filtered, x="tissue", measures=c("Observed", "Shannon", "Simpson"),
color = "Location",
title = "Alpha Diversity: Location by Tissues") + geom_point(alpha = .05)
alpha_plot1
soil_alpha <- plot_richness(soil, x = "Location",measures=c("Observed", "Shannon", "Simpson"),
color = "Location",
title = "Alpha Diversity: Fungus - Soil") + theme(legend.position = "none") +
geom_point(position = position_dodge(width = .5))
soil_alpha$layers <- soil_alpha$layers[-1]
soil_alpha
rootwash_alpha <- plot_richness(rootwash, x = "Location",measures=c("Observed", "Shannon", "Simpson"),
color = "Location",
title = "Alpha Diversity: Fungus - Root Wash") + theme(legend.position = "none") +
geom_point(position = position_dodge(width = .5))
rootwash_alpha$layers <- rootwash_alpha$layers[-1]
rootwash_alpha
root_alpha <- plot_richness(root, x = "Location",measures=c("Observed", "Shannon", "Simpson"),
color = "Location",
title = "Alpha Diversity: Fungus - Roots") + theme(legend.position = "none") +
geom_point(position = position_dodge(width = .5))
root_alpha$layers <- root_alpha$layers[-1]
root_alpha
leaf_alpha <- plot_richness(leaf, x = "Location",measures=c("Observed", "Shannon", "Simpson"),
color = "Location",
title = "Alpha Diversity: Fungus - Leaf") + theme(legend.position = "none") +
geom_point(position = position_dodge(width = .5))
leaf_alpha$layers <- leaf_alpha$layers[-1]
leaf_alpha
alpha_diversity <- ggarrange(soil_alpha, rootwash_alpha, root_alpha, leaf_alpha, ncol = 1, nrow = 4, labels = c("A","B","C","D"))
alpha_diversity # Figure for finaplot
ggsave("FungalAlphaDiversity.png", plot = alpha_diversity, path = "Results_Figs_Tables/Quick_Figures", dpi = 700,
width = 10, height = 10, units = c("in"), device = "png")
######## it looks like location may have an effect on root alpha diversity
### Stats
library(vegan)
# roots: location is significant for all rarefied and unrarified
root_rich <- estimate_richness(root ,measures = c("Observed", "Shannon", "Simpson") )
root_rich <- tibble::rownames_to_column(root_rich, "Sample_ID")
root_rich <- merge(root_rich,metadata)
adonis2(root_rich$Observed ~ Location + temp + precip + Soil.pH + Organic.Matter, data = root_rich,
by = "margin",na.action = na.exclude)
adonis2(root_rich$Shannon ~ Location + temp + precip + Soil.pH + Organic.Matter, data = root_rich,
by = "margin",na.action = na.exclude)
adonis2(root_rich$Simpson ~ Location + temp + precip + Soil.pH + Organic.Matter, data = root_rich,
by = "margin",na.action = na.exclude)
# soil - only Observed is significant
soil_rich <- estimate_richness(soil,measures = c("Observed", "Shannon", "Simpson") )
soil_rich <- tibble::rownames_to_column(soil_rich, "Sample_ID")
soil_rich <- merge(soil_rich,metadata)
adonis2(soil_rich$Observed ~ Location + temp + precip + Soil.pH + Organic.Matter, data = soil_rich,
by = "margin",na.action = na.exclude)
adonis2(soil_rich$Shannon ~ Location + temp + precip + Soil.pH + Organic.Matter, data = soil_rich,
by = "margin",na.action = na.exclude)
adonis2(soil_rich$Simpson ~ Location + temp + precip + Soil.pH + Organic.Matter, data = soil_rich,
by = "margin",na.action = na.exclude)
# rootwash - only observed significant
rootwash_rich <- estimate_richness(rootwash ,measures = c("Observed", "Shannon", "Simpson") )
rootwash_rich <- tibble::rownames_to_column(rootwash_rich, "Sample_ID")
rootwash_rich <- merge(rootwash_rich,metadata)
adonis2(rootwash_rich$Observed ~ Location + temp + precip + Soil.pH + Organic.Matter, data = rootwash_rich,
by = "margin",na.action = na.exclude)
adonis2(rootwash_rich$Shannon ~ Location + temp + precip + Soil.pH + Organic.Matter, data = rootwash_rich,
by = "margin",na.action = na.exclude)
adonis2(rootwash_rich$Simpson ~ Location + temp + precip + Soil.pH + Organic.Matter, data = rootwash_rich,
by = "margin",na.action = na.exclude)
# leafs - all significant!!!
leaf_rich <- estimate_richness(leaf ,measures = c("Observed", "Shannon", "Simpson") )
leaf_rich <- tibble::rownames_to_column(leaf_rich, "Sample_ID")
leaf_rich <- merge(leaf_rich,metadata)
adonis2(leaf_rich$Observed ~ Location + temp + precip + Soil.pH + Organic.Matter, data = leaf_rich,
by = "margin",na.action = na.exclude)
adonis2(leaf_rich$Shannon ~ Location + temp + precip + Soil.pH + Organic.Matter, data = leaf_rich,
by = "margin",na.action = na.exclude)
adonis2(leaf_rich$Simpson ~ Location + temp + precip + Soil.pH + Organic.Matter, data = leaf_rich,
by = "margin",na.action = na.exclude)
# leaf and root alpha values are significantly changed by location (rarefied and unrarified) while soil and rootwash are not!