--- dataset_info: features: - name: sequence dtype: string - name: annotation list: int64 - name: description dtype: string - name: labels dtype: int64 splits: - name: train num_bytes: 71733637 num_examples: 60666 - name: valid num_bytes: 3939369 num_examples: 3316 - name: test num_bytes: 3960144 num_examples: 3420 download_size: 53137709 dataset_size: 79633150 configs: - config_name: default data_files: - split: train path: data/train-* - split: valid path: data/valid-* - split: test path: data/test-* license: cc-by-4.0 language: - en tags: - biology - protein - protein-language-model - embeddings - representation-learning - uniprot - gene-ontology pretty_name: PLAT (Protein Language Alignment Tuples) task_categories: - feature-extraction - sentence-similarity - text-classification --- # PLAT: Protein Language Alignment Tuples `plat_data` is a curated, cluster-split dataset of protein sequences paired with structured functional annotations and natural-language descriptions. It is designed to train and evaluate cross-encoder alignment models (Vec2Vec, Mat2Mat) that map representations between different protein language models (PLMs), or between PLMs and natural-language encoders. Each row contains: - a protein `sequence` (amino-acid string), - an `annotation` list of integer IDs covering Gene Ontology, EC numbers, InterPro, Gene3D, cofactors, and UniProt keywords, - a `description` string assembled from UniProt free-text curation (function, miscellaneous notes, subcellular localization, domain). ## Dataset Schema | Field | Type | Description | |---------------|-------------|-------------| | `sequence` | `string` | Canonical amino-acid sequence in single-letter IUPAC code. | | `annotation` | `list[int]` | Sorted, deduplicated integer IDs decoded via the `label2id.pkl` vocabulary produced by `data/process_uniprot_av.py`. Each ID corresponds to a typed annotation key of the form `"_"` where suffix is one of `bp`, `cc`, `mf`, `ec`, `cofactor`, `ip`, `threed`, `keywords`. | | `description` | `string` | Structured free-text block beginning with `"The following text describes a protein:"` and containing any present of `Function:`, `Miscellaneous:`, `Subcellular Localization:`, `Domain:` subsections. Every row is guaranteed to contain a `Function:` block (see "Preferential sampling" below). | | `labels` | `int` | Placeholder column (always `0`), added by `data/add_dummy_labels.py` so downstream `Trainer` pipelines that expect a `labels` key work without modification. | ### Splits The dataset has three splits: `train`, `valid`, and `test`. Splitting is performed at the cluster level (see "Clustering and splitting" below), so no sequence in `valid` or `test` shares more than ~40% identity with any sequence in `train`. ## Data Source The primary upstream source is UniProtKB, restricted to entries with manually curated Gene Ontology annotations (the "GO manual" subset). Two snapshots are used: - `uniprotkb_go_manual_2025_11_18.tsv.gz` (1,380,840 entries) for structured annotations. - `uniprotkb_go_manual_2025_12_02.tsv.gz` (1,380,840 entries) for free-text descriptions. Columns pulled from the UniProt TSV are: | UniProt column | Used for | Parsing | |----------------|----------|---------| | `Entry` | record key | verbatim | | `Sequence` | `sequence` | verbatim | | `EC number` | annotations | split on `;`, strip | | `Cofactor` | annotations | parse `Name=` from each `COFACTOR:` entry | | `Gene Ontology (biological process)` | annotations | extract `GO:xxxxxxx` IDs | | `Gene Ontology (cellular component)` | annotations | extract `GO:xxxxxxx` IDs | | `Gene Ontology (molecular function)` | annotations | extract `GO:xxxxxxx` IDs | | `InterPro` | annotations | split on `;`, drop trailing empty | | `Gene3D` | annotations | split on `;`, drop trailing empty | | `Keywords` | annotations | split on `;`, strip | | `Function [CC]` | description | see text cleaning | | `Miscellaneous [CC]` | description | see text cleaning | | `Subcellular location [CC]` | description | see text cleaning | | `Domain [CC]` | description | see text cleaning | ### Annotation vocabulary `data/process_uniprot_av.py` streams the UniProt TSV twice. The first pass builds a `label2id` dictionary whose keys are typed strings (e.g. `GO:0016310_bp`, `1.1.1.1_ec`, `IPR000878_ip`, `ATP-binding_keywords`, `K(+)_cofactor`). The second pass emits `camp_data.csv` with columns `[sequence, annotations]`, where `annotations` is the sorted, deduplicated list of integer IDs for that protein. The `label2id.pkl` and `id2label.pkl` files are the authoritative mapping used throughout the pipeline. The resulting table is pushed to the intermediate dataset `lhallee/camp_data_11_2025`. ### Description assembly `data/process_uniprot_cc.py` builds the free-text description by concatenating the four CC columns in order (`Function`, `Miscellaneous`, `Subcellular location`, `Domain`), each under its own header. Text cleaning removes: - `(PubMed:...)` inline citations, - `{ECO:...}` evidence codes, - UniProt CC prefixes (`FUNCTION: `, `MISC: `, `SUBCELLULAR LOCATION: `, `DOMAIN: `), - redundant whitespace and stray punctuation artifacts from the removals above. A resulting row looks like: ``` The following text describes a protein: Function: Catalyzes the reversible conversion of methylmalonyl-CoA to succinyl-CoA... Subcellular Localization: Mitochondrial matrix... ``` ## Build Pipeline The full pipeline is four stages. All scripts live under [data/](data/) in the source repo. ### Stage 1: UniProt ingestion and annotation curation - Input: `uniprotkb_go_manual_2025_11_18.tsv.gz` and `uniprotkb_go_manual_2025_12_02.tsv.gz`. - [data/process_uniprot_av.py](data/process_uniprot_av.py) produces `camp_data.csv` (sequence + integer annotation list) and the `label2id.pkl` / `id2label.pkl` vocabulary files. - [data/process_uniprot_cc.py](data/process_uniprot_cc.py) produces `seq_descriptions.tsv` (entry + sequence + structured description). The sequence-keyed dictionaries `seq_annotation_dict.pkl` and `seq_description_dict.pkl` are later used by the final assembly step to look up annotations and descriptions by exact sequence match. The annotation table is pushed to [lhallee/camp_data_11_2025](https://huggingface.co/datasets/lhallee/camp_data_11_2025) as an intermediate artifact. ### Stage 2: Deduplication Before clustering, exact-duplicate sequences are removed with `drop_duplicates(subset=['sequence'])` (see [data/build_dataset.py](data/build_dataset.py)). ### Stage 3: Clustering and splitting Clustering and split assignment are performed by [data/build_dataset.py](data/build_dataset.py): - Sequences are written to a FASTA file with integer IDs. - CD-HIT is invoked inside a Docker container built from the official CD-HIT Dockerfile. - **Identity threshold: 0.4** (40% sequence identity), word size `-n 5`. This is the threshold actually used for the published PLAT release, as recorded by the cluster filename `output_lhallee_camp_data_11_2025_0.4.clstr`. - The `.clstr` output is parsed into `cluster_dict: {cluster_id -> [seq_ids]}` and `id_seq_dict: {seq_id -> sequence}`. - Clusters are shuffled and partitioned: - **5% valid clusters, 5% test clusters, 90% train clusters.** - The four working pickles (`cluster_dict.pkl`, `id_seq_dict.pkl`, `final_cluster_dict.pkl`, `seq_annotation_dict.pkl`) are uploaded to an auxiliary private repo for reproducibility. Because splits are assigned by cluster, any two sequences in different splits are less than ~40% identical under CD-HIT's greedy incremental clustering, which gives a realistic generalization benchmark for PLM alignment. ### Stage 4: PLAT assembly (preferential sampling) [data/build_plat_data.py](data/build_plat_data.py) produces the final dataset: 1. For each cluster in each split, gather all member sequences. 2. Keep only sequences for which both an `annotation` and a `description` exist. 3. Keep only the subset whose `description` contains the literal substring `"Function:"` (that is, sequences with at least a UniProt `Function [CC]` annotation after text cleaning). 4. Pick one sequence uniformly at random from that subset (seed `42`). 5. If no candidate survives, **the cluster is skipped entirely**. This biases PLAT toward clusters containing at least one well-characterized member. 6. The resulting records (`sequence`, `annotation`, `description`) are assembled into a `DatasetDict(train, valid, test)` and pushed to `lhallee/plat_data`. A final `labels` column of constant `0` is added by [data/add_dummy_labels.py](data/add_dummy_labels.py) for compatibility with generic `Trainer` pipelines. ## Reproducing the Build ```bash # 1. Parse UniProt TSV into annotations + vocabulary py -m data.process_uniprot_av # -> camp_data.csv, label2id.pkl, id2label.pkl # -> pushes lhallee/camp_data_11_2025 # 2. Parse UniProt TSV into descriptions py -m data.process_uniprot_cc # -> seq_descriptions.tsv # 3. Cluster with CD-HIT and split by cluster (requires Docker) py -m data.build_dataset \ --hf_token \ --dataset_path lhallee/camp_data_11_2025 \ --similarity_threshold 0.4 \ --n 5 \ --valid_percentage 0.05 \ --test_percentage 0.05 # 4. Assemble PLAT with preferential Function-aware sampling py -m data.build_plat_data \ --hf_token \ --repo_name lhallee/plat_data \ --seed 42 ``` ## Intended Use PLAT was constructed to train and evaluate representation-alignment models: - **Vec2Vec**: align pooled (mean + variance) embeddings from one PLM to another, or from a PLM to a natural-language encoder of the `description` field. - **Mat2Mat**: align full residue-by-residue embedding matrices between two PLMs. - **Cross-modal retrieval**: use the `description` column with a text encoder (for example ModernBERT or GPT-OSS) and the `sequence` column with a PLM (for example ESMC-600), then evaluate whether aligned embeddings retrieve each other. Typical consumption patterns in the source repo read columns as `(sequence, sequence)`, `(sequence, description)`, or `(description, description)` pairs. ## Licensing and Attribution All sequences and annotations are derived from UniProtKB and are redistributed under the UniProt terms of use (Creative Commons Attribution 4.0, `CC BY 4.0`). If you use PLAT, please also cite UniProt: > The UniProt Consortium. UniProt: the Universal Protein Knowledgebase in 2025. *Nucleic Acids Research*, 2025. And the dependent databases surfaced in the annotation vocabulary: Gene Ontology, Enzyme Commission (IUBMB), InterPro, Gene3D, and the UniProt Keyword ontology. ## Known Limitations - **Manual-annotation bias.** Only UniProt entries with manually curated GO terms are considered, and only clusters containing at least one member with a `Function [CC]` block appear in the final dataset. Taxa and protein families that are underrepresented in Swiss-Prot are correspondingly underrepresented here. - **One representative per cluster.** Within-cluster diversity (paralogs, species variants) is not preserved: each cluster contributes a single randomly chosen, function-annotated representative. - **Descriptions are post-processed.** PubMed citations, ECO evidence codes, and the CC-prefix tags are stripped, which simplifies downstream tokenization but loses provenance information relative to the raw UniProt text. - **Integer annotation labels are only meaningful via `label2id.pkl`.** The integer space mixes eight annotation types; training code that treats it as a single flat multi-label target should be aware that different IDs correspond to semantically different taxonomies. - **Snapshot-frozen.** PLAT is built from a fixed UniProt release (manual-GO subset, November-December 2025) and will not reflect later curation updates until rebuilt.