forked from coenzymeQbiology/CoQPrimaryDef
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
209 lines (129 loc) · 3.66 KB
/
index.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
---
title: "Clinical manifestations of primary CoQ deficiencies"
author: "María Alcázar-Fabra & Gloria Brea-Calvo"
date: ""
output:
html_document:
fig_caption: yes
fig_height: 4
includes:
in_header: header.html
self_contained: no
theme: cerulean
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, message = FALSE)
```
```{r}
library(dplyr)
library(assertr)
library(ggplot2)
#source("render_toc.R")
```
```{r}
#render_toc("index.Rmd", base_level = 2, toc_depth = 1)
```
```{r read.data, include=FALSE}
datos <- gsheet::gsheet2tbl("https://docs.google.com/spreadsheets/d/1zCc9r7Uy_6ujOU5qXc7VOXuN4OSvIJg5Tx9iqWw6swY/edit?usp=sharing", sheetid = 1) %>%
arrange(group)
npatients <- gsheet::gsheet2tbl("https://docs.google.com/spreadsheets/d/1zCc9r7Uy_6ujOU5qXc7VOXuN4OSvIJg5Tx9iqWw6swY/edit?usp=sharing#gid=1452337852")
datos %>%
# verify(ncol(.) == 12) %>%
verify(names(datos)[1:2] == c("group", "symptom")) %>%
verify(all.equal(names(datos)[3:ncol(datos)], names(npatients)))
npatients <- as.numeric(npatients)
```
```{r percent}
percent <- datos
for (j in 3:ncol(datos)) {
percent[, j] <- 100*(percent[, j]/npatients[j - 2])
}
```
```{r datos.long}
datos.long <- percent %>%
tidyr::pivot_longer(cols = 3:ncol(datos), names_to = "gene") %>%
mutate(gene = factor(gene, levels = names(datos)[3:ncol(datos)]))
```
```{r heatmap.fun}
plotfun <- function(df = datos.long, grupo = NULL, npat = npatients) {
datos.sub <- df %>%
dplyr::filter(group == grupo) %>%
mutate(symptom = factor(symptom,
levels = sort(unique(symptom), decreasing = TRUE)))
## Sort rows by prevalence
df2 <- datos.sub %>%
dplyr::filter(value > 0) %>%
group_by(symptom) %>%
summarise(n.site = sum(value)) %>%
arrange(n.site)
datos.sub$symptom <- factor(datos.sub$symptom, levels = df2$symptom)
patients <- data.frame(gene = unique(df$gene),
n.pat = npat)
heatm <- ggplot(datos.sub) +
aes(x = gene, y = symptom) +
geom_tile(aes(fill = value), colour = "grey80",
height = 1, width = 1) +
#scale_fill_viridis(name = "% patients", option = "magma") +
scale_fill_distiller(name = "% patients", type = "seq",
palette = "YlGnBu", direction = 1,
limits = c(0, 100)) +
coord_equal(clip = "off") +
scale_x_discrete(position = "top") +
theme(axis.text.x.top = element_text(angle = 90, hjust = 0, vjust = 0.5)) +
xlab("") +
ylab("") +
theme(plot.margin = unit(c(0, 0, 0.5, 0), "cm")) +
theme(panel.background = element_blank()) +
geom_text(data = patients, aes(y = 0, label = n.pat), size = 3)
heatm
}
```
-----------------------------------------------------------------
<br>
Aquí va texto
<br>
## {.tabset .tabset-fade .tabset-pills}
### The tool
Here you can ...
Go to table to search the data
### CSN
```{r out.width='100%', fig.height=9}
plotfun(grupo = "CSN")
```
### Heart
```{r out.width='100%'}
plotfun(grupo = "Heart")
```
### Kidney
```{r out.width='100%'}
plotfun(grupo = "Kidney")
```
### Liver
```{r out.width='100%'}
plotfun(grupo = "Liver")
```
### Lung
```{r out.width='100%'}
plotfun(grupo = "Lung")
```
### Muscle
```{r out.width='100%'}
plotfun(grupo = "Muscle")
```
### PNS/Sensory organs
```{r out.width='100%'}
plotfun(grupo = "PNS/sensory organs")
```
### Other
```{r out.width='100%'}
plotfun(grupo = "Other")
```
### Table
In this table you can search by symptom (and link to symptom description). Numbers represent number of patients
```{r out.width='100%'}
library(DT)
datatable(datos, filter = "top", rownames = FALSE)
```
## {-}
Epílogo...
Last update: `r Sys.Date()`