Upload folder using huggingface_hub

#1
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. 1_data.ipynb +740 -0
  3. README.md +52 -3
  4. data.h5ad +3 -0
.gitattributes CHANGED
@@ -57,3 +57,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
60
+ data.h5ad filter=lfs diff=lfs merge=lfs -text
1_data.ipynb ADDED
@@ -0,0 +1,740 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "9904be0b-9bdb-4a28-850a-8aec7786fab4",
6
+ "metadata": {},
7
+ "source": [
8
+ "# Process data for training CATLAS binary ATAC-seq model"
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "markdown",
13
+ "id": "83fd567a-5263-458a-97f9-6b9f2d3db6c1",
14
+ "metadata": {},
15
+ "source": [
16
+ "## Set up W&B"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": 1,
22
+ "id": "f6cc91ab-89b9-448b-a2ec-6d43dafe5e86",
23
+ "metadata": {},
24
+ "outputs": [
25
+ {
26
+ "name": "stderr",
27
+ "output_type": "stream",
28
+ "text": [
29
+ "/opt/conda/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
30
+ " from .autonotebook import tqdm as notebook_tqdm\n"
31
+ ]
32
+ }
33
+ ],
34
+ "source": [
35
+ "import wandb\n",
36
+ "import os\n",
37
+ "import anndata\n",
38
+ "import pandas as pd\n",
39
+ "import numpy as np\n",
40
+ "import bioframe as bf\n",
41
+ "from grelu.sequence.utils import resize\n",
42
+ "from grelu.data.preprocess import filter_blacklist, filter_chromosomes"
43
+ ]
44
+ },
45
+ {
46
+ "cell_type": "code",
47
+ "execution_count": 2,
48
+ "id": "4f87b690-04e0-4099-8536-15ebec7c5102",
49
+ "metadata": {},
50
+ "outputs": [
51
+ {
52
+ "name": "stderr",
53
+ "output_type": "stream",
54
+ "text": [
55
+ "\u001b[34m\u001b[1mwandb\u001b[0m: Using wandb-core as the SDK backend. Please refer to https://wandb.me/wandb-core for more information.\n",
56
+ "\u001b[34m\u001b[1mwandb\u001b[0m: Currently logged in as: \u001b[33mavantikalal\u001b[0m (\u001b[33mgrelu\u001b[0m) to \u001b[32mhttps://api.wandb.ai\u001b[0m. Use \u001b[1m`wandb login --relogin`\u001b[0m to force relogin\n"
57
+ ]
58
+ },
59
+ {
60
+ "data": {
61
+ "text/plain": [
62
+ "True"
63
+ ]
64
+ },
65
+ "execution_count": 2,
66
+ "metadata": {},
67
+ "output_type": "execute_result"
68
+ }
69
+ ],
70
+ "source": [
71
+ "wandb.login(host=\"https://api.wandb.ai\")"
72
+ ]
73
+ },
74
+ {
75
+ "cell_type": "code",
76
+ "execution_count": 3,
77
+ "id": "d4cfb6b2-2f49-4c0f-8c0d-9f402852d150",
78
+ "metadata": {},
79
+ "outputs": [],
80
+ "source": [
81
+ "project_name='human-atac-catlas'"
82
+ ]
83
+ },
84
+ {
85
+ "cell_type": "code",
86
+ "execution_count": 4,
87
+ "id": "52c22759-6d2c-4b41-bc1d-d2a3233d7c73",
88
+ "metadata": {},
89
+ "outputs": [
90
+ {
91
+ "data": {
92
+ "text/html": [
93
+ "Tracking run with wandb version 0.19.7"
94
+ ],
95
+ "text/plain": [
96
+ "<IPython.core.display.HTML object>"
97
+ ]
98
+ },
99
+ "metadata": {},
100
+ "output_type": "display_data"
101
+ },
102
+ {
103
+ "data": {
104
+ "text/html": [
105
+ "Run data is saved locally in <code>/code/github/gReLU-applications/catlas/wandb/run-20250306_000043-vphymp69</code>"
106
+ ],
107
+ "text/plain": [
108
+ "<IPython.core.display.HTML object>"
109
+ ]
110
+ },
111
+ "metadata": {},
112
+ "output_type": "display_data"
113
+ },
114
+ {
115
+ "data": {
116
+ "text/html": [
117
+ "Syncing run <strong><a href='https://wandb.ai/grelu/human-atac-catlas/runs/vphymp69' target=\"_blank\">prep</a></strong> to <a href='https://wandb.ai/grelu/human-atac-catlas' target=\"_blank\">Weights & Biases</a> (<a href='https://wandb.me/developer-guide' target=\"_blank\">docs</a>)<br>"
118
+ ],
119
+ "text/plain": [
120
+ "<IPython.core.display.HTML object>"
121
+ ]
122
+ },
123
+ "metadata": {},
124
+ "output_type": "display_data"
125
+ },
126
+ {
127
+ "data": {
128
+ "text/html": [
129
+ " View project at <a href='https://wandb.ai/grelu/human-atac-catlas' target=\"_blank\">https://wandb.ai/grelu/human-atac-catlas</a>"
130
+ ],
131
+ "text/plain": [
132
+ "<IPython.core.display.HTML object>"
133
+ ]
134
+ },
135
+ "metadata": {},
136
+ "output_type": "display_data"
137
+ },
138
+ {
139
+ "data": {
140
+ "text/html": [
141
+ " View run at <a href='https://wandb.ai/grelu/human-atac-catlas/runs/vphymp69' target=\"_blank\">https://wandb.ai/grelu/human-atac-catlas/runs/vphymp69</a>"
142
+ ],
143
+ "text/plain": [
144
+ "<IPython.core.display.HTML object>"
145
+ ]
146
+ },
147
+ "metadata": {},
148
+ "output_type": "display_data"
149
+ }
150
+ ],
151
+ "source": [
152
+ "run = wandb.init(\n",
153
+ " entity='grelu', project=project_name, job_type='preprocessing', name='prep',\n",
154
+ " settings=wandb.Settings(\n",
155
+ " program_relpath='1_data.ipynb',\n",
156
+ " program_abspath='/code/github/gReLU-applications/catlas/1_data.ipynb')\n",
157
+ ")"
158
+ ]
159
+ },
160
+ {
161
+ "cell_type": "markdown",
162
+ "id": "9b3caead-af54-4e7a-88af-ac9e283f0750",
163
+ "metadata": {},
164
+ "source": [
165
+ "## Load CATLAS snATAC-seq matrix"
166
+ ]
167
+ },
168
+ {
169
+ "cell_type": "code",
170
+ "execution_count": 5,
171
+ "id": "0d70c98f-f45f-45a9-98ca-946c507c36c6",
172
+ "metadata": {},
173
+ "outputs": [],
174
+ "source": [
175
+ "#!wget http://catlas.org/catlas_downloads/humantissues/cCRE_by_cell_type/matrix.tsv.gz"
176
+ ]
177
+ },
178
+ {
179
+ "cell_type": "code",
180
+ "execution_count": 6,
181
+ "id": "b909e398-8de7-41e2-83b7-3c32021cef5b",
182
+ "metadata": {},
183
+ "outputs": [
184
+ {
185
+ "name": "stderr",
186
+ "output_type": "stream",
187
+ "text": [
188
+ "/opt/conda/lib/python3.11/site-packages/anndata/utils.py:429: FutureWarning: Importing read_mtx from `anndata` is deprecated. Import anndata.io.read_mtx instead.\n",
189
+ " warnings.warn(msg, FutureWarning)\n"
190
+ ]
191
+ },
192
+ {
193
+ "name": "stdout",
194
+ "output_type": "stream",
195
+ "text": [
196
+ "(222, 1154611)\n"
197
+ ]
198
+ }
199
+ ],
200
+ "source": [
201
+ "ad = anndata.read_mtx('matrix.tsv.gz').T\n",
202
+ "\n",
203
+ "# Prepare ad.obs\n",
204
+ "ad.obs = pd.read_table('http://catlas.org/catlas_downloads/humantissues/cCRE_by_cell_type/celltypes.txt.gz', header=None, names=['cell type'])\n",
205
+ "ad.obs_names = ad.obs['cell type']\n",
206
+ "\n",
207
+ "# Prepare ad.var\n",
208
+ "var = pd.read_table('http://catlas.org/catlas_downloads/humantissues/cCRE_hg38.tsv.gz')\n",
209
+ "var.columns = ['chrom', 'start', 'end', 'cre_class', 'in_fetal', 'in_adult', 'cre_module']\n",
210
+ "var[\"width\"] = (var.end - var.start).astype(int)\n",
211
+ "var.index = var.index.astype(str)\n",
212
+ "ad.var = var\n",
213
+ "\n",
214
+ "print(ad.shape)"
215
+ ]
216
+ },
217
+ {
218
+ "cell_type": "code",
219
+ "execution_count": 7,
220
+ "id": "bd2463e1-8fa8-40ee-a1a2-b5b60516976d",
221
+ "metadata": {},
222
+ "outputs": [
223
+ {
224
+ "name": "stdout",
225
+ "output_type": "stream",
226
+ "text": [
227
+ " chrom start end cre_class in_fetal in_adult cre_module \\\n",
228
+ "0 chr1 9955 10355 Promoter Proximal yes yes 146 \n",
229
+ "1 chr1 29163 29563 Promoter yes yes 37 \n",
230
+ "2 chr1 79215 79615 Distal no yes 75 \n",
231
+ "3 chr1 102755 103155 Distal no yes 51 \n",
232
+ "4 chr1 115530 115930 Distal yes no 36 \n",
233
+ "\n",
234
+ " width \n",
235
+ "0 400 \n",
236
+ "1 400 \n",
237
+ "2 400 \n",
238
+ "3 400 \n",
239
+ "4 400 \n",
240
+ " cell type\n",
241
+ "cell type \n",
242
+ "Follicular Follicular\n",
243
+ "Fibro General Fibro General\n",
244
+ "Acinar Acinar\n",
245
+ "T Lymphocyte 1 (CD8+) T Lymphocyte 1 (CD8+)\n",
246
+ "T lymphocyte 2 (CD4+) T lymphocyte 2 (CD4+)\n"
247
+ ]
248
+ }
249
+ ],
250
+ "source": [
251
+ "print(ad.var.head())\n",
252
+ "print(ad.obs.head())"
253
+ ]
254
+ },
255
+ {
256
+ "cell_type": "markdown",
257
+ "id": "84f93545-eaf0-4d39-b16d-2e843367d626",
258
+ "metadata": {},
259
+ "source": [
260
+ "## Filter peaks"
261
+ ]
262
+ },
263
+ {
264
+ "cell_type": "code",
265
+ "execution_count": 8,
266
+ "id": "b5181175-02ce-4614-81a3-962d4705e4f6",
267
+ "metadata": {},
268
+ "outputs": [
269
+ {
270
+ "name": "stdout",
271
+ "output_type": "stream",
272
+ "text": [
273
+ "Keeping 1121319 intervals\n"
274
+ ]
275
+ }
276
+ ],
277
+ "source": [
278
+ "ad = filter_chromosomes(ad, 'autosomes')"
279
+ ]
280
+ },
281
+ {
282
+ "cell_type": "code",
283
+ "execution_count": 9,
284
+ "id": "db96deff-fdec-4cc3-8c39-ad2541394a70",
285
+ "metadata": {},
286
+ "outputs": [
287
+ {
288
+ "name": "stdout",
289
+ "output_type": "stream",
290
+ "text": [
291
+ "Keeping 1121319 intervals\n"
292
+ ]
293
+ }
294
+ ],
295
+ "source": [
296
+ "ad = filter_blacklist(ad, genome='hg38')"
297
+ ]
298
+ },
299
+ {
300
+ "cell_type": "code",
301
+ "execution_count": 10,
302
+ "id": "517b43dc-8e4f-4f44-a6de-e4b459dca5af",
303
+ "metadata": {},
304
+ "outputs": [
305
+ {
306
+ "name": "stdout",
307
+ "output_type": "stream",
308
+ "text": [
309
+ "(222, 1121319)\n",
310
+ "(204, 1121319)\n"
311
+ ]
312
+ }
313
+ ],
314
+ "source": [
315
+ "# Drop peaks that are only accessible in few cell types\n",
316
+ "print(ad.shape)\n",
317
+ "ad = ad[ad.X.mean(axis=1) > .03, :]\n",
318
+ "print(ad.shape)"
319
+ ]
320
+ },
321
+ {
322
+ "cell_type": "markdown",
323
+ "id": "7c53c564-17ed-42e8-bd62-2e4ee182a082",
324
+ "metadata": {},
325
+ "source": [
326
+ "## Resize peaks"
327
+ ]
328
+ },
329
+ {
330
+ "cell_type": "code",
331
+ "execution_count": 11,
332
+ "id": "493f5905-02bb-477b-ae5f-abde1572962d",
333
+ "metadata": {},
334
+ "outputs": [
335
+ {
336
+ "data": {
337
+ "text/html": [
338
+ "<div>\n",
339
+ "<style scoped>\n",
340
+ " .dataframe tbody tr th:only-of-type {\n",
341
+ " vertical-align: middle;\n",
342
+ " }\n",
343
+ "\n",
344
+ " .dataframe tbody tr th {\n",
345
+ " vertical-align: top;\n",
346
+ " }\n",
347
+ "\n",
348
+ " .dataframe thead th {\n",
349
+ " text-align: right;\n",
350
+ " }\n",
351
+ "</style>\n",
352
+ "<table border=\"1\" class=\"dataframe\">\n",
353
+ " <thead>\n",
354
+ " <tr style=\"text-align: right;\">\n",
355
+ " <th></th>\n",
356
+ " <th>chrom</th>\n",
357
+ " <th>start</th>\n",
358
+ " <th>end</th>\n",
359
+ " <th>cre_class</th>\n",
360
+ " <th>in_fetal</th>\n",
361
+ " <th>in_adult</th>\n",
362
+ " <th>cre_module</th>\n",
363
+ " <th>width</th>\n",
364
+ " </tr>\n",
365
+ " </thead>\n",
366
+ " <tbody>\n",
367
+ " <tr>\n",
368
+ " <th>0</th>\n",
369
+ " <td>chr1</td>\n",
370
+ " <td>10055</td>\n",
371
+ " <td>10255</td>\n",
372
+ " <td>Promoter Proximal</td>\n",
373
+ " <td>yes</td>\n",
374
+ " <td>yes</td>\n",
375
+ " <td>146</td>\n",
376
+ " <td>400</td>\n",
377
+ " </tr>\n",
378
+ " <tr>\n",
379
+ " <th>1</th>\n",
380
+ " <td>chr1</td>\n",
381
+ " <td>29263</td>\n",
382
+ " <td>29463</td>\n",
383
+ " <td>Promoter</td>\n",
384
+ " <td>yes</td>\n",
385
+ " <td>yes</td>\n",
386
+ " <td>37</td>\n",
387
+ " <td>400</td>\n",
388
+ " </tr>\n",
389
+ " <tr>\n",
390
+ " <th>2</th>\n",
391
+ " <td>chr1</td>\n",
392
+ " <td>79315</td>\n",
393
+ " <td>79515</td>\n",
394
+ " <td>Distal</td>\n",
395
+ " <td>no</td>\n",
396
+ " <td>yes</td>\n",
397
+ " <td>75</td>\n",
398
+ " <td>400</td>\n",
399
+ " </tr>\n",
400
+ " </tbody>\n",
401
+ "</table>\n",
402
+ "</div>"
403
+ ],
404
+ "text/plain": [
405
+ " chrom start end cre_class in_fetal in_adult cre_module width\n",
406
+ "0 chr1 10055 10255 Promoter Proximal yes yes 146 400\n",
407
+ "1 chr1 29263 29463 Promoter yes yes 37 400\n",
408
+ "2 chr1 79315 79515 Distal no yes 75 400"
409
+ ]
410
+ },
411
+ "execution_count": 11,
412
+ "metadata": {},
413
+ "output_type": "execute_result"
414
+ }
415
+ ],
416
+ "source": [
417
+ "seq_len = 200\n",
418
+ "ad.var = resize(ad.var, seq_len)\n",
419
+ "ad.var.head(3)"
420
+ ]
421
+ },
422
+ {
423
+ "cell_type": "markdown",
424
+ "id": "26745890-cb7f-4f8c-9801-133c66a0ef96",
425
+ "metadata": {},
426
+ "source": [
427
+ "## Load enformer splits"
428
+ ]
429
+ },
430
+ {
431
+ "cell_type": "code",
432
+ "execution_count": 12,
433
+ "id": "85bc5e37-ba54-4e34-8826-96e266c7ec87",
434
+ "metadata": {},
435
+ "outputs": [
436
+ {
437
+ "name": "stderr",
438
+ "output_type": "stream",
439
+ "text": [
440
+ "\u001b[34m\u001b[1mwandb\u001b[0m: 1 of 1 files downloaded. \n"
441
+ ]
442
+ },
443
+ {
444
+ "data": {
445
+ "text/html": [
446
+ "<div>\n",
447
+ "<style scoped>\n",
448
+ " .dataframe tbody tr th:only-of-type {\n",
449
+ " vertical-align: middle;\n",
450
+ " }\n",
451
+ "\n",
452
+ " .dataframe tbody tr th {\n",
453
+ " vertical-align: top;\n",
454
+ " }\n",
455
+ "\n",
456
+ " .dataframe thead th {\n",
457
+ " text-align: right;\n",
458
+ " }\n",
459
+ "</style>\n",
460
+ "<table border=\"1\" class=\"dataframe\">\n",
461
+ " <thead>\n",
462
+ " <tr style=\"text-align: right;\">\n",
463
+ " <th></th>\n",
464
+ " <th>chrom</th>\n",
465
+ " <th>start</th>\n",
466
+ " <th>end</th>\n",
467
+ " <th>split</th>\n",
468
+ " </tr>\n",
469
+ " </thead>\n",
470
+ " <tbody>\n",
471
+ " <tr>\n",
472
+ " <th>0</th>\n",
473
+ " <td>chr18</td>\n",
474
+ " <td>895618</td>\n",
475
+ " <td>1092226</td>\n",
476
+ " <td>train</td>\n",
477
+ " </tr>\n",
478
+ " <tr>\n",
479
+ " <th>1</th>\n",
480
+ " <td>chr4</td>\n",
481
+ " <td>113598179</td>\n",
482
+ " <td>113794787</td>\n",
483
+ " <td>train</td>\n",
484
+ " </tr>\n",
485
+ " <tr>\n",
486
+ " <th>2</th>\n",
487
+ " <td>chr11</td>\n",
488
+ " <td>18394952</td>\n",
489
+ " <td>18591560</td>\n",
490
+ " <td>train</td>\n",
491
+ " </tr>\n",
492
+ " </tbody>\n",
493
+ "</table>\n",
494
+ "</div>"
495
+ ],
496
+ "text/plain": [
497
+ " chrom start end split\n",
498
+ "0 chr18 895618 1092226 train\n",
499
+ "1 chr4 113598179 113794787 train\n",
500
+ "2 chr11 18394952 18591560 train"
501
+ ]
502
+ },
503
+ "execution_count": 12,
504
+ "metadata": {},
505
+ "output_type": "execute_result"
506
+ }
507
+ ],
508
+ "source": [
509
+ "artifact = run.use_artifact('enformer/human_intervals:latest')\n",
510
+ "dir = artifact.download()\n",
511
+ "enformer_intervals = pd.read_table(os.path.join(dir, \"data.tsv\"))\n",
512
+ "enformer_intervals.head(3)"
513
+ ]
514
+ },
515
+ {
516
+ "cell_type": "markdown",
517
+ "id": "842a7aa6-e8ae-4969-8bba-72bb532575c9",
518
+ "metadata": {},
519
+ "source": [
520
+ "## Split peaks based on their overlap with enformer"
521
+ ]
522
+ },
523
+ {
524
+ "cell_type": "code",
525
+ "execution_count": 13,
526
+ "id": "d3c8c95a-9386-4c6e-9f21-d4370dac178c",
527
+ "metadata": {},
528
+ "outputs": [],
529
+ "source": [
530
+ "ad.var = ad.var.reset_index(drop=True)"
531
+ ]
532
+ },
533
+ {
534
+ "cell_type": "code",
535
+ "execution_count": 14,
536
+ "id": "57727d0b-6187-4640-9947-d247d4225166",
537
+ "metadata": {},
538
+ "outputs": [],
539
+ "source": [
540
+ "ad.var['cre_idx'] = range(len(ad.var))"
541
+ ]
542
+ },
543
+ {
544
+ "cell_type": "code",
545
+ "execution_count": 15,
546
+ "id": "04f3e704-cd4d-44ea-bcc1-d4c9dc1db1db",
547
+ "metadata": {},
548
+ "outputs": [
549
+ {
550
+ "data": {
551
+ "text/plain": [
552
+ "split_\n",
553
+ "train 966953\n",
554
+ "test 72507\n",
555
+ "valid 71703\n",
556
+ "None 9670\n",
557
+ "testtrain 222\n",
558
+ "trainvalid 169\n",
559
+ "testvalid 95\n",
560
+ "Name: count, dtype: int64"
561
+ ]
562
+ },
563
+ "execution_count": 15,
564
+ "metadata": {},
565
+ "output_type": "execute_result"
566
+ }
567
+ ],
568
+ "source": [
569
+ "overlaps = bf.overlap(ad.var, enformer_intervals, how='left')\n",
570
+ "overlaps.split_ = overlaps.split_.fillna('None')\n",
571
+ "\n",
572
+ "overlaps = overlaps.groupby('cre_idx').split_.apply(lambda x: ''.join(list(np.unique(x))))\n",
573
+ "overlaps.value_counts()"
574
+ ]
575
+ },
576
+ {
577
+ "cell_type": "code",
578
+ "execution_count": 16,
579
+ "id": "72775c43-2996-456d-879a-e077b11ba736",
580
+ "metadata": {},
581
+ "outputs": [],
582
+ "source": [
583
+ "assert np.all(overlaps.index == ad.var.cre_idx)"
584
+ ]
585
+ },
586
+ {
587
+ "cell_type": "code",
588
+ "execution_count": 17,
589
+ "id": "a317db18-c0e9-425d-86da-98cd6bdac3e9",
590
+ "metadata": {},
591
+ "outputs": [
592
+ {
593
+ "data": {
594
+ "text/plain": [
595
+ "train 977014\n",
596
+ "test 72507\n",
597
+ "valid 71798\n",
598
+ "Name: count, dtype: int64"
599
+ ]
600
+ },
601
+ "execution_count": 17,
602
+ "metadata": {},
603
+ "output_type": "execute_result"
604
+ }
605
+ ],
606
+ "source": [
607
+ "new_splits = np.array(['train'] * len(overlaps))\n",
608
+ "new_splits[[(('valid' in x) and ('train' not in x)) for x in overlaps]] = 'valid'\n",
609
+ "new_splits[[(('test' in x) and ('train' not in x) and ('valid' not in x)) for x in overlaps]] = 'test'\n",
610
+ "pd.Series(new_splits).value_counts()"
611
+ ]
612
+ },
613
+ {
614
+ "cell_type": "code",
615
+ "execution_count": 18,
616
+ "id": "3c0f944d-ee42-45a9-ad3b-41e4a53aba10",
617
+ "metadata": {},
618
+ "outputs": [],
619
+ "source": [
620
+ "ad.var['enformer_split'] = overlaps\n",
621
+ "ad.var['split'] = new_splits"
622
+ ]
623
+ },
624
+ {
625
+ "cell_type": "markdown",
626
+ "id": "04ff9b90-956d-4150-bbf8-f5c29826f6fb",
627
+ "metadata": {},
628
+ "source": [
629
+ "## Save"
630
+ ]
631
+ },
632
+ {
633
+ "cell_type": "code",
634
+ "execution_count": 19,
635
+ "id": "e947777a-3a1f-4e07-995f-c0e85e9dedf6",
636
+ "metadata": {},
637
+ "outputs": [],
638
+ "source": [
639
+ "ad.write_h5ad('preprocessed.h5ad')"
640
+ ]
641
+ },
642
+ {
643
+ "cell_type": "code",
644
+ "execution_count": 20,
645
+ "id": "e39fb051-0a80-4832-a962-ab62e6995e95",
646
+ "metadata": {},
647
+ "outputs": [
648
+ {
649
+ "data": {
650
+ "text/plain": [
651
+ "<Artifact dataset>"
652
+ ]
653
+ },
654
+ "execution_count": 20,
655
+ "metadata": {},
656
+ "output_type": "execute_result"
657
+ }
658
+ ],
659
+ "source": [
660
+ "artifact = wandb.Artifact('dataset', type='dataset')\n",
661
+ "artifact.add_file(local_path='preprocessed.h5ad', name='data.h5ad')\n",
662
+ "run.log_artifact(artifact)"
663
+ ]
664
+ },
665
+ {
666
+ "cell_type": "code",
667
+ "execution_count": 21,
668
+ "id": "573db082-362c-4caa-a7d7-53e1dff271e6",
669
+ "metadata": {},
670
+ "outputs": [
671
+ {
672
+ "data": {
673
+ "text/html": [],
674
+ "text/plain": [
675
+ "<IPython.core.display.HTML object>"
676
+ ]
677
+ },
678
+ "metadata": {},
679
+ "output_type": "display_data"
680
+ },
681
+ {
682
+ "data": {
683
+ "text/html": [
684
+ " View run <strong style=\"color:#cdcd00\">prep</strong> at: <a href='https://wandb.ai/grelu/human-atac-catlas/runs/vphymp69' target=\"_blank\">https://wandb.ai/grelu/human-atac-catlas/runs/vphymp69</a><br> View project at: <a href='https://wandb.ai/grelu/human-atac-catlas' target=\"_blank\">https://wandb.ai/grelu/human-atac-catlas</a><br>Synced 6 W&B file(s), 0 media file(s), 2 artifact file(s) and 0 other file(s)"
685
+ ],
686
+ "text/plain": [
687
+ "<IPython.core.display.HTML object>"
688
+ ]
689
+ },
690
+ "metadata": {},
691
+ "output_type": "display_data"
692
+ },
693
+ {
694
+ "data": {
695
+ "text/html": [
696
+ "Find logs at: <code>./wandb/run-20250306_000043-vphymp69/logs</code>"
697
+ ],
698
+ "text/plain": [
699
+ "<IPython.core.display.HTML object>"
700
+ ]
701
+ },
702
+ "metadata": {},
703
+ "output_type": "display_data"
704
+ }
705
+ ],
706
+ "source": [
707
+ "run.finish()"
708
+ ]
709
+ },
710
+ {
711
+ "cell_type": "code",
712
+ "execution_count": null,
713
+ "id": "8e408e2f-babd-491b-8287-f131b6a82c7e",
714
+ "metadata": {},
715
+ "outputs": [],
716
+ "source": []
717
+ }
718
+ ],
719
+ "metadata": {
720
+ "kernelspec": {
721
+ "display_name": "Python 3 (ipykernel)",
722
+ "language": "python",
723
+ "name": "python3"
724
+ },
725
+ "language_info": {
726
+ "codemirror_mode": {
727
+ "name": "ipython",
728
+ "version": 3
729
+ },
730
+ "file_extension": ".py",
731
+ "mimetype": "text/x-python",
732
+ "name": "python",
733
+ "nbconvert_exporter": "python",
734
+ "pygments_lexer": "ipython3",
735
+ "version": "3.11.9"
736
+ }
737
+ },
738
+ "nbformat": 4,
739
+ "nbformat_minor": 5
740
+ }
README.md CHANGED
@@ -1,3 +1,52 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ task_categories:
4
+ - tabular-classification
5
+ tags:
6
+ - biology
7
+ - genomics
8
+ pretty_name: "CATlas Human Enhancer Binary Matrix"
9
+ size_categories:
10
+ - 1M<n<10M
11
+ ---
12
+
13
+ # human-catlas-atac-data
14
+
15
+ ## Dataset Summary
16
+ This dataset provides a binary accessibility matrix of candidate Cis-Regulatory Elements (cCREs) across human cell types. It is derived from the CATlas project (https://decoder-genetics.wustl.edu/catlasv1/catlas_humanenhancer/#!/). The matrix identifies which genomic regions are accessible (1) or inaccessible (0) across 204 distinct cell types. The data is derived from https://decoder-genetics.wustl.edu/catlasv1/humanenhancer/data/cCRE_by_cell_type/. The hg38 genome build was used.
17
+
18
+ ## Repository Content
19
+ 1. `data.h5ad`: The main dataset stored in AnnData format.
20
+ 2. `1_data.ipynb`: Jupyter notebook containing the preprocessing steps used to generate the `.h5ad` file.
21
+
22
+ ## Dataset Structure
23
+
24
+ ### AnnData Object Dimensions
25
+ - **n_obs (Cell Types):** 204
26
+ - **n_vars (cCREs):** 1,121,319
27
+
28
+ ### Data Fields
29
+ - **`.X`**: A sparse binary matrix where rows are cell types and columns are genomic regions (cCREs).
30
+ - **`.obs` (Cell Type Metadata):**
31
+ - `cell type`: The descriptive name of the human cell type/cluster.
32
+ - **`.var` (Genomic Feature Metadata):**
33
+ - `chrom`, `start`, `end`: Genomic coordinates (hg38).
34
+ - `cre_class`: Classification of the regulatory element.
35
+ - `in_fetal` / `in_adult`: indicators of activity in developmental stages.
36
+ - `cre_module`: Associated regulatory module.
37
+ - `enformer_split`: Overlap with the data splits used for training the Enformer model.
38
+ - `split`: Splits used for downstream modeling (training/validation/test).
39
+
40
+ ## Usage
41
+
42
+ ```python
43
+ import anndata as ad
44
+ from huggingface_hub import hf_hub_download
45
+
46
+ file_path = hf_hub_download(
47
+ repo_id="Genentech/human-atac-catlas-data",
48
+ filename="data.h5ad"
49
+ )
50
+
51
+ ad = anndata.read_h5ad(file_path)
52
+ ```
data.h5ad ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:50059ed67b84d0237d385a6dc89e95bdaeb8b877bd75b269c25df777de8d19a5
3
+ size 187877866