-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlot_Polarella_vs_Hill.R
90 lines (60 loc) · 2.41 KB
/
Plot_Polarella_vs_Hill.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
library(readxl)
library(writexl)
library(tidyverse)
library(janitor)
library(ggpubr)
library(gam)
library(visreg)
library(AER)
library(mgcv)
install.packages("visreg")
#read dataframe Polarella
df_polarella <- read_excel("input/ATP23-012_Analiza.xlsx", sheet = "P.glacialis (%)") %>%
filter(Reference == "All identified Dinoflagellata") %>%
select(-Reference)
df_polarella_t <- t(df_polarella)
df_polarella <- data.frame(df_polarella_t) %>%
row_to_names(row_number = 1) %>%
rownames_to_column("DNA_ID")
df_polarella$`Polarella_glacialis` <- df_polarella$`6.66666666666667`
df_polarella <- df_polarella[,-2]
#df_polarella$`Polarella glacialis` = as.numeric(as.character(df_polarella$`Polarella glacialis`))
write_xlsx(df_polarella, "output/Polarella_abundance.xlsx")
#read dataframe Hill numbers
df_hills <- read_excel("output/hill_Antarctica.xlsx")
#merge dataframes
df <- inner_join(df_polarella, df_hills)
df_marian <- df %>%
filter(Site == "Marian Cove")
df_borgen <- df %>%
filter(Site == "Börgen Bay")
df_sheldon <- df %>%
filter(Site == "Sheldon Cove")
m1_marian <- gam(Hill_N0 ~ Polarella_glacialis,
data = df_marian, family = "poisson"); summary(m1_marian)
visreg(m1_marian, scale = "response")
m1_borgen <- gam(Hill_N0 ~ Polarella_glacialis,
data = df_borgen, family = "poisson"); summary(m1_borgen)
visreg(m1_borgen, scale = "response")
m1_sheldon <- gam(Hill_N1 ~ Polarella_glacialis,
data = df_sheldon, family = "poisson"); summary(m1_sheldon)
visreg(m1_sheldon, scale = "response")
hist(residuals(m1, type = "pearson"))
dispersiontest(m1)
library(glmmTMB)
library(car)
m0 <- glmmTMB(Hill_N0 ~ 1,
data = df_sheldon_bio, family = "nbinom2"); summary(m0)
m2 <- glmmTMB(Hill_N0 ~ Polarella_glacialis,
data = df_sheldon_bio, family = "nbinom2"); summary(m2)
m3 <- glmmTMB(Hill_N0 ~ Polarella_glacialis + HBI_III,
data = df_sheldon_bio, family = "nbinom2"); summary(m3)
visreg(m2, "Polarella_glacialis", scale = "response")
visreg(m2, "HBI_III", scale = "response")
plot(residuals(m2) ~ fitted(m2))
anova(m0, m2, m3, test = "Chisq")
AIC(m0,m2,m3)
exp(-0.031014)
biomarkers <- readxl::read_xlsx("input/Dating_biomarkers.xlsx")
df_sheldon_bio <- inner_join(df_sheldon, biomarkers)
names(df_sheldon_bio)[2] <- "Polarella_glacialis"