File size: 22,094 Bytes
ddbd543
84b01d5
 
 
 
 
eb3b21d
 
0a15406
eb3b21d
84b01d5
 
 
 
 
 
 
 
 
 
 
eb3b21d
 
 
 
90ab4ee
 
0a15406
 
 
 
ddbd543
84b01d5
eb3b21d
 
 
 
 
 
 
0a15406
90ab4ee
0a15406
 
eb3b21d
 
 
 
84b01d5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eb3b21d
 
 
 
 
 
 
 
 
 
 
 
 
90ab4ee
0a15406
 
eb3b21d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90ab4ee
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0a15406
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eb3b21d
 
90ab4ee
 
 
 
 
eb3b21d
 
 
 
 
 
 
 
 
90ab4ee
 
 
 
eb3b21d
0a15406
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eb3b21d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90ab4ee
 
 
 
 
 
 
 
 
 
 
 
0a15406
 
 
 
 
 
 
 
 
 
 
eb3b21d
 
 
 
 
 
 
 
 
 
 
0a15406
 
 
 
 
 
eb3b21d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
---
license: cc-by-4.0
tags:
- virtual-screening
- drug-discovery
- aidd
- knowledge-graph
- parkinsons-disease
- toxicology
pretty_name: Biopharma hackathon data
configs:
- config_name: targets
  data_files: targets.parquet
- config_name: pockets
  data_files: pockets.parquet
- config_name: pocket_structures
  data_files: pocket_structures.parquet
- config_name: molecules
  data_files: molecules.parquet
- config_name: hits
  data_files: hits.parquet
- config_name: pd_subgraph
  data_files: pd_subgraph.parquet
- config_name: pd_subgraph_enrichment
  data_files: pd_subgraph_enrichment.parquet
- config_name: pd_tree
  data_files: pd_tree.parquet
- config_name: pd_toxin_target
  data_files: pd_toxin_target.parquet
- config_name: pd_toxin_pathway
  data_files: pd_toxin_pathway.parquet
---

# Biopharma hackathon data

Two independent datasets share this repo. They have different sources and different licenses,
and nothing joins them:

1. **[GenomeScreen (relational)](#1-genomescreen-as-a-relational-dataset)** — 5 tables, the
   DrugCLIP genome-wide virtual screen parsed into parquet.
2. **[Parkinson's disease subgraph](#2-parkinsons-disease-subgraph-primekg)** — 5 tables, a
   pathway-centric neighbourhood extracted from PrimeKG, as a graph and as a
   disease→pathway→protein→drug tree, plus an environmental-toxin overlay on the same
   pathways.

---

# 1. GenomeScreen, as a relational dataset

A normalized, queryable form of [GenomeScreen](https://huggingface.co/datasets/THU-ATOM/GenomeScreenDB)
— the DrugCLIP genome-wide virtual screen of human proteins. The source release ships as
~26.5k per-pocket directories of CSV and structure files; this is the same data parsed into
five parquet tables.

**This contains the screen results only.** The 27 GB of `.pdbgz` receptor structures are not
redistributed here; `pocket_structures` records their paths relative to the source release's
`screen_results/` directory so you can join against your own copy.

## Tables

| file | rows | grain |
| --- | ---: | --- |
| `targets.parquet` | 9,919 | UniProt accession |
| `pockets.parquet` | 26,562 | screen-result directory (target × AF fragment × pocket) |
| `pocket_structures.parquet` | 215,481 | refined receptor conformation + docking grid |
| `molecules.parquet` | 1,110,392 | distinct `(oid, smiles)` — 982,239 distinct compounds |
| `hits.parquet` | 3,175,634 | `(pocket, molecule)` DrugCLIP hit |

Join keys: `hits.pocket_key → pockets.pocket_key → targets.uniprot_acc`, and
`hits.mol_id → molecules.mol_id`.

## How the data is keyed

- **Targets are UniProt accessions**, wrapped in AlphaFold DB ids. A `pocket_key` of
  `AF-Q12879-F1-model_v4_0_pocket3` is UniProt `Q12879`, AF2 model fragment `0`, pocket `3`.
- **Pockets come in two kinds.** `pocket_kind = 'detected'` (22,061) were found by apo pocket
  detection; `'template'` (4,501) were transferred from an aligned holo structure and keep the
  source PDB id in `pocket_structures.template_pdb_id` (3,125 distinct entries).
- **Molecules are vendor catalogue ids plus SMILES — there are no PubChem CIDs.** `oid` is a
  ZINC id (`ZINC000066055208`), an Enamine REAL id (`Z1333761449_1_T2`) or an Enamine PV id
  (`PV-001914042032_1_T1`). The Enamine `_<protomer>_T<tautomer>` suffix is split into
  `protomer_idx` / `tautomer_idx`; `catalog_id` strips it.
- **The same `oid` sometimes carries two SMILES** (protonation variants), so the `molecules`
  grain is `(oid, smiles)` behind a surrogate `mol_id`. Group by `catalog_id` to collapse them.
- **`hits.source_index` is not a molecule id.** It is the source `leader.csv` `Name` column, a
  row index into the screened library that differs between targets for the same compound. Use
  `catalog_id` to identify a compound. `rank_in_pocket` (1 = best) is derived from `score`.

## Caveats worth knowing before you use it

- **These are predicted hits, not measured interactions.** `score` is DrugCLIP similarity.
- **Scores are not calibrated across proteins.** Ranking is meaningful within a pocket; a
  global threshold across targets is not.
- **The per-molecule view is truncated by construction.** The screen kept each *pocket's* top
  10K, then cluster leaders — so a molecule's known target is not guaranteed to survive that
  cut. Empirically it often doesn't: ibuprofen appears with 34 predicted targets, none of them
  COX-1 or COX-2, though both are screened. Read a molecule's row set as a biased sample of
  its profile, not as its profile.
- **It is a make-on-demand screening library, not a drug library.** Most approved drugs are
  absent entirely.

## Usage

```python
import duckdb
conn = duckdb.connect()
conn.execute("""
    CREATE VIEW hits    AS SELECT * FROM 'hf://datasets/conradry/biopharma-hackathon/hits.parquet';
    CREATE VIEW pockets AS SELECT * FROM 'hf://datasets/conradry/biopharma-hackathon/pockets.parquet';
    CREATE VIEW molecules AS SELECT * FROM 'hf://datasets/conradry/biopharma-hackathon/molecules.parquet';
""")

# top hits for a UniProt accession, one row per compound
conn.execute("""
    SELECT m.catalog_id, m.source, max(h.score) AS score,
           arg_max(m.smiles, h.score) AS smiles
    FROM hits h
    JOIN pockets   p ON p.pocket_key = h.pocket_key
    JOIN molecules m ON m.mol_id = h.mol_id
    WHERE p.uniprot_acc = ?
    GROUP BY 1, 2 ORDER BY score DESC LIMIT 25
""", ["P14416"]).fetchall()
```

## Source and license

Derived from **GenomeScreen** by Jia et al., released under CC-BY-4.0. This derived dataset
carries the same license, and the original work must be credited:

> Jia, Y., Gao, B., Tan, J., Zheng, J., Hong, X., Zhu, W., Tan, H., Xiao, Y., Tan, L., Cai, H.,
> Huang, Y., Deng, Z., Jin, Y., Yuan, Y., Tian, J., He, W., Ma, W., Zhang, Y., Yan, C., Liu, L.,
> Zhang, W., Lan, Y. *Deep contrastive learning enables genome-wide virtual screening.*
> bioRxiv 2024.09.02.610777.

- Source dataset: https://huggingface.co/datasets/THU-ATOM/GenomeScreenDB
- Portal: https://drug-the-whole-genome.yanyanlan.com
- Code: https://github.com/THU-ATOM/Drug-The-Whole-Genome

```bibtex
@article{Jia2024GenomeScreen,
  title={Deep contrastive learning enables genome-wide virtual screening},
  author={Jia, Yinjun and Gao, Bowen and Tan, Jiaxin and Zheng, Jiqing and Hong, Xin and Zhu, Wenyu and Tan, Haichuan and Xiao, Yuan and Tan, Liping and Cai, Hongyi and Huang, Yanwen and Deng, Zhiheng and Jin, Yue and Yuan, Yafei and Tian, Jiekang and He, Wei and Ma, Weiying and Zhang, Yaqin and Yan, Chuangye and Liu, Lei and Zhang, Wei and Lan, Yanyan},
  journal={bioRxiv},
  year={2024},
  doi={10.1101/2024.09.02.610777}
}
```

---

# 2. Parkinson's disease subgraph (PrimeKG)

A pathway-centric neighbourhood of Parkinson's disease extracted from
[PrimeKG](https://github.com/mims-harvard/PrimeKG) (13,001,666 edges), plus a pathway
enrichment table for filtering it down.

| file | rows | grain |
| --- | ---: | --- |
| `pd_subgraph.parquet` | 162,384 | edge (both orientations — see below) |
| `pd_subgraph_enrichment.parquet` | 283 | pathway |
| `pd_tree.parquet` | 54,557 | root→leaf path, disease → pathway → protein → drug |
| `pd_toxin_target.parquet` | 79 | (environmental toxin, gene) |
| `pd_toxin_pathway.parquet` | 76 | pathway, with toxin evidence rolled up |

## How it was built

**PrimeKG has no `disease_pathway` relation**, so the disease is bridged to pathways through
its associated proteins:

```
Parkinson disease (x_index 80275)
  --disease_protein-->  104 seed proteins
  --pathway_protein-->  283 pathways
  --pathway_pathway-->  edges among those pathways
  --pathway_protein-->  4,916 proteins in those pathways
  --protein_protein-->  edges among those proteins
```

The `layer` column tags which step each edge came from:

| `layer` | rows | unique edges |
| --- | ---: | ---: |
| `disease_protein` | 208 | 104 |
| `pathway_pathway` | 62 | 31 |
| `pathway_protein` | 24,544 | 12,272 |
| `protein_protein` | 137,570 | 68,785 |

PD is the merged MONDO/Orphanet node at `x_index` 80275. The other node named "Parkinson
disease" (`x_index` 91594, MONDO:0005180) carries only `disease_disease` edges and no protein
links.

Columns are PrimeKG's original twelve (`relation`, `display_relation`, `x_index`, `x_id`,
`x_type`, `x_name`, `x_source`, and the `y_*` equivalents) plus `layer`,
`x_pathway_qvalue` and `y_pathway_qvalue`.

## Pathway enrichment

Bridging through proteins pulls in generic pathways (`Platelet degranulation`) alongside
PD-relevant ones, so each of the 283 pathways is scored by a hypergeometric test: background =
the 10,849 pathway-annotated proteins in PrimeKG, sample = the 90 of 104 seed proteins that
carry a pathway annotation. P-values are Benjamini-Hochberg corrected across all 283 pathways.
**21 pathways reach q < 0.05.**

`pd_subgraph_enrichment.parquet` holds `pathway_index`, `pathway_name`, `pathway_size`,
`seed_overlap`, `expected_overlap`, `fold_enrichment`, `pvalue`, `qvalue`, ranked by q-value.
The same q-value is denormalized onto the edge table as `x_pathway_qvalue` /
`y_pathway_qvalue` — populated on whichever endpoint is a pathway, null otherwise (a
`pathway_pathway` edge has both).

Top hits are recognisable PD biology:

| pathway | size | overlap | fold | q |
| --- | ---: | ---: | ---: | ---: |
| Interleukin-4 and Interleukin-13 signaling | 108 | 7 | 7.8 | 6.4e-03 |
| Biogenic amines are oxidatively deaminated to aldehydes | 2 | 2 | 120.5 | 6.4e-03 |
| Detoxification of Reactive Oxygen Species | 37 | 4 | 13.0 | 1.5e-02 |
| Catecholamine biosynthesis | 4 | 2 | 60.3 | 1.6e-02 |
| Dopamine receptors | 5 | 2 | 48.2 | 2.1e-02 |
| Transcriptional activation of mitochondrial biogenesis | 56 | 4 | 8.6 | 2.4e-02 |

## The tree view

`pd_tree.parquet` is the same neighbourhood reshaped into a tree, with drugs attached below
the proteins:

```
Parkinson disease                    (root)
└── 283 pathways
      └── 4,916 proteins             (12,272 pathway-protein pairs)
            └── 4,993 drugs          (drug_protein edges)
```

**PrimeKG has no `drug_pathway` relation either**, so proteins are the only join between drugs
and pathways — a drug hangs off the tree once per (pathway, protein) pair it reaches. Use
`COUNT(DISTINCT drug_index)` when you want unique drugs.

One row per root-to-leaf path, fully denormalized, so any level rolls up with a `GROUP BY`:
`disease_index`/`disease_name`, `pathway_index`/`pathway_name`/`pathway_size`/
`pathway_seed_overlap`/`pathway_fold_enrichment`/`pathway_qvalue`, `protein_index`/
`protein_name`/`protein_is_pd_seed`, `drug_index`/`drug_id`/`drug_name`/`drug_relation`, and
`depth`. Proteins with no drug still get a row (`depth = 3`, drug columns null; 7,917 of them)
so the protein layer stays complete.

Nothing is pre-filtered — the narrowings you are likely to want are all columns:
`pathway_qvalue < 0.05` (21 pathways), `protein_is_pd_seed`, `drug_relation = 'target'`.

**`drug_relation` matters more than it looks.** Only `target` (30,151 rows) is a therapeutic
target; `enzyme` (10,149), `transporter` (3,680) and `carrier` (2,660) are ADME relationships
— a metabolizing CYP is not a repurposing lead. Note that 185 drug-protein pairs legitimately
carry two relation types (usually enzyme + target), so they appear as two rows.

The tree drops `protein_protein` and `pathway_pathway`, which have no place in a tree; use
`pd_subgraph.parquet` for those.

## The environmental-toxin overlay

A second, independent line of evidence on the same pathways. Ten environmental toxins with
an established PD association (paraquat, rotenone, MPTP, manganese, lead, mercury,
chlorpyrifos, dieldrin, trichloroethylene, tetrachloroethylene) were mapped to their
literature-co-mentioned gene targets, and those genes joined onto the tree's pathways.

The premise: a toxin that is *causative* for PD implicates the pathways it perturbs, so a
pathway reached by both the disease-association route and the toxicological route carries a
stronger prior than either alone. **9 of the 21 enriched pathways contain a toxin target**,
and the top of that list is the canonical PD tox story.

`pd_toxin_target.parquet` is one row per (toxin, gene): `toxin`, `cid`, `pubmed_mentions`,
`gene_symbol`, `protein_index` (PrimeKG), `evidence_count`, `n_source_entries`,
`source_entries`, `mapping_confidence`, `toxin_mapped_fraction`, `in_pd_tree`, `is_pd_seed`,
`tf`, `idf`, `specificity_weight`.

`pd_toxin_pathway.parquet` rolls that up per pathway and joins to `pd_tree.parquet` on
`pathway_index`: `n_toxins`, `n_toxin_targets`, `toxin_support`, `toxins`, `toxin_targets`,
alongside the pathway's `pathway_qvalue`, `n_drugs` and `n_target_drugs`.

Ranked by toxin support among pathways at q < 0.05:

| pathway | support | q | toxins | targets |
| --- | ---: | ---: | ---: | --- |
| Detoxification of Reactive Oxygen Species | 3.28 | 1.5e-02 | 6 | CAT, GPX1–3, SOD1–3 |
| Transcriptional activation of mitochondrial biogenesis | 2.99 | 2.4e-02 | 7 | GABPA, PPARGC1B, SOD2 |
| FOXO-mediated transcription of oxidative stress genes | 1.98 | 3.3e-02 | 6 | CAT, SOD2 |
| Interleukin-4 and Interleukin-13 signaling | 1.24 | 6.4e-03 | 4 | AKT1, BCL2, IL6, MAOA, TNF |
| Catecholamine biosynthesis | 1.05 | 1.6e-02 | 2 | TH |
| Biogenic amines deaminated by MAOA and MAOB | 0.19 | 6.4e-03 | 1 | MAOA, MAOB |

### How the targets were mapped

The source lists targets as `name [TAG] (count)`, where TAG is a gene symbol *or* an EC
number. Three properties of that format shape the table:

- **The EC entries carry the mechanism.** MPTP's causal target is monoamine oxidase, which
  appears only as `EC:1.4.3.4`; rotenone's is complex I, only as `EC:1.6.99.3`. Symbol-only
  parsing loses both. EC classes are expanded through a hand-curated map, and
  `mapping_confidence` records how firm each expansion is: `exact` (one human gene),
  `family` (a small enumerated family — MAOA/MAOB, SOD1–3), or `complex` (complex I core
  subunits). Large cross-species classes (`peroxidase`, `unspecific monooxygenase`) and
  non-human ones (photosystem II, lignin peroxidase, bacterial dehalogenases) are dropped
  rather than guessed at.
- **A toxin often lists one protein twice**, once by symbol and once by EC — lead has both
  `catalase [CAT] (576)` and `catalase [EC:1.11.1.6] (234)`. Rows are aggregated to the
  (toxin, gene) grain and the counts summed; `source_entries` preserves what contributed.
  A family EC has its evidence split across members rather than replicated, so a family tag
  cannot outvote a specific symbol.
- **The gene lists are cross-species.** Influenza PB2, bacterial MERA, rice LOC4326471 and a
  *Drosophila* GABA receptor all appear. Only symbols resolving to a PrimeKG `gene/protein`
  node are kept.

`specificity_weight` is `tf × idf`: a gene's share of its toxin's mapped evidence, damped by
how many toxins name it. CAT and the SODs appear for 6 of the 10 toxins — they are the
background of the toxicology literature, not a toxin-specific signal, and the weighting is
what keeps them from dominating.

## Caveats worth knowing before you use it

- **Every edge in `pd_subgraph.parquet` appears twice.** PrimeKG stores undirected edges in
  both orientations, and this extract preserves that verbatim — all 162,384 rows are 81,192
  unique edges mirrored. Filter `x_index < y_index` for a single copy, and match on
  `x_type`/`y_type` rather than assuming which column holds the pathway or the disease.
  (`pd_tree.parquet` is already deduplicated — it has a fixed level order.)
- **The disease→pathway link is inferred, not asserted.** These pathways are not curated PD
  pathways; they are pathways containing at least one PD-associated protein.
- **14 of the 104 seed proteins have no pathway annotation** and are excluded from the
  enrichment test. They remain in the edge table under the `disease_protein` layer.
- **Small pathways produce fragile scores.** Several top hits rest on an overlap of 2 in a
  pathway of size 2–6. `Signaling by Insulin receptor` at size 2 is a PrimeKG annotation
  artifact, not the real Reactome pathway. Add `pathway_size >= 10` for robust hits only.
- **Enrichment is scored over the 283 bridged pathways, not all of PrimeKG.** The multiple
  testing correction is relative to that set.
- **Ranking drugs by pathway or target count rewards promiscuity.** The query above returns
  zinc salts, cannabidiol and fatty acids at the top — compounds with dozens of annotated
  protein interactions, not compounds with a PD rationale. Weight by target specificity, or
  restrict to a pathway you care about, before reading anything into the ordering.

- **PrimeKG's drug nodes are all of DrugBank, and it carries no approval status.** Every
  `drug_id` is a `DB…` accession, but the set includes experimental entries, cofactors and
  crystallographic ligands — NADH, copper and glutathione adducts all appear as `target`
  drugs. There is no column to filter on; join against a DrugBank approval list if you need
  approved compounds only.

Specific to the toxin overlay:

- **A shared target does not mean a shared direction of effect, and PrimeKG cannot tell you
  which.** `drug_relation` distinguishes target from enzyme, never agonist from antagonist.
  If a toxin causes PD by inhibiting a protein, a drug that also inhibits it is a risk, not a
  therapy. `SLC6A3` is the clearest case: DAT-mediated uptake is how MPP+ enters dopaminergic
  neurons, so a DAT blocker is protective while amphetamine — on the same target list — is
  not. Read the overlay as nominating *pathways*, and get direction from DrugBank's action
  field before selecting compounds within one.
- **The counts are literature co-mentions, not affinities or assays.** A high count means the
  toxin and the gene are frequently discussed together, which tracks how well-studied a gene
  is at least as much as how relevant it is.
- **The source lists only the top 8 of 25 targets per toxin.** Document frequencies — and so
  every `idf` — are computed over that truncated view, which biases `idf` upward for genes
  that fall below the cut for some toxins.
- **Two toxins are mostly unmappable.** `toxin_mapped_fraction` is 0.38 for tetrachloroethylene
  and 0.40 for trichloroethylene; the rest of their lists is bacterial or fungal. Because `tf`
  is a share of *mapped* evidence, the survivors absorb the whole share and their weights are
  inflated. Treat anything below ~0.5 as soft.
- **`toxin_support` is a raw sum, so it rewards large pathways.** Unfiltered, `Neutrophil
  degranulation` (478 proteins, q = 0.21) tops the ranking. The enrichment q-value already
  controls for size — filter on it first, then rank by support.
- **10 toxin targets are absent from the tree entirely**, including all seven complex I core
  subunits — the most PD-relevant mechanism in the set. They resolve to valid PrimeKG
  `protein_index` values but sit in no PD-bridged pathway, so they contribute nothing to
  `pd_toxin_pathway.parquet`. Filter `in_pd_tree = false` to see them.

## Usage

```python
import duckdb
conn = duckdb.connect()
base = "hf://datasets/conradry/biopharma-hackathon"

# significantly enriched pathways and the proteins in them, deduplicated
conn.execute(f"""
    SELECT DISTINCT
        CASE WHEN x_type = 'pathway' THEN x_name ELSE y_name END AS pathway,
        CASE WHEN x_type = 'pathway' THEN y_name ELSE x_name END AS protein
    FROM '{base}/pd_subgraph.parquet'
    WHERE layer = 'pathway_protein'
      AND coalesce(x_pathway_qvalue, y_pathway_qvalue) < 0.05
      AND x_index < y_index
""").fetchall()

# repurposing candidates: drugs targeting proteins in enriched PD pathways,
# ranked by how many distinct enriched pathways they reach
conn.execute(f"""
    SELECT drug_name,
           count(DISTINCT pathway_index) AS pathways,
           count(DISTINCT protein_index) AS proteins,
           string_agg(DISTINCT protein_name, ', ') AS targets
    FROM '{base}/pd_tree.parquet'
    WHERE drug_relation = 'target' AND pathway_qvalue < 0.05
    GROUP BY 1 ORDER BY pathways DESC, proteins DESC LIMIT 25
""").fetchall()

# convergent evidence: drugs targeting proteins in pathways that are both
# statistically enriched for PD proteins and hit by a PD-associated toxin
conn.execute(f"""
    SELECT t.drug_name, t.protein_name, x.pathway_name,
           x.toxins, x.toxin_support, x.pathway_qvalue
    FROM '{base}/pd_tree.parquet' t
    JOIN '{base}/pd_toxin_pathway.parquet' x USING (pathway_index)
    WHERE t.drug_relation = 'target' AND x.pathway_qvalue < 0.05
    ORDER BY x.toxin_support DESC, t.drug_name
""").fetchall()
```

## Source and license

Derived from **PrimeKG** by Chandak, Huang and Zitnik. Note that PrimeKG's MIT license covers
the software; the upstream repository states that this is distinct from the terms governing
the data itself, which is distributed via Harvard Dataverse
([doi:10.7910/DVN/IXA7BM](https://doi.org/10.7910/DVN/IXA7BM)) and inherits the terms of its
own ~20 constituent primary sources. Check those before redistributing. The `license` field in
this repo's metadata (CC-BY-4.0) describes the GenomeScreen tables above.

The toxin overlay adds a second source: the toxin list and its gene targets come from
**PubChem** (compound records and their literature-co-mentioned genes) and PubMed mention
counts, retrieved via the PubChem PUG-REST API. PubChem aggregates from many depositors whose
individual terms vary; see https://www.ncbi.nlm.nih.gov/home/about/policies/. The EC-to-gene
map and the specificity weighting are original to this dataset.

> Chandak, P., Huang, K., Zitnik, M. *Building a knowledge graph to enable precision medicine.*
> Nature Scientific Data 10, 67 (2023).

```bibtex
@article{Chandak2023PrimeKG,
  title={Building a knowledge graph to enable precision medicine},
  author={Chandak, Payal and Huang, Kexin and Zitnik, Marinka},
  journal={Scientific Data},
  volume={10},
  number={1},
  pages={67},
  year={2023},
  doi={10.1038/s41597-023-01960-3}
}
```