-
Notifications
You must be signed in to change notification settings - Fork 1
/
template_analysis_report_pdf.Rmd
119 lines (103 loc) · 4.38 KB
/
template_analysis_report_pdf.Rmd
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
---
title: "*pfhrp2/3* Planner: Analysis report"
subtitle: "*Downloaded on: `r Sys.Date()`| DRpower interactive app v1.0.0*"
output:
pdf_document:
fig_caption: yes
number_sections: no
latex_engine: xelatex
df_print: kable
fig_width: 6
fig_height: 4
header-includes:
- \usepackage{booktabs}
mainfont: Arial
documentclass: article
links-as-notes: true
geometry:
- margin=0.75in
- top=0.5in
papersize: letter
always_allow_html: true
params:
analysis_prevthresh: NA
analysis_nclusters: NA
analysis_study_data: NA
analysis_prevoutput: NA
analysis_iccoutput: NA
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(bslib)
library(kableExtra)
set.seed(10)
```
```{r create objects from params, echo=F}
prev_thresh <- params$analysis_prevthresh
nclusters <- params$analysis_nclusters
study_data <- params$analysis_study_data
prev_output <- params$analysis_prevoutput
icc_output <- params$analysis_iccoutput
```
## Background
<!-- \begin{center}\rule{7in}{0.4pt}\end{center} -->
This report presents the results generated by using the [*pfhrp2/3* planner web application](https://github.com/shaziaruybal/DRpower_app). This application was used to analyze data from a *pfhrp2/3* deletion prevalence study and estimate prevalence and determine if it is above a set threshold. For more information on the statistical method used, see the [DRpower R package website](https://mrc-ide.github.io/DRpower).
## Study details
<!-- \begin{center}\rule{7in}{0.4pt}\end{center} -->
A total of `r params$analysis_nclusters` clusters were surveyed in this *pfhrp2/3* deletion prevalence study. The observed counts of *pfhrp2/3* deletions and the sample sizes in each cluster are shown below:
```{r echo=F}
kable(study_data,
format = "latex",
booktabs = T) %>%
kable_styling(
bootstrap_options = "striped",
position = "left",
full_width = F)
```
### Estimated prevalence
<!-- \begin{center}\rule{7in}{0.4pt}\end{center} -->
To estimate the prevalence of *pfhrp2/3* deletions in this study we used the [DRpower R package](https://mrc-ide.github.io/DRpower) to test whether the observed prevalence in this study was above or below a prevalence threshold of `r params$analysis_prevthresh`%.
We estimate that the prevalence of *pfhrp2/3* deletions is `r round(as.numeric(prev_output$MAP),2)`% (95% CrI: `r round(as.numeric(prev_output$CrI_lower),2)`-`r round(as.numeric(prev_output$CrI_upper),2)`%).
<!-- Add here the rendering of the conclusion text if prob is > or < 95% -->
```{r fig.height=3, fig.width=3, echo=F}
prev_output %>%
ggplot() +
geom_segment(aes(x = " ", xend = " ", y = CrI_lower, yend = CrI_upper),
color = "gray20", linewidth = 1) +
geom_point(aes(x = " ", y = MAP),
size = 2,
shape = 21,
fill = "mediumpurple") +
# use the user-entered prev_thresh to plot threshold line
geom_hline(aes(yintercept = as.numeric(params$analysis_prevthresh)),
color = "darkgrey",
linetype = "dashed") +
# use the user-entered prev_thresh to plot threshold line
geom_text(aes(x= " ",
y = (as.numeric(params$analysis_prevthresh))+3,
label = paste0(ceiling(as.numeric(params$analysis_prevthresh)),"% threshold")),
color = "darkgrey", size = 3) +
scale_y_continuous(labels = scales::percent_format(1, scale = 1), limits = c(0,100)) +
labs(x = "",
y = "Estimated prevalence") +
theme_light() +
theme(text = element_text(size = 12))
```
### Estimated intra-cluster correlation (ICC)
We estimate that the intra-cluster correlation is `r round(as.numeric(icc_output$MAP),2)` (95% CrI: `r round(as.numeric(icc_output$CrI_lower), 2)`-`r round(as.numeric(icc_output$CrI_upper),2)`).
```{r fig.height=3, fig.width=3, echo=F}
icc_output %>%
ggplot() +
geom_segment(aes(x = " ", xend = " ", y = CrI_lower, yend = CrI_upper),
color = "gray20", linewidth = 1) +
geom_point(aes(x = " ", y = MAP),
size = 2,
shape = 21,
fill = "mediumpurple") +
scale_y_continuous(limits = c(0,1)) +
labs(x = "",
y = "Estimated ICC") +
theme_light() +
theme(text = element_text(size = 12))
```