-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path06_BasicNotebook.Rmd
110 lines (86 loc) · 2.4 KB
/
06_BasicNotebook.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
---
output: html_document
---
```{r Setup, setup, include=FALSE}
knitr::opts_chunk$set(message = FALSE, echo = FALSE, warning = FALSE)
```
```{r, message = FALSE}
library(data.table)
library(tidyverse)
library(kableExtra)
library(reactable)
library(htmltools)
library(ggpubr)
```
```{r}
table <- fread("data_input/test01_input.csv")
file_id <- "test"
```
# Report for experiment `r file_id` {.tabset .tabset-fade .tabset-pills}
## Boxplot
```{r}
#calculating yield in 3 different ways:
table <- table[,yield01:=elute.vol*Q.conc][]
table$yield02 <- table$elute.vol*table$Q.conc
table <- table %>% mutate(yield03 = elute.vol*Q.conc)
```
```{r}
ggplot(table, aes(x=reformatter, y=Q.conc, color=plate)) +
geom_boxplot(outlier.colour = 'grey', outlier.alpha = 0.5)
```
## Slopes
```{r}
#alternative way of calculating max per plate and slope using tidyverse:
table <- table %>%
group_by(`96w.pos`) %>%
mutate(plate.max = max(Q.conc))
table <- table %>%
mutate(new.plate.slope = case_when(
Q.conc==plate.max ~ plate,
TRUE ~ "eppen_221123"
))
```
```{r}
#a better way avoiding hardcoded names
widetable <- table %>%
select(plate, `96w.pos`, Q.conc) %>%
spread(plate, Q.conc)
widetable$plate.slope <- colnames(widetable)[apply(widetable,1,which.max)]
table <- left_join(table, widetable)
```
```{r}
plot <- ggplot(table, aes(x=plate, y=Q.conc)) +
geom_point(aes(fill=plate)) +
geom_line(aes(group=`96w.pos`, color=plate.slope)) +
labs(x='Reformatted by whom', y='Extraction concentration (ng/uL)')
```
#### Summary Table
```{r}
summary_table <- widetable %>%
group_by(plate.slope) %>%
summarise(samples = n())
summary_table_formatted <- ggtexttable(summary_table, rows = NULL, theme = ttheme("blank"))
```
```{r, fig.height=6, fig.width=9}
ggarrange(plot, summary_table_formatted, ncol=2, widths=c(3,1))
```
## Table
```{r, fig.width=9}
htmltools::browsable(
tagList(
tags$button(
tagList(fontawesome::fa("download"), "Download as CSV"),
onclick = "Reactable.downloadDataCSV('table-download', 'table.csv')"
),
table %>%
reactable(filterable = TRUE,
pagination = FALSE,
searchable = TRUE,
elementId = "table-download")
)
)
```
#
::: {#box style="color: white; background-color:red; font-size: 20px; text-align:center; font-weight: bold;"}
To run as an automatic report use the script [run_Notebook.R](run_Notebook.R)
:::