Skip to content

Commit 5a0a437

Browse files
author
Liam Shaw
committed
adding table 3
1 parent db318ec commit 5a0a437

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"","","Value","Z statistic","Chi-sq statistic","P-value","Effective Degrees of Freedom","Percent Dev. Explained","model"
2+
"1","Intercept","1.28","23.24",NA,"<0.001",NA,NA,"Bacterial richness per species"
3+
"2","Intercept","1.28","23.24",NA,"<0.001",NA,NA,NA
4+
"3","hDiseaseZACitesLn",NA,NA,"584.96","<0.001","3.63","81.55%",NA
5+
"4","hOrderCHIROPTERA",NA,NA,"7.5","0.003","0.86","1.56%",NA
6+
"5","hOrderDIDELPHIMORPHIA",NA,NA,"2.81","0.058","0.78","0.67%",NA
7+
"6","hOrderDIPROTODONTIA",NA,NA,"7.03","0.005","0.89","1.69%",NA
8+
"7","hOrderLAGOMORPHA",NA,NA,"1.19","0.174","0.61","0.32%",NA
9+
"8","hOrderPRIMATES",NA,NA,"10.36","0.002","0.97","1.8%",NA
10+
"9","hOrderRODENTIA",NA,NA,"47.45","<0.001","1","7.88%",NA
11+
"10","LnAreaHost",NA,NA,"10.89","0.117","4.13","1.88%",NA
12+
"11","S20",NA,NA,"46.42","<0.001","1.15","2.65%",NA
13+
"12","Intercept","1.11","28.65",NA,"<0.001",NA,NA,"Viral richness per species"
14+
"13","Intercept","1.11","28.65",NA,"<0.001",NA,NA,NA
15+
"14","hDiseaseZACitesLn",NA,NA,"2884.3","<0.001","4.51","76.59%",NA
16+
"15","hMassGramsPVR",NA,NA,"5.73","0.193","3.2","0.8%",NA
17+
"16","hOrderCETARTIODACTYLA",NA,NA,"35.02","<0.001","0.95","2.93%",NA
18+
"17","hOrderCHIROPTERA",NA,NA,"18.81","<0.001","0.97","2.05%",NA
19+
"18","hOrderCINGULATA",NA,NA,"1.1","0.144","0.51","0.18%",NA
20+
"19","hOrderDIDELPHIMORPHIA",NA,NA,"1.88","0.097","0.67","0.3%",NA
21+
"20","hOrderEULIPOTYPHLA",NA,NA,"8.81","0.002","0.9","1.3%",NA
22+
"21","hOrderPRIMATES",NA,NA,"105.73","<0.001","0.99","7.52%",NA
23+
"22","LnAreaHost",NA,NA,"119.01","<0.001","3.16","5.72%",NA
24+
"23","S20",NA,NA,"41.31","<0.001","2.96","2.61%",NA
25+
"24","Intercept","-1.46","-10.63",NA,"<0.001",NA,NA,"Zoonotic potential (bacteria)"
26+
"25","Intercept","-1.46","-10.63",NA,"<0.001",NA,NA,NA
27+
"26","gramGrampositive",NA,NA,"0.54","0.277","0.29","0.15%",NA
28+
"27","motility",NA,NA,"2.64","0.152","0.66","0.55%",NA
29+
"28","oxygenFacultativelyanaerobic",NA,NA,"12.04","0.01","0.9","1.79%",NA
30+
"29","oxygenMicroaerophilic",NA,NA,"17.75","0.005","0.92","2.04%",NA
31+
"30","PHB.median",NA,NA,"159.77","<0.001","4.82","47.81%",NA
32+
"31","PubMed.records.log",NA,NA,"151.9","<0.001","2.59","42.04%",NA
33+
"32","vector.borne",NA,NA,"50.49","<0.001","0.95","5.63%",NA
34+
"33","Intercept","-1.76","-10.59",NA,"<0.001",NA,NA,"Zoonotic potential (viruses)"
35+
"34","Intercept","-1.76","-10.59",NA,"<0.001",NA,NA,NA
36+
"35","genome.typenegativessRNA",NA,NA,"28.51","<0.001","0.99","11.28%",NA
37+
"36","genome.typepositivessRNA",NA,NA,"39.61","0.003","0.89","5.14%",NA
38+
"37","PHB.mean",NA,NA,"68.13","<0.001","3.36","36.66%",NA
39+
"38","SRA.records.log",NA,NA,"54.72","<0.001","3.65","33.33%",NA
40+
"39","vector.borne",NA,NA,"41.05","<0.001","0.95","13.59%",NA

scripts/08-tables-GAMs.R

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
library(mgcv)
2+
library(stringi)
3+
library(dplyr)
4+
library(purrr)
5+
library(officer)
6+
source('scripts/Olival_fit_gam.R')
7+
8+
top_models <- lapply(c("intermediates/all_bacteria_models.rds", "intermediates//all_viruses_models.rds", "intermediates/zoonotic-GAM-fits-bacteria.rds", "intermediates/zoonotic-GAM-fits-virus.rds"), function(mods) {
9+
readRDS(mods)$model[[1]]
10+
})
11+
12+
model_names = c("Bacterial richness per species",
13+
"Viral richness per species",
14+
"Zoonotic potential (bacteria)",
15+
"Zoonotic potential (viruses)")
16+
17+
model_tables = map2(top_models, model_names, function(modd, model_name) {
18+
summ = summary(modd)
19+
summ$p.table
20+
summ$s.table
21+
rel_dev = get_relative_contribs(modd)
22+
23+
bind_rows(data_frame(Term = stri_extract_first_regex(rownames(summ$p.table), "(?<=\\()[^\\)]+(?=\\))"),
24+
Value = round(summ$p.table[,1], 2),
25+
`Z statistic` = round(summ$p.table[,3], 2),
26+
`Chi-sq statistic` = NA,
27+
`P-value` = ifelse(summ$p.table[,4] > 0.001, as.character(round(summ$p.table[,4], digits=3)), "<0.001"),
28+
`Effective Degrees of Freedom` = NA,
29+
`Percent Dev. Explained` = as.character(NA),
30+
model = model_name),
31+
data_frame(Term = stri_extract_first_regex(rownames(summ$s.table), "(?<=s\\()[^\\)]+(?=\\))"),
32+
Value = NA,
33+
`Z statistic` = NA,
34+
`Chi-sq statistic` = round(summ$s.table[,3], 2),
35+
`P-value` = ifelse(summ$s.table[,4] > 0.001, as.character(round(summ$s.table[,4], digits=3)), "<0.001"),
36+
`Effective Degrees of Freedom` = round(summ$s.table[,1], 2),
37+
`Percent Dev. Explained`= paste0(round(100*rel_dev$rel_deviance_explained, 2), "%"),
38+
model=model_name))
39+
40+
})
41+
42+
model_rows = map_int(model_tables, nrow)
43+
model_tables2 = model_tables %>%
44+
map(~ rbind(.[1,], .)) %>%
45+
map(function(x) {
46+
x$model = c(x$model[1], rep(NA, nrow(x) -1))
47+
return(x)
48+
}) %>%
49+
bind_rows %>%
50+
mutate_each(funs(as.character), -Term, -model) #%>%
51+
#arrange(model, Term !="Intercept") %>%
52+
dplyr::select(8, 1:7)
53+
54+
names(model_tables2)[1] <- ""
55+
56+
print(kable(model_tables2))
57+
write.csv(model_tables2, file='figures/Table-3-summary-best-fit-GAMs.csv')
58+
59+

0 commit comments

Comments
 (0)