Skip to content

Commit 01fbb36

Browse files
committed
Update p-value calculation
1 parent d8d9ed8 commit 01fbb36

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

workflow/scripts/report/NV_description.R

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -488,12 +488,9 @@ model <- lm(n ~ CollectionDate, data = figur_SNP_table)
488488

489489
# Calculate correlation, if possible
490490
if (nrow(figur_SNP_table) > 2) {
491-
p.cor <- cor.test(
492-
figur_SNP_table$n,
493-
as.numeric(figur_SNP_table$CollectionDate)
494-
)$p.value
491+
p.value <- summary(model)$coefficients[2,4]
495492
} else {
496-
p.cor <- NA
493+
p.value <- NA
497494
}
498495

499496
list(
@@ -502,7 +499,7 @@ list(
502499
"window" = snakemake@params[["window"]],
503500
"step" = snakemake@params[["step"]],
504501
"r2" = summary(model)$r.squared[[1]],
505-
"value" = ifelse(p.cor < 0.001, "< 0.001", p.cor)
502+
"value" = ifelse(p.value < 0.001, "< 0.001", p.value)
506503
) %>%
507504
toJSON() %>%
508505
write(snakemake@output[["json"]])

workflow/scripts/report/phylo_plots.R

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@ tempest %>%
277277

278278
# TEMPEST STATS
279279
model <- lm(distance ~ date_interval, data = tempest)
280+
p.value <- summary(model)$coefficients[2,4]
280281

281282
# TREE STATS
282283
study.node <- tree_ml$node.label[study.mrca - length(tip.color)]
@@ -285,11 +286,7 @@ monophyletic <- ifelse(is.monophyletic(tree_ml, study_names), "are", "are not")
285286
list(
286287
"sub_rate" = model$coefficients[[2]] * 365,
287288
"r2" = summary(model)$r.squared[[1]],
288-
"pvalue" = ifelse(
289-
cor.test(tempest$distance, tempest$date_interval)$p.value < 0.001,
290-
"< 0.001",
291-
cor.test(tempest$distance, tempest$date_interval)$p.value
292-
),
289+
"pvalue" = ifelse(p.value < 0.001, "< 0.001", p.value),
293290
"boot" = strsplit(study.node, "/")[[1]][2] %>% as.numeric(),
294291
"alrt" = strsplit(study.node, "/")[[1]][1] %>% as.numeric(),
295292
"monophyly" = monophyletic,

0 commit comments

Comments
 (0)