-
Notifications
You must be signed in to change notification settings - Fork 0
/
eurofins_assays.Rmd
191 lines (162 loc) · 5.6 KB
/
eurofins_assays.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
## Scrape Eurofins kinase assay datasheets
Eurofins doesn't make information about the kinases they measure available in a
machine-readable format. This is a quick and dirty script to scrape the
datasheets for each target and extract whether the target is mutated,
phosphorylated, and what form the kinase is assayed in. E.g. only a
domain or the entire kinase.
```{r}
library(tidyverse)
library(rvest)
library(qs)
library(synExtra)
synapser::synLogin()
```
```{r}
assay_index <- read_html("https://www.discoverx.com/services/drug-discovery-development-services/kinase-profiling/kinomescan#kinase-assay-list")
assay_table_node <- assay_index %>%
html_elements("table") %>%
magrittr::extract2(3)
assay_table_raw <- html_table(assay_table_node, header = TRUE)
```
```{r}
assay_links <- assay_table_node %>%
html_elements("td a") %>%
html_attr("href") %>%
str_subset("kinase-data-sheets") %>%
str_replace(fixed("../../.."), "https://www.discoverx.com")
length(assay_links) == nrow(assay_table_raw)
assay_datasheet_nodes <- map(assay_links, read_html)
```
Fetch each datasheet and extract the assay information. Put reference compound
information in a separate column (not particularly interesting).
```{r}
extract_assay_info <- function(datasheet_node) {
vals_raw <- tibble(
name = datasheet_node %>%
html_nodes("dt") %>%
html_text(),
value = datasheet_node %>%
html_nodes("dd") %>%
html_text()
)
if ("Compound" %in% vals_raw$name) {
cmpd_info <- vals_raw %>%
slice(which(vals_raw$name == "Compound") + 1:nrow(vals_raw)) %>%
magrittr::set_colnames(c("Compound", "Kd"))
vals <- vals_raw %>%
slice(1:(which(vals_raw$name == "Compound") - 1)) %>%
pivot_wider(names_from = name, values_from = value) %>%
mutate(Compounds = list(cmpd_info))
} else
vals <- vals_raw %>%
pivot_wider(names_from = name, values_from = value)
vals
}
assay_datasheets_raw <- assay_datasheet_nodes %>%
map(extract_assay_info)
```
Include Ensembl and Entrez gene IDs and UniProt IDs for each kinase.
```{r}
library(biomaRt)
mart <- biomaRt::useMart("ensembl", dataset = "hsapiens_gene_ensembl")
gene_symbol_to_id_map <- biomaRt::getBM(
attributes = c("ensembl_gene_id", "external_gene_name", "entrezgene_id", "chromosome_name", "hgnc_symbol"),
filters = "external_gene_name",
values = assay_table_raw$`Entrez Gene Symbol`,
mart = mart
)
setdiff(assay_table_raw$`Entrez Gene Symbol`, gene_symbol_to_id_map$external_gene_name)
# figure out ambiguous mappings
gene_symbol_to_id_map %>%
group_by(external_gene_name) %>%
filter(n() > 1) %>%
arrange(external_gene_name) %>%
print(n = Inf)
gene_symbol_to_id_map_disam <- gene_symbol_to_id_map %>%
filter(
# ensembl gene id hits for some are on alternative assemblies
chromosome_name %in% c(as.character(1:22), "X", "Y"),
# this entrez gene hit is a BUB1B-PAK6 readthrough
!entrezgene_id %in% c(106821730)
)
setdiff(assay_table_raw$`Entrez Gene Symbol`, gene_symbol_to_id_map_disam$external_gene_name) %>%
sort()
gene_symbol_to_id_map_disam %>%
group_by(external_gene_name) %>%
filter(n() > 1) %>%
arrange(external_gene_name) %>%
print(n = Inf)
# Make sure this is zero
manual_map_old_symbols <- tribble(
~`Entrez Gene Symbol`, ~entrezgene_id, ~ensembl_gene_id,
"ADCK4", 79934, "ENSG00000123815",
"ADRBK1", 156, "ENSG00000173020",
"ADRBK2", 157, "ENSG00000100077",
"CABC1", 56997, "ENSG00000163050",
"CDC2L2", 728642, "ENSG00000008128",
"CDPK1", 812762, NA_character_, # Plasmodium
"GSG2", 83903, "ENSG00000177602",
"ICK", 22858, "ENSG00000112144",
"KIAA0999", 23387, "ENSG00000160584",
"MAL13P1.279", 813841, NA_character_, # Plasmodium
"MGC42105", 167359, "ENSG00000177453",
"MST4", 51765, "ENSG00000134602",
"PAK7", 57144, "ENSG00000101349",
"pknB", 887072, NA_character_, # M. tuberculosis
"SgK110", 100130827, "ENSG00000231274",
"ZAK", 51776, "ENSG00000091436"
) %>%
left_join(
biomaRt::getBM(
attributes = c("ensembl_gene_id", "entrezgene_id", "hgnc_symbol"),
filters = "entrezgene_id",
values = .$entrezgene_id,
mart = mart
)
)
gene_symbol_to_id_map_final <- gene_symbol_to_id_map_disam %>%
distinct(`Entrez Gene Symbol` = external_gene_name, entrezgene_id, ensembl_gene_id, hgnc_symbol) %>%
bind_rows(manual_map_old_symbols)
setdiff(assay_table_raw$`Entrez Gene Symbol`, gene_symbol_to_id_map_final$`Entrez Gene Symbol`) %>%
sort()
```
```{r}
assay_datasheets <- assay_table_raw %>%
bind_cols(
bind_rows(assay_datasheets_raw)
) %>%
left_join(
gene_symbol_to_id_map_final
) %>%
dplyr::select(
`DiscoveRx Gene Symbol` = `KGS ▲`,
`Entrez Gene Symbol`,
`Kinase Name`,
entrezgene_id,
ensembl_gene_id,
hgnc_symbol,
everything()
)
```
```{r}
write_csv(
assay_datasheets %>%
dplyr::select(where(negate(is.list))),
"eurofins_kinase_info.csv"
)
qsave(
assay_datasheets,
"eurofins_kinase_info.qs"
)
synStoreMany(
c("eurofins_kinase_info.csv", "eurofins_kinase_info.qs"),
parent = "syn18502717",
activity = synapser::Activity(
used = c(
"https://www.discoverx.com/services/drug-discovery-development-services/kinase-profiling/kinomescan#kinase-assay-list"
),
executed = "https://github.com/labsyspharm/okl-analysis/blob/main/eurofins_assays.Rmd"
),
forceVersion = FALSE
)
```