Datasets:
Add normalized Parquet train/test Human Protein Atlas table
Browse filesFiles changed (7)
- README.md+107-56
- data/test-00000-of-00001.parquetAdded+3
- data/train-00000-of-00001.parquetAdded+3
- dataset_summary.jsonAdded+127
- metadata/cancer_prognostics.parquetAdded+3
- metadata/rna_expression_measurements.parquetAdded+3
- scripts/prepare_hpa_dataset.pyAdded+313
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283---license: cc-by-sa-4.0pretty_name: Human Protein Atlassize_categories:- 10K<n<100Ktask_categories:- otherlanguage:- entags:- biology- proteins- annotation- human-protein-atlas- jsonl---# Human Protein AtlasPer-protein annotations from the Human Protein Atlas (proteinatlas.json), normalized to newline-delimited JSON with row-level provenance.Processed and uploaded by the [MegaData](https://github.com/) post-download pipeline(internal repo). Original source: <https://www.proteinatlas.org/about/download>.## Statistics| | ||---|---|| Table files | 1 || Total rows | 20,162 || Total bytes | 148.67 MiB (155,892,614) |## Tables| Table | Rows | Bytes ||---|---:|---:|| `annotation_human_protein_atlas_proteinatlas.json.gz.jsonl` | 20,162 | 148.67 MiB |## Layout```.├── _MANIFEST.json # aggregate manifest (per-table counts)└── tables/<source_slug>.jsonl # normalized rows (one JSON object per line)```Each line in a `tables/*.jsonl` file is a JSON object with at least`dataset_id`, `row` (the raw upstream row), `row_index`, and `source_file`fields, so every row carries its upstream provenance.## Loading```bashhf download LiteFold/HumanProteinAtlas --repo-type dataset --local-dir ./human_protein_atlas```Programmatic streaming:```pythonimport jsonfrom pathlib import Pathfrom huggingface_hub import snapshot_downloadlocal = snapshot_download(repo_id="LiteFold/HumanProteinAtlas", repo_type="dataset")for jsonl in sorted(Path(local, "tables").glob("*.jsonl")):with jsonl.open() as f:for line in f:row = json.loads(line)... # row["row"] is the upstream record```## LicenseCC BY-SA 4.0 (Human Protein Atlas).## Citation> Uhlen M, et al. Tissue-based map of the human proteome. Science, 347(6220):1260419, 2015.## ProvenanceBuilt from the local manifest entry `human_protein_atlas` of `manifests/atlas_download_plan.json`.Pipeline source: `megadata-post normalize --dataset human_protein_atlas --tables-only`.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134---pretty_name: Human Protein Atlas Gene Annotationslicense: othertags:- biology- proteins- human- human-protein-atlas- gene-expression- subcellular-localization- parquetconfigs:- config_name: defaultdata_files:- split: trainpath: data/train-*.parquet- split: testpath: data/test-*.parquet---# Human Protein Atlas Gene AnnotationsThis dataset contains a viewer-friendly gene-level Parquet table derived from the Human Protein Atlas JSONL source in this repository. Each row is one gene/protein entry. Repeated cancer-prognostic and RNA expression measurements are available as metadata tables.## SplitsThe split is deterministic by Ensembl ID: `sha256(ensembl_id) % 10`. Bucket `0` is `test`; buckets `1` through `9` are `train`.| Split | Rows ||---|---:|| train | 18,138 || test | 2,024 || total | 20,162 |## Dataset Statistics| Field | Value ||---|---:|| Gene rows | 20,162 || Cancer prognostic metadata rows | 442,504 || RNA expression measurement rows | 149,150 |## Usage```bashpip install datasets```Load all splits:```pythonfrom datasets import load_datasetds = load_dataset("LiteFold/HumanProteinAtlas")print(ds)print(ds["train"][0]["gene"])```Load one split:```pythonfrom datasets import load_datasettrain = load_dataset("LiteFold/HumanProteinAtlas", split="train")```Filter genes with protein-level evidence:```pythonfrom datasets import load_datasetds = load_dataset("LiteFold/HumanProteinAtlas", split="train")protein_level = ds.filter(lambda row: row["evidence"] == "Evidence at protein level")print(protein_level[0])```Load metadata tables directly:```pythonimport pandas as pdfrom huggingface_hub import hf_hub_downloadprognostics_path = hf_hub_download(repo_id="LiteFold/HumanProteinAtlas",repo_type="dataset",filename="metadata/cancer_prognostics.parquet",)prognostics = pd.read_parquet(prognostics_path)print(prognostics.head())expression_path = hf_hub_download(repo_id="LiteFold/HumanProteinAtlas",repo_type="dataset",filename="metadata/rna_expression_measurements.parquet",)expression = pd.read_parquet(expression_path)print(expression.head())```## Key Columns| Column | Description ||---|---|| `ensembl_id` | Ensembl gene ID. || `gene` | Gene symbol. || `gene_description` | Gene/protein description. || `uniprot` | UniProt accession, when available. || `chromosome` | Chromosome. || `position` | Genomic position string. || `evidence` | Main HPA evidence level. || `hpa_evidence` | HPA-specific evidence level. || `uniprot_evidence` | UniProt evidence level. || `nextprot_evidence` | neXtProt evidence level. || `antibodies` | HPA antibody IDs. || `gene_synonyms` | Gene synonyms. || `protein_classes` | Protein class labels. || `biological_processes` | Biological process annotations. || `molecular_functions` | Molecular function annotations. || `disease_involvement` | Disease involvement labels. || `subcellular_main_locations` | Main subcellular locations. || `subcellular_additional_locations` | Additional subcellular locations. || `secretome_locations` | Secretome location annotations. || `secretome_functions` | Secretome function annotations. || `rna_tissue_specificity` | RNA tissue specificity category. || `rna_tissue_distribution` | RNA tissue distribution category. || `prognostic_cancer_count` | Number of cancers where the gene is prognostic. || `validated_prognostic_cancer_count` | Number of validated prognostic cancer entries. || `potential_prognostic_cancer_count` | Number of potential prognostic cancer entries. || `prognostic_cancers` | Cancer names with prognostic entries. || `split_bucket` | Deterministic split bucket from `sha256(ensembl_id) % 10`. |## PreparationThe normalization script used to create the Parquet files is included at `scripts/prepare_hpa_dataset.py`.
123version https://git-lfs.github.com/spec/v1oid sha256:94e1aa6381607bf895a4c4d0493485e44bde2a9b93e9689c11daeef0d134e1e1size 234848123version https://git-lfs.github.com/spec/v1oid sha256:2269abf21bc9f3f570bfb81647703955161296da985941a88e7e8c291dfd5a0csize 1646557123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127{ "source": "LiteFold/HumanProteinAtlas", "entry_rows": 20162, "cancer_prognostic_rows": 442504, "rna_expression_measurement_rows": 149150, "splits": { "train": 18138, "test": 2024 }, "split_strategy": "deterministic sha256(ensembl_id) % 10; bucket 0 is test, buckets 1-9 are train", "evidence_counts": { "Evidence at protein level": 18564, "Evidence at transcript level": 1344, "No human protein/transcript evidence": 254 }, "rna_tissue_specificity_counts": { "Low tissue specificity": 8096, "Tissue enhanced": 6356, "Tissue enriched": 3132, "Group enriched": 1547, "Not detected": 1031 }, "top_subcellular_main_locations": { "Nucleoplasm": 4897, "Cytosol": 3087, "Vesicles": 1661, "Plasma membrane": 1648, "Mitochondria": 974, "Golgi apparatus": 886, "Nucleoli": 638, "Endoplasmic reticulum": 486, "Nuclear speckles": 412, "Nuclear bodies": 326, "Centrosome": 248, "Microtubules": 237, "Nucleoli fibrillar center": 193, "Nuclear membrane": 193, "Cell Junctions": 192, "Mid piece": 151, "Principal piece": 140, "Primary cilium": 140, "Basal body": 139, "Actin filaments": 138 }, "top_protein_classes": { "Predicted intracellular proteins": 15915, "Predicted membrane proteins": 5573, "Disease related genes": 4906, "Human disease related genes": 4555, "Enzymes": 3777, "Plasma proteins": 3750, "Metabolic proteins": 2882, "Transporters": 2138, "Essential proteins": 2023, "Predicted secreted proteins": 1902, "Potential drug targets": 1757, "Cancer-related genes": 1672, "Transcription factors": 1485, "FDA approved drug targets": 854, "G-protein coupled receptors": 743, "CD markers": 384, "RAS pathway related proteins": 235, "Immunoglobulin genes": 214, "T-cell receptor genes": 196, "Ribosomal proteins": 180 }, "columns": [ "ensembl_id", "gene", "gene_description", "uniprot", "chromosome", "position", "evidence", "hpa_evidence", "uniprot_evidence", "nextprot_evidence", "antibodies", "gene_synonyms", "protein_classes", "biological_processes", "molecular_functions", "disease_involvement", "subcellular_main_locations", "subcellular_additional_locations", "secretome_locations", "secretome_functions", "reliability_if", "reliability_ih", "reliability_mouse_brain", "interactions", "ccd_protein", "ccd_transcript", "blood_expression_cluster", "brain_expression_cluster", "cell_line_expression_cluster", "single_cell_expression_cluster", "tissue_expression_cluster", "rna_tissue_specificity", "rna_tissue_distribution", "rna_tissue_specificity_score", "rna_cell_line_specificity", "rna_cell_line_distribution", "rna_cell_line_specificity_score", "rna_cancer_specificity", "rna_cancer_distribution", "rna_cancer_specificity_score", "rna_single_cell_type_specificity", "rna_single_cell_type_distribution", "rna_single_cell_type_specificity_score", "rna_blood_cell_specificity", "rna_blood_cell_distribution", "rna_blood_cell_specificity_score", "prognostic_cancer_count", "validated_prognostic_cancer_count", "potential_prognostic_cancer_count", "favorable_prognostic_cancers", "unfavorable_prognostic_cancers", "prognostic_cancers", "source_row_index", "split_bucket" ], "metadata_tables": [ "metadata/cancer_prognostics.parquet", "metadata/rna_expression_measurements.parquet" ]}123version https://git-lfs.github.com/spec/v1oid sha256:eb2be087d1c8e9f2af45770e988c5f1caa75f4ef4f87496b229977a913447aadsize 1232620123version https://git-lfs.github.com/spec/v1oid sha256:0aaae1c210442b91464ae97102e9efd10b21c68bd9d70c220562107ecc771f8dsize 872017123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313#!/usr/bin/env python3"""Build viewer-friendly Parquet splits for LiteFold/HumanProteinAtlas."""
from __future__ import annotations
import argparseimport hashlibimport jsonimport reimport shutilfrom collections import Counterfrom pathlib import Pathfrom typing import Any
import pandas as pd
ENTRY_COLUMNS = [ "ensembl_id", "gene", "gene_description", "uniprot", "chromosome", "position", "evidence", "hpa_evidence", "uniprot_evidence", "nextprot_evidence", "antibodies", "gene_synonyms", "protein_classes", "biological_processes", "molecular_functions", "disease_involvement", "subcellular_main_locations", "subcellular_additional_locations", "secretome_locations", "secretome_functions", "reliability_if", "reliability_ih", "reliability_mouse_brain", "interactions", "ccd_protein", "ccd_transcript", "blood_expression_cluster", "brain_expression_cluster", "cell_line_expression_cluster", "single_cell_expression_cluster", "tissue_expression_cluster", "rna_tissue_specificity", "rna_tissue_distribution", "rna_tissue_specificity_score", "rna_cell_line_specificity", "rna_cell_line_distribution", "rna_cell_line_specificity_score", "rna_cancer_specificity", "rna_cancer_distribution", "rna_cancer_specificity_score", "rna_single_cell_type_specificity", "rna_single_cell_type_distribution", "rna_single_cell_type_specificity_score", "rna_blood_cell_specificity", "rna_blood_cell_distribution", "rna_blood_cell_specificity_score", "prognostic_cancer_count", "validated_prognostic_cancer_count", "potential_prognostic_cancer_count", "favorable_prognostic_cancers", "unfavorable_prognostic_cancers", "prognostic_cancers", "source_row_index", "split_bucket",]
PROGNOSIS_COLUMNS = [ "ensembl_id", "gene", "cancer", "source", "is_prognostic", "p_value", "prognostic", "prognostic_type",]
EXPRESSION_COLUMNS = [ "ensembl_id", "gene", "measurement", "sample", "value",]
def stable_bucket(value: str, buckets: int = 10) -> int: digest = hashlib.sha256(value.encode("utf-8")).hexdigest()[:16] return int(digest, 16) % buckets
def as_list(value: Any) -> list[str]: if value is None or value == "NA": return [] if isinstance(value, list): return [str(item) for item in value if item is not None and item != ""] return [str(value)] if value != "" else []
def clean_scalar(value: Any) -> Any: if value in {"NA", ""}: return None return value
def parse_float(value: Any) -> float | None: if value in {None, "", "NA"}: return None try: return float(value) except (TypeError, ValueError): return None
def score(value: Any) -> float | None: return parse_float(value)
def normalize_cancer_name(column: str) -> tuple[str, str]: label = column.removeprefix("Cancer prognostics - ") source = "validation" if "(validation)" in label else "TCGA" if "(TCGA)" in label else "" cancer = re.sub(r"\s*\((TCGA|validation)\)\s*$", "", label).strip() return cancer, source
def entry_row(wrapper: dict[str, Any]) -> tuple[dict[str, Any], list[dict[str, Any]], list[dict[str, Any]]]: row = wrapper["row"] ensembl = row.get("Ensembl") gene = row.get("Gene") prognosis_rows = [] prognostic_cancers = [] validated = 0 potential = 0 favorable = [] unfavorable = []
expression_rows = [] for key, value in row.items(): if key.startswith("Cancer prognostics -") and isinstance(value, dict): cancer, source = normalize_cancer_name(key) is_prognostic = bool(value.get("is_prognostic")) prognostic = value.get("prognostic") or None prognostic_type = value.get("prognostic type") or None if is_prognostic: prognostic_cancers.append(cancer) if prognostic == "validated prognostic": validated += 1 elif prognostic == "potential prognostic": potential += 1 if prognostic_type == "favorable": favorable.append(cancer) elif prognostic_type == "unfavorable": unfavorable.append(cancer) prognosis_rows.append( { "ensembl_id": ensembl, "gene": gene, "cancer": cancer, "source": source, "is_prognostic": is_prognostic, "p_value": parse_float(value.get("p_val")), "prognostic": prognostic, "prognostic_type": prognostic_type, } ) elif key.startswith("RNA ") and isinstance(value, dict): for sample, measurement in value.items(): expression_rows.append( { "ensembl_id": ensembl, "gene": gene, "measurement": key, "sample": sample, "value": parse_float(measurement), } )
entry = { "ensembl_id": ensembl, "gene": gene, "gene_description": row.get("Gene description"), "uniprot": row.get("Uniprot"), "chromosome": row.get("Chromosome"), "position": row.get("Position"), "evidence": row.get("Evidence"), "hpa_evidence": row.get("HPA evidence"), "uniprot_evidence": row.get("UniProt evidence"), "nextprot_evidence": row.get("NeXtProt evidence"), "antibodies": as_list(row.get("Antibody")), "gene_synonyms": as_list(row.get("Gene synonym")), "protein_classes": as_list(row.get("Protein class")), "biological_processes": as_list(row.get("Biological process")), "molecular_functions": as_list(row.get("Molecular function")), "disease_involvement": as_list(row.get("Disease involvement")), "subcellular_main_locations": as_list(row.get("Subcellular main location")), "subcellular_additional_locations": as_list(row.get("Subcellular additional location")), "secretome_locations": as_list(row.get("Secretome location")), "secretome_functions": as_list(row.get("Secretome function")), "reliability_if": clean_scalar(row.get("Reliability (IF)")), "reliability_ih": clean_scalar(row.get("Reliability (IH)")), "reliability_mouse_brain": clean_scalar(row.get("Reliability (Mouse Brain)")), "interactions": row.get("Interactions"), "ccd_protein": clean_scalar(row.get("CCD Protein")), "ccd_transcript": clean_scalar(row.get("CCD Transcript")), "blood_expression_cluster": clean_scalar(row.get("Blood expression cluster")), "brain_expression_cluster": clean_scalar(row.get("Brain expression cluster")), "cell_line_expression_cluster": clean_scalar(row.get("Cell line expression cluster")), "single_cell_expression_cluster": clean_scalar(row.get("Single cell expression cluster")), "tissue_expression_cluster": clean_scalar(row.get("Tissue expression cluster")), "rna_tissue_specificity": clean_scalar(row.get("RNA tissue specificity")), "rna_tissue_distribution": clean_scalar(row.get("RNA tissue distribution")), "rna_tissue_specificity_score": score(row.get("RNA tissue specificity score")), "rna_cell_line_specificity": clean_scalar(row.get("RNA cell line specificity")), "rna_cell_line_distribution": clean_scalar(row.get("RNA cell line distribution")), "rna_cell_line_specificity_score": score(row.get("RNA cell line specificity score")), "rna_cancer_specificity": clean_scalar(row.get("RNA cancer specificity")), "rna_cancer_distribution": clean_scalar(row.get("RNA cancer distribution")), "rna_cancer_specificity_score": score(row.get("RNA cancer specificity score")), "rna_single_cell_type_specificity": clean_scalar(row.get("RNA single cell type specificity")), "rna_single_cell_type_distribution": clean_scalar(row.get("RNA single cell type distribution")), "rna_single_cell_type_specificity_score": score(row.get("RNA single cell type specificity score")), "rna_blood_cell_specificity": clean_scalar(row.get("RNA blood cell specificity")), "rna_blood_cell_distribution": clean_scalar(row.get("RNA blood cell distribution")), "rna_blood_cell_specificity_score": score(row.get("RNA blood cell specificity score")), "prognostic_cancer_count": len(set(prognostic_cancers)), "validated_prognostic_cancer_count": validated, "potential_prognostic_cancer_count": potential, "favorable_prognostic_cancers": sorted(set(favorable)), "unfavorable_prognostic_cancers": sorted(set(unfavorable)), "prognostic_cancers": sorted(set(prognostic_cancers)), "source_row_index": wrapper.get("row_index"), "split_bucket": stable_bucket(str(ensembl or gene or wrapper.get("row_index"))), } return entry, prognosis_rows, expression_rows
def build_dataset(raw_dir: Path, out_dir: Path) -> dict[str, Any]: source = raw_dir / "tables/annotation_human_protein_atlas_proteinatlas.json.gz.jsonl" rows = [] prognosis_rows = [] expression_rows = [] with source.open("r", encoding="utf-8") as handle: for line in handle: wrapper = json.loads(line) entry, prognosis, expression = entry_row(wrapper) rows.append(entry) prognosis_rows.extend(prognosis) expression_rows.extend(expression)
if out_dir.exists(): shutil.rmtree(out_dir) data_dir = out_dir / "data" metadata_dir = out_dir / "metadata" data_dir.mkdir(parents=True, exist_ok=True) metadata_dir.mkdir(parents=True, exist_ok=True)
df = pd.DataFrame.from_records(rows, columns=ENTRY_COLUMNS) train = df[df["split_bucket"].ne(0)].sort_values("ensembl_id", kind="mergesort") test = df[df["split_bucket"].eq(0)].sort_values("ensembl_id", kind="mergesort") train.to_parquet(data_dir / "train-00000-of-00001.parquet", index=False, compression="zstd") test.to_parquet(data_dir / "test-00000-of-00001.parquet", index=False, compression="zstd")
prognosis_df = pd.DataFrame.from_records(prognosis_rows, columns=PROGNOSIS_COLUMNS) prognosis_df.to_parquet(metadata_dir / "cancer_prognostics.parquet", index=False, compression="zstd") expression_df = pd.DataFrame.from_records(expression_rows, columns=EXPRESSION_COLUMNS) expression_df.to_parquet(metadata_dir / "rna_expression_measurements.parquet", index=False, compression="zstd")
evidence_counts = df["evidence"].fillna("missing").value_counts().to_dict() tissue_specificity_counts = df["rna_tissue_specificity"].fillna("missing").value_counts().to_dict() location_counts = Counter(location for values in df["subcellular_main_locations"] for location in values) protein_class_counts = Counter(item for values in df["protein_classes"] for item in values) summary = { "source": "LiteFold/HumanProteinAtlas", "entry_rows": int(len(df)), "cancer_prognostic_rows": int(len(prognosis_df)), "rna_expression_measurement_rows": int(len(expression_df)), "splits": {"train": int(len(train)), "test": int(len(test))}, "split_strategy": "deterministic sha256(ensembl_id) % 10; bucket 0 is test, buckets 1-9 are train", "evidence_counts": {str(k): int(v) for k, v in evidence_counts.items()}, "rna_tissue_specificity_counts": {str(k): int(v) for k, v in tissue_specificity_counts.items()}, "top_subcellular_main_locations": dict(location_counts.most_common(20)), "top_protein_classes": dict(protein_class_counts.most_common(20)), "columns": ENTRY_COLUMNS, "metadata_tables": [ "metadata/cancer_prognostics.parquet", "metadata/rna_expression_measurements.parquet", ], } (out_dir / "dataset_summary.json").write_text(json.dumps(summary, indent=2) + "\n", encoding="utf-8") return summary
def main() -> None: parser = argparse.ArgumentParser() parser.add_argument("--raw-dir", type=Path, default=Path("LiteFold_HumanProteinAtlas_raw")) parser.add_argument("--out-dir", type=Path, default=Path("LiteFold_HumanProteinAtlas_processed")) args = parser.parse_args() summary = build_dataset(args.raw_dir, args.out_dir) print(json.dumps(summary, indent=2))
if __name__ == "__main__": main()README.md+107-56
data/test-00000-of-00001.parquetAdded+3
data/train-00000-of-00001.parquetAdded+3
dataset_summary.jsonAdded+127
metadata/cancer_prognostics.parquetAdded+3
metadata/rna_expression_measurements.parquetAdded+3
scripts/prepare_hpa_dataset.pyAdded+313