Compute and display confidence interval

This commit is contained in:
Elias Projahn 2022-06-06 16:15:31 +02:00
parent 882891da53
commit add8a4bd76

View file

@ -53,24 +53,39 @@ server <- function(input, output, session) {
reference <- ranked_data()[!gene %chin% comparison_gene_ids, score] reference <- ranked_data()[!gene %chin% comparison_gene_ids, score]
comparison <- ranked_data()[gene %chin% comparison_gene_ids, score] comparison <- ranked_data()[gene %chin% comparison_gene_ids, score]
p_value <- stats::wilcox.test( reference_median <- format(
round(stats::median(reference), digits = 3),
nsmall = 3
)
comparison_median <- format(
round(stats::median(comparison), digits = 3),
nsmall = 3
)
test_result <- stats::wilcox.test(
x = comparison, x = comparison,
y = reference, y = reference,
alternative = "greater" conf.int = TRUE
)$p.value )
reference_median <- stats::median(reference) p_value <- format(
comparison_median <- stats::median(comparison) round(test_result$p.value, digits = 4),
nsmall = 4,
scientific = FALSE
)
lower <- format(round(test_result$conf.int[1], digits = 3), nsmall = 3)
upper <- format(round(test_result$conf.int[2], digits = 3), nsmall = 3)
HTML(glue::glue( HTML(glue::glue(
"The p-value for the alternative hypothesis that your genes have ", "The p-value for the alternative hypothesis that your genes have ",
"higher scores than other genes is <b>{format(round(p_value, ", "different scores than other genes is <b>{p_value}</b>. This value ",
"digits = 4), nsmall = 4, scientific = FALSE)}</b>. This value was ", "was computed using a Wilcoxon rank sum test. Based on a 95% ",
"computed using a Wilcoxon rank sum test. The median score of your ", "confidence, the difference in scores is between <b>{lower}</b> and ",
"genes is <b>{format(round(comparison_median, digits = 2), ", "<b>{upper}</b>. The median score of your genes is ",
"nsmall = 2, scientific = FALSE)}</b> compared to a median score of ", "<b>{comparison_median}</b> compared to a median score of ",
"<b>{format(round(reference_median, digits = 2), nsmall = 2, ", "<b>{reference_median}</b> of the other genes."
"scientific = FALSE)}</b> of the other genes."
)) ))
} }
}) })