File size: 13,997 Bytes
3cd46ba
 
7f74728
 
 
 
 
 
 
 
 
 
d1052fe
 
7f74728
d1052fe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0e25eec
 
 
 
 
627e50d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
489d46f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7f74728
 
489d46f
d12fc8e
 
489d46f
d12fc8e
489d46f
 
40ce10b
 
 
 
 
 
 
 
 
 
825d1c4
 
40ce10b
825d1c4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5aaf926
 
 
 
 
 
 
 
 
 
65b159e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40ce10b
 
65b159e
a48b2f1
 
65b159e
a48b2f1
65b159e
 
a9420d1
 
 
 
 
 
 
 
 
 
ccbc21c
 
a9420d1
ccbc21c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ba428ca
 
 
 
 
 
1255619
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a9420d1
 
1255619
a041bb2
 
1255619
a041bb2
1255619
 
40ce10b
3cd46ba
 
 
 
 
 
 
 
 
ef2285e
 
3cd46ba
ef2285e
 
 
 
 
1324175
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3cd46ba
 
1324175
6528156
 
1324175
6528156
1324175
 
3cd46ba
7f74728
 
 
 
d12fc8e
 
40ce10b
 
 
 
a48b2f1
 
a9420d1
 
 
 
a041bb2
 
3cd46ba
 
 
 
6528156
 
1da297c
 
 
 
 
 
91b84aa
1da297c
 
 
3cd46ba
1da297c
24a1203
 
3eec64e
1da297c
996c695
1da297c
c688e75
 
36049b0
 
 
c688e75
 
 
352a046
c688e75
 
 
 
 
 
 
91b84aa
c688e75
 
 
 
 
91b84aa
 
 
36049b0
 
 
91b84aa
 
36049b0
 
91b84aa
36049b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c688e75
 
36049b0
1da297c
 
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
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
---
dataset_info:
- config_name: all
  features:
  - name: id
    dtype: string
  - name: sequence
    dtype: string
  - name: length
    dtype: int64
  - name: terms
    sequence: string
  - name: terms_embedding
    sequence: float64
  - name: taxon_id
    dtype: string
  - name: stratum_id
    dtype:
      class_label:
        names:
          '0': '0'
          '1': '1'
          '2': '10'
          '3': '11'
          '4': '12'
          '5': '13'
          '6': '14'
          '7': '15'
          '8': '16'
          '9': '17'
          '10': '18'
          '11': '19'
          '12': '2'
          '13': '20'
          '14': '21'
          '15': '22'
          '16': '23'
          '17': '24'
          '18': '25'
          '19': '26'
          '20': '27'
          '21': '28'
          '22': '29'
          '23': '3'
          '24': '30'
          '25': '31'
          '26': '32'
          '27': '33'
          '28': '34'
          '29': '35'
          '30': '36'
          '31': '37'
          '32': '38'
          '33': '39'
          '34': '4'
          '35': '40'
          '36': '41'
          '37': '42'
          '38': '43'
          '39': '44'
          '40': '45'
          '41': '46'
          '42': '47'
          '43': '48'
          '44': '49'
          '45': '5'
          '46': '50'
          '47': '51'
          '48': '52'
          '49': '53'
          '50': '54'
          '51': '55'
          '52': '56'
          '53': '57'
          '54': '58'
          '55': '59'
          '56': '6'
          '57': '60'
          '58': '61'
          '59': '62'
          '60': '63'
          '61': '64'
          '62': '65'
          '63': '66'
          '64': '67'
          '65': '68'
          '66': '69'
          '67': '7'
          '68': '70'
          '69': '71'
          '70': '72'
          '71': '73'
          '72': '74'
          '73': '75'
          '74': '76'
          '75': '77'
          '76': '78'
          '77': '79'
          '78': '8'
          '79': '80'
          '80': '81'
          '81': '82'
          '82': '83'
          '83': '84'
          '84': '85'
          '85': '86'
          '86': '87'
          '87': '88'
          '88': '89'
          '89': '9'
          '90': '90'
          '91': '91'
          '92': '92'
          '93': '93'
          '94': '94'
          '95': '95'
          '96': '96'
          '97': '97'
          '98': '98'
          '99': '99'
  splits:
  - name: train
    num_bytes: 193626393.11677656
    num_examples: 128021
  - name: test
    num_bytes: 21514715.88322343
    num_examples: 14225
  download_size: 154163126
  dataset_size: 215141109.0
- config_name: bp
  features:
  - name: id
    dtype: string
  - name: sequence
    dtype: string
  - name: length
    dtype: int64
  - name: terms
    sequence: string
  - name: terms_embedding
    sequence: float64
  - name: taxon_id
    dtype: string
  - name: stratum_id
    dtype:
      class_label:
        names:
          '0': '0'
          '1': '1'
          '2': '10'
          '3': '11'
          '4': '12'
          '5': '13'
          '6': '14'
          '7': '15'
          '8': '16'
          '9': '17'
          '10': '18'
          '11': '19'
          '12': '2'
          '13': '20'
          '14': '21'
          '15': '22'
          '16': '23'
          '17': '24'
          '18': '25'
          '19': '26'
          '20': '27'
          '21': '28'
          '22': '29'
          '23': '3'
          '24': '30'
          '25': '31'
          '26': '32'
          '27': '33'
          '28': '34'
          '29': '35'
          '30': '36'
          '31': '37'
          '32': '38'
          '33': '39'
          '34': '4'
          '35': '40'
          '36': '41'
          '37': '42'
          '38': '43'
          '39': '44'
          '40': '45'
          '41': '46'
          '42': '47'
          '43': '48'
          '44': '49'
          '45': '5'
          '46': '50'
          '47': '51'
          '48': '52'
          '49': '53'
          '50': '54'
          '51': '55'
          '52': '56'
          '53': '57'
          '54': '58'
          '55': '59'
          '56': '6'
          '57': '60'
          '58': '61'
          '59': '62'
          '60': '63'
          '61': '64'
          '62': '65'
          '63': '66'
          '64': '67'
          '65': '68'
          '66': '69'
          '67': '7'
          '68': '70'
          '69': '71'
          '70': '72'
          '71': '73'
          '72': '74'
          '73': '75'
          '74': '76'
          '75': '77'
          '76': '78'
          '77': '79'
          '78': '8'
          '79': '80'
          '80': '81'
          '81': '82'
          '82': '83'
          '83': '84'
          '84': '85'
          '85': '86'
          '86': '87'
          '87': '88'
          '88': '89'
          '89': '9'
          '90': '90'
          '91': '91'
          '92': '92'
          '93': '93'
          '94': '94'
          '95': '95'
          '96': '96'
          '97': '97'
          '98': '98'
          '99': '99'
  splits:
  - name: train
    num_bytes: 129187926.9
    num_examples: 82989
  - name: test
    num_bytes: 14354214.1
    num_examples: 9221
  download_size: 107191842
  dataset_size: 143542141.0
- config_name: cc
  features:
  - name: id
    dtype: string
  - name: sequence
    dtype: string
  - name: length
    dtype: int64
  - name: terms
    sequence: string
  - name: terms_embedding
    sequence: float64
  - name: taxon_id
    dtype: string
  - name: stratum_id
    dtype:
      class_label:
        names:
          '0': '0'
          '1': '1'
          '2': '10'
          '3': '11'
          '4': '12'
          '5': '13'
          '6': '14'
          '7': '15'
          '8': '16'
          '9': '17'
          '10': '18'
          '11': '19'
          '12': '2'
          '13': '20'
          '14': '21'
          '15': '22'
          '16': '23'
          '17': '24'
          '18': '25'
          '19': '26'
          '20': '27'
          '21': '28'
          '22': '29'
          '23': '3'
          '24': '30'
          '25': '31'
          '26': '32'
          '27': '33'
          '28': '34'
          '29': '35'
          '30': '36'
          '31': '37'
          '32': '38'
          '33': '39'
          '34': '4'
          '35': '40'
          '36': '41'
          '37': '42'
          '38': '43'
          '39': '44'
          '40': '45'
          '41': '46'
          '42': '47'
          '43': '48'
          '44': '49'
          '45': '5'
          '46': '50'
          '47': '51'
          '48': '52'
          '49': '53'
          '50': '54'
          '51': '55'
          '52': '56'
          '53': '57'
          '54': '58'
          '55': '59'
          '56': '6'
          '57': '60'
          '58': '61'
          '59': '62'
          '60': '63'
          '61': '64'
          '62': '65'
          '63': '66'
          '64': '67'
          '65': '68'
          '66': '69'
          '67': '7'
          '68': '70'
          '69': '71'
          '70': '72'
          '71': '73'
          '72': '74'
          '73': '75'
          '74': '76'
          '75': '77'
          '76': '78'
          '77': '79'
          '78': '8'
          '79': '80'
          '80': '81'
          '81': '82'
          '82': '83'
          '83': '84'
          '84': '85'
          '85': '86'
          '86': '87'
          '87': '88'
          '88': '89'
          '89': '9'
          '90': '90'
          '91': '91'
          '92': '92'
          '93': '93'
          '94': '94'
          '95': '95'
          '96': '96'
          '97': '97'
          '98': '98'
          '99': '99'
  splits:
  - name: train
    num_bytes: 76889746.48893577
    num_examples: 83620
  - name: test
    num_bytes: 8544122.511064233
    num_examples: 9292
  download_size: 64110332
  dataset_size: 85433869.0
- config_name: mf
  features:
  - name: id
    dtype: string
  - name: sequence
    dtype: string
  - name: length
    dtype: int64
  - name: terms
    sequence: string
  - name: terms_embedding
    sequence: float64
  - name: taxon_id
    dtype: string
  - name: stratum_id
    dtype:
      class_label:
        names:
          '0': '0'
          '1': '1'
          '2': '10'
          '3': '11'
          '4': '12'
          '5': '13'
          '6': '14'
          '7': '15'
          '8': '16'
          '9': '17'
          '10': '18'
          '11': '19'
          '12': '2'
          '13': '20'
          '14': '21'
          '15': '22'
          '16': '23'
          '17': '24'
          '18': '25'
          '19': '26'
          '20': '27'
          '21': '28'
          '22': '29'
          '23': '3'
          '24': '30'
          '25': '31'
          '26': '32'
          '27': '33'
          '28': '34'
          '29': '35'
          '30': '36'
          '31': '37'
          '32': '38'
          '33': '39'
          '34': '4'
          '35': '40'
          '36': '41'
          '37': '42'
          '38': '43'
          '39': '44'
          '40': '45'
          '41': '46'
          '42': '47'
          '43': '48'
          '44': '49'
          '45': '5'
          '46': '50'
          '47': '51'
          '48': '52'
          '49': '53'
          '50': '54'
          '51': '55'
          '52': '56'
          '53': '57'
          '54': '58'
          '55': '59'
          '56': '6'
          '57': '60'
          '58': '61'
          '59': '62'
          '60': '63'
          '61': '64'
          '62': '65'
          '63': '66'
          '64': '67'
          '65': '68'
          '66': '69'
          '67': '7'
          '68': '70'
          '69': '71'
          '70': '72'
          '71': '73'
          '72': '74'
          '73': '75'
          '74': '76'
          '75': '77'
          '76': '78'
          '77': '79'
          '78': '8'
          '79': '80'
          '80': '81'
          '81': '82'
          '82': '83'
          '83': '84'
          '84': '85'
          '85': '86'
          '86': '87'
          '87': '88'
          '88': '89'
          '89': '9'
          '90': '90'
          '91': '91'
          '92': '92'
          '93': '93'
          '94': '94'
          '95': '95'
          '96': '96'
          '97': '97'
          '98': '98'
          '99': '99'
  splits:
  - name: train
    num_bytes: 69470217.72236988
    num_examples: 70773
  - name: test
    num_bytes: 7719240.277630123
    num_examples: 7864
  download_size: 63311313
  dataset_size: 77189458.0
configs:
- config_name: all
  data_files:
  - split: train
    path: all/train-*
  - split: test
    path: all/test-*
- config_name: bp
  data_files:
  - split: train
    path: bp/train-*
  - split: test
    path: bp/test-*
- config_name: cc
  data_files:
  - split: train
    path: cc/train-*
  - split: test
    path: cc/test-*
- config_name: mf
  data_files:
  - split: train
    path: mf/train-*
  - split: test
    path: mf/test-*
license: apache-2.0
task_categories:
- text-classification
tags:
- proteomics
- protein
- gene-ontology
pretty_name: CAFA 5
size_categories:
- 100K<n<1M
---

# CAFA 5

This is the [CAFA 5](https://www.kaggle.com/competitions/cafa-5-protein-function-prediction) dataset of 142k protein sequences annotated with their gene ontology (GO) terms. The samples are divided into three subsets each containing a set of GO terms that are associated with one of the three subgraphs of the gene ontology - Molecular Function, Biological Process, and Cellular Component. In addition, we provide a stratified train/test split that utilizes term embeddings to distribute term labels equally. The term embeddings are included in the dataset and can be used to stratify custom splits or to search for sequences with similar gene ontologies.

The code to export this dataset can be found [here](https://github.com/andrewdalpino/CAFA5).

## Subsets

The [CAFA 5](https://huggingface.co/datasets/andrewdalpino/CAFA5) dataset is available on HuggingFace Hub and can be loaded using the HuggingFace [Datasets](https://huggingface.co/docs/datasets) library. 

The dataset is divided into three subsets according to the GO terms that the sequences are annotated with.

- `all` - All annotations
- `mf` - Only molecular function terms
- `cc` - Only celluar component terms
- `bp` - Only biological process terms

To load the default CAFA 5 dataset with all function annotations you can use the example below.

```python
from datasets import load_dataset

dataset = load_dataset("andrewdalpino/CAFA5")
```

To load a subset of the CAFA 5 dataset use the example below.

```python
dataset = load_dataset("andrewdalpino/CAFA5", "mf")
```

## Splits

We provide a 90/10 `train` and `test` split for your convenience. The subsets were determined using a stratified approach which assigns cluster numbers to sequences based on their terms embeddings. We've included the stratum IDs so that you can generate additional custom stratified splits as shown in the example below.

```python
from datasets import load_dataset

dataset = load_dataset("andrewdalpino/CAFA5", split="train")

dataset = dataset.class_encode_column("stratum_id")

dataset = dataset.train_test_split(test_size=0.2, stratify_by_column="stratum_id")
```

## Filtering

You can also filter the samples of the dataset like in the example below.

```python
dataset = dataset.filter(lambda sample: sample["length"] <= 2048)
```

## Tokenizing

Some tasks may require you to tokenize the amino acid sequences. In this example, we loop through the samples and add a `tokens` column to store the tokenized sequences.

```python
def tokenize(sample: dict): list[int]:
    tokens = tokenizer.tokenize(sample["sequence"])

    sample["tokens"] = tokens

    return sample

dataset = dataset.map(tokenize, remove_columns="sequence")
```

## Original Dataset

Iddo Friedberg, Predrag Radivojac, Clara De Paolis, Damiano Piovesan, Parnal Joshi, Walter Reade, and Addison Howard. CAFA 5 Protein Function Prediction. https://kaggle.com/competitions/cafa-5-protein-function-prediction, 2023. Kaggle.