History of ogbn_proteins
The changes to the source code of this entry in the repository, newest first, each with the differences it made to the entry's files. They are also listed on GitLab.
[entries] New entry: ogbn_proteins e4e401a
diff --git a/entries/ogbn_proteins/__init__.py b/entries/ogbn_proteins/__init__.py
new file mode 100644
index 0000000..1a2a0e2
--- /dev/null
+++ b/entries/ogbn_proteins/__init__.py
@@ -0,0 +1,103 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2026 Tiago de Paula Peixoto <tiago@skewed.de>
+#
+# This program is free software: you can redistribute it and/or modify it under
+# the terms of the GNU Affero General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option) any
+# later version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Affero General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+
+import pandas
+
+from .. import *
+
+title = "Protein associations of 8 species (ogbn-proteins, 2020)"
+description = """An undirected network of functional associations between the proteins of eight species, from the `ogbn-proteins` dataset of the Open Graph Benchmark (OGB), a benchmark for node classification (version 1, of May 2020). The proteins and associations come from the STRING database (version 11): an edge means that two proteins are functionally associated, and has as features the scores of eight kinds of evidence for the association. The species are *Escherichia coli* (taxonomy identifier 511145), *Arabidopsis thaliana* (3702), *Saccharomyces cerevisiae* (4932), *Caenorhabditis elegans* (6239), *Drosophila melanogaster* (7227), *Danio rerio* (7955), *Homo sapiens* (9606) and *Mus musculus* (10090); the networks of all the species of STRING are in the entry `string_all`.
+
+The task of the benchmark is to predict the presence of 112 protein functions (terms of the Gene Ontology), given as binary labels of the nodes. The nodes are split by species: the proteins of one species are used for validation, those of another for testing, and the rest for training.
+
+The network has the following properties:
+
+- `protein_id`: the identifier of the protein in STRING, e.g. `9606.ENSP00000000233` (the NCBI taxonomy identifier of the species, followed by the identifier of the protein).
+- `species`: the NCBI taxonomy identifier of the species of the protein.
+- `labels`: the 112 binary labels of the protein (1 if the protein has the function, 0 otherwise), in the order of the graph property `label_go_terms`.
+- `split`: the part of the benchmark the protein belongs to: `train`, `valid` or `test`.
+- Edge `homology`, `neighborhood`, `fusion`, `cooccurence`, `coexpression`, `experimental`, `database`, `textmining`: the scores of the eight kinds of evidence for the association (between 0 and 1; 0 if there is no evidence of that kind), as in STRING: homology, conserved genomic neighborhood, gene fusions, phylogenetic co-occurrence, co-expression, experiments, curated databases and text mining (as named by STRING, with its spelling of `cooccurence`).
+- `label_go_terms` (graph): the Gene Ontology term of each label, e.g. `GO:0003674`."""
+tags = ['Biological', 'Protein interactions', 'Weighted', 'Metadata']
+url = ['https://ogb.stanford.edu/docs/nodeprop/#ogbn-proteins',
+ 'https://snap.stanford.edu/ogb/data/']
+citation = [('W. Hu, M. Fey, M. Zitnik, Y. Dong, H. Ren, B. Liu, M. Catasta, J. Leskovec, "Open Graph Benchmark: Datasets for Machine Learning on Graphs." Advances in Neural Information Processing Systems 33, 22118-22133 (2020)', 'https://doi.org/10.48550/arXiv.2005.00687'),
+ ('D. Szklarczyk et al., "STRING v11: protein-protein association networks with increased coverage, supporting functional discovery in genome-wide experimental datasets." Nucleic Acids Research 47, D607-D613 (2019)', 'https://doi.org/10.1093/nar/gky1131')]
+icon_hash = None
+upstream_license = ('CC0 1.0', 'https://creativecommons.org/publicdomain/zero/1.0/')
+upstream_prefix = 'https://snap.stanford.edu/ogb/data'
+z = 'nodeproppred/proteins.zip:proteins'
+files = [((f'{z}/raw/edge.csv.gz', f'{z}/raw/edge-feat.csv.gz',
+ f'{z}/raw/node_species.csv.gz', f'{z}/raw/node-label.csv.gz',
+ f'{z}/mapping/nodeidx2proteinid.csv.gz',
+ f'{z}/mapping/labelidx2GO.csv.gz',
+ f'{z}/split/species/train.csv.gz', f'{z}/split/species/valid.csv.gz',
+ f'{z}/split/species/test.csv.gz'),
+ None, None)]
+
+def fetch_upstream(force=False):
+ return fetch_upstream_files(__name__.split(".")[-1], upstream_prefix, files,
+ force)
+
+def read_csv_gz(name, fname, header=None, dtype="int64"):
+ "The gzipped CSV member `fname`, as an array."
+ with open_upstream_file(name, fname, "rb") as f:
+ return pandas.read_csv(f, compression="gzip", header=header,
+ dtype=dtype).values
+
+@cache_network()
+@coerce_props()
+@annotate()
+def parse(alts=None):
+ global files
+ name = __name__.split(".")[-1]
+ for fnames, alt, fmt in files:
+ if alts is not None and alt not in alts:
+ continue
+ ids = read_csv_gz(name, fnames[4], header=0, dtype=str)
+ N = len(ids)
+ assert (ids[:, 0].astype("int64") == numpy.arange(N)).all()
+ g = Graph(directed=False)
+ g.add_vertex(N)
+ g.vp.protein_id = g.new_vp("string", vals=ids[:, 1])
+ del ids
+ species = read_csv_gz(name, fnames[2])[:, 0]
+ assert len(species) == N
+ g.vp.species = g.new_vp("int64_t", vals=species)
+ labels = read_csv_gz(name, fnames[3], dtype="int16")
+ assert labels.shape == (N, 112)
+ g.vp.labels = g.new_vp("vector<int16_t>")
+ g.vp.labels.set_2d_array(labels.T)
+ go = read_csv_gz(name, fnames[5], header=0, dtype=str)
+ assert (go[:, 0].astype("int64") == numpy.arange(112)).all()
+ g.gp.label_go_terms = g.new_gp("vector<string>", val=list(go[:, 1]))
+ split = numpy.full(N, "", dtype=object)
+ for f, s in zip(fnames[6:9], ("train", "valid", "test")):
+ split[read_csv_gz(name, f)[:, 0]] = s
+ assert (split != "").all()
+ g.vp.split = g.new_vp("string", vals=list(split))
+ edges = read_csv_gz(name, fnames[0])
+ g.add_edge_list(edges)
+ del edges
+ feat = read_csv_gz(name, fnames[1], dtype="float64")
+ assert feat.shape == (g.num_edges(), 8)
+ for i, k in enumerate(["homology", "neighborhood", "fusion", "cooccurence",
+ "coexpression", "experimental", "database",
+ "textmining"]):
+ g.ep[k] = g.new_ep("double", vals=feat[:, i])
+ yield alt, g