Jupyter Notebook

Gene Ontology (GO)

Pathways represent interconnected molecular networks of signaling cascades that govern critical cellular processes. They provide understandings cellular behavior mechanisms, insights of disease progression and treatment responses. In an R&D organization, managing pathways across different datasets are crucial for gaining insights of potential therapeutic targets and intervention strategies.

In this notebook we manage a pathway registry based on “2023 GO Biological Process” ontology. We’ll walk you through the steps of registering pathways and link them to genes.

In the following Standardize metadata on-the-fly notebook, we’ll demonstrate how to perform a pathway enrichment analysis and track the dataset with LaminDB.

# !pip install 'lamindb[jupyter,bionty]'
!lamin init --storage ./use-cases-registries --modules bionty
Hide code cell output
 initialized lamindb: testuser1/use-cases-registries
import lamindb as ln
import bionty as bt
import gseapy as gp

bt.settings.organism = "human"  # globally set organism
 connected lamindb: testuser1/use-cases-registries

Fetch GO pathways annotated with human genes using Enrichr

First we fetch the “GO_Biological_Process_2023” pathways for humans using GSEApy which wraps GSEA and Enrichr.

go_bp = gp.get_library(name="GO_Biological_Process_2023", organism="Human")
print(f"Number of pathways {len(go_bp)}")
Number of pathways 5406
go_bp["ATF6-mediated Unfolded Protein Response (GO:0036500)"]
['MBTPS1', 'MBTPS2', 'XBP1', 'ATF6B', 'DDIT3', 'CREBZF']

Parse out the ontology_id from keys, convert into the format of {ontology_id: (name, genes)}

def parse_ontology_id_from_keys(key):
    """Parse out the ontology id.

    "ATF6-mediated Unfolded Protein Response (GO:0036500)" -> ("GO:0036500", "ATF6-mediated Unfolded Protein Response")
    """
    name, id = key.rsplit(" (", 1)
    id = id.rstrip(")")
    return id, name
go_bp_parsed = {}

for key, genes in go_bp.items():
    id, name = parse_ontology_id_from_keys(key)
    go_bp_parsed[id] = (name, genes)
go_bp_parsed["GO:0036500"]
('ATF6-mediated Unfolded Protein Response',
 ['MBTPS1', 'MBTPS2', 'XBP1', 'ATF6B', 'DDIT3', 'CREBZF'])

Register pathway ontology in LaminDB

bionty = bt.Pathway.public()
bionty
Hide code cell output
PublicOntology
Entity: Pathway
Organism: all
Source: go, 2024-06-17
#terms: 47856

Next, we register all the pathways and genes in LaminDB to finally link pathways to genes.

Register pathway terms

To register the pathways we make use of .from_values to directly parse the annotated GO pathway ontology IDs into LaminDB.

pathway_records = bt.Pathway.from_values(go_bp_parsed.keys(), bt.Pathway.ontology_id)
ln.save(pathway_records)

Register gene symbols

Similarly, we use .from_values for all Pathway associated genes to register them with LaminDB.

all_genes = bt.Gene.standardize(list({g for genes in go_bp.values() for g in genes}))
gene_records = bt.Gene.from_values(all_genes, bt.Gene.symbol)
ln.save(gene_records);
! using default organism = human
! found 56 synonyms in public source (output truncated): [np.str_('C1ORF146'), np.str_('C21ORF91'), np.str_('C9ORF78'), np.str_('C8ORF88'), np.str_('PIFO'), np.str_('C11ORF65'), np.str_('C12ORF57'), np.str_('C11ORF80'), np.str_('C12ORF50'), np.str_('DUSP13'), '...']
  please add corresponding Gene records via (output truncated): `.from_values([np.str_('C1ORF146'), np.str_('C21ORF91'), np.str_('C9ORF78'), np.str_('C8ORF88'), np.str_('PIFO'), np.str_('C11ORF65'), np.str_('C12ORF57'), np.str_('C11ORF80'), np.str_('C12ORF50'), np.str_('DUSP13'), '...'])`
! using default organism = human
! ambiguous validation in Bionty for 1104 records: 'HMOX2', 'NPEPPSP1', 'TUBGCP3', 'AKT3', 'ZNF436', 'USP17L1', 'TRPV5', 'HLA-A', 'PROM2', 'CLDN7', 'KRT20', 'GLIS2', 'DTX2', 'STK19', 'HLA-DRB4', 'CACNA2D4', 'OR2J1', 'TRIM39', 'TRIM27', 'ELP5', ...

Manually register the 37 non-validated symbols:

inspect_result = bt.Gene.inspect(all_genes, bt.Gene.symbol)

nonval_genes = []
for g in inspect_result.non_validated:
    nonval_genes.append(bt.Gene(symbol=g))

ln.save(nonval_genes)
! using default organism = human
! received 14696 unique terms, 1 empty/duplicated term is ignored
! 38 unique terms (0.30%) are not validated for symbol: 'MTRNR2L10', 'MTRNR2L11', 'MTRNR2L7', 'MTRNR2L1', 'MDRV', 'FOXL3-OT1', 'MTRNR2L9', 'LOC102724159', 'TAS2R33', 'TRA', ...
   couldn't validate 38 terms: 'MTRNR2L8', 'IGL', 'LOC102723996', 'LOC100653049', 'MTRNR2L9', 'MTRNR2L11', 'AFD1', 'DUX5', 'SEPTIN14P20', 'LOC122539214', 'TAS2R36', 'AZF1', 'MTRNR2L2', 'CCL4L1', 'MTRNR2L1', 'MTRNR2L5', 'MTRNR2L12', 'FOXL3-OT1', 'LOC122319436', 'MTRNR2L4', ...
→  if you are sure, create new records via Gene() and save to your registry
! records with similar symbols exist! did you mean to load one of them?
uid symbol stable_id ensembl_gene_id ncbi_gene_ids biotype synonyms description space_id source_id organism_id run_id created_at created_by_id _aux _branch_code
id
432 6Z6z8R4PcrGz TAS2R10 None ENSG00000121318 50839 protein_coding TRB2|T2R10 taste 2 receptor member 10 1 11 1 None 2025-05-13 19:58:18.468000+00:00 1 None 1
433 1zmsbmO5GP3c TAS2R10 None ENSG00000272805 50839 protein_coding TRB2|T2R10 taste 2 receptor member 10 1 11 1 None 2025-05-13 19:58:18.468000+00:00 1 None 1
434 15HmvU09gHq8 TAS2R10 None ENSG00000277238 50839 protein_coding TRB2|T2R10 taste 2 receptor member 10 1 11 1 None 2025-05-13 19:58:18.468000+00:00 1 None 1
! records with similar symbols exist! did you mean to load one of them?
uid symbol stable_id ensembl_gene_id ncbi_gene_ids biotype synonyms description space_id source_id organism_id run_id created_at created_by_id _aux _branch_code
id
249 2x4BOvYyEkiA TRAF3IP2 None ENSG00000056972 10758 protein_coding C6ORF4|DKFZP586G0522|C6ORF2|C6ORF6|ACT1|CIKS|C... TRAF3 interacting protein 2 1 11 1 None 2025-05-13 19:58:18.454000+00:00 1 None 1
968 3x68eWb86MNq TRAPPC6A None ENSG00000007255 79090 protein_coding HSPC289|MGC2650|TRS33 trafficking protein particle complex subunit 6A 1 11 1 None 2025-05-13 19:58:18.510000+00:00 1 None 1
1036 312BVdvNhQc8 TRAF6 None ENSG00000175104 7189 protein_coding RNF85 TNF receptor associated factor 6 1 11 1 None 2025-05-13 19:58:18.514000+00:00 1 None 1
! record with similar symbol exists! did you mean to load it?
uid symbol stable_id ensembl_gene_id ncbi_gene_ids biotype synonyms description space_id source_id organism_id run_id created_at created_by_id _aux _branch_code
id
12082 2Z2LBAj16utl TRAFD1 None ENSG00000135148 10906 protein_coding FLN29 TRAF-type zinc finger domain containing 1 1 11 1 None 2025-05-13 19:58:19.872000+00:00 1 None 1
! record with similar symbol exists! did you mean to load it?
uid symbol stable_id ensembl_gene_id ncbi_gene_ids biotype synonyms description space_id source_id organism_id run_id created_at created_by_id _aux _branch_code
id
3067 217N4Hgazwqu JAZF1 None ENSG00000153814 221895 protein_coding TIP27|ZNF802|DKFZP761K2222 JAZF zinc finger 1 1 11 1 None 2025-05-13 19:58:18.682000+00:00 1 None 1
! records with similar symbols exist! did you mean to load one of them?
uid symbol stable_id ensembl_gene_id ncbi_gene_ids biotype synonyms description space_id source_id organism_id run_id created_at created_by_id _aux _branch_code
id
10324 TfqHfw8FjZxq CCL4 None ENSG00000275302 6351 protein_coding MIP-1-BETA|SCYA4|AT744.1|LAG1|ACT-2 C-C motif chemokine ligand 4 1 11 1 None 2025-05-13 19:58:19.509000+00:00 1 None 1
10325 2MLaX8EEZ9sQ CCL4 None ENSG00000275824 6351 protein_coding MIP-1-BETA|SCYA4|AT744.1|LAG1|ACT-2 C-C motif chemokine ligand 4 1 11 1 None 2025-05-13 19:58:19.515000+00:00 1 None 1
10326 7P74Aze5sMxb CCL4 None ENSG00000277943 6351 protein_coding MIP-1-BETA|SCYA4|AT744.1|LAG1|ACT-2 C-C motif chemokine ligand 4 1 11 1 None 2025-05-13 19:58:19.515000+00:00 1 None 1
! records with similar symbols exist! did you mean to load one of them?
uid symbol stable_id ensembl_gene_id ncbi_gene_ids biotype synonyms description space_id source_id organism_id run_id created_at created_by_id _aux _branch_code
id
7005 F36vWNagki41 CCL3 None ENSG00000274221 6348 protein_coding LD78|G0S19-1|SCYA3|LD78ALPHA|SCI|MIP-1-ALPHA C-C motif chemokine ligand 3 1 11 1 None 2025-05-13 19:58:19.218000+00:00 1 None 1
7006 EBoWJxh70guC CCL3 None ENSG00000277632 6348 protein_coding LD78|G0S19-1|SCYA3|LD78ALPHA|SCI|MIP-1-ALPHA C-C motif chemokine ligand 3 1 11 1 None 2025-05-13 19:58:19.218000+00:00 1 None 1
7007 6XmKAksx3Nn4 CCL3 None ENSG00000278567 6348 protein_coding LD78|G0S19-1|SCYA3|LD78ALPHA|SCI|MIP-1-ALPHA C-C motif chemokine ligand 3 1 11 1 None 2025-05-13 19:58:19.218000+00:00 1 None 1
! record with similar symbol exists! did you mean to load it?
uid symbol stable_id ensembl_gene_id ncbi_gene_ids biotype synonyms description space_id source_id organism_id run_id created_at created_by_id _aux _branch_code
id
7446 19ZTVOfazMYF SEPTIN14 None ENSG00000154997 346288 protein_coding SEPT14|FLJ44060 septin 14 1 11 1 None 2025-05-13 19:58:19.259000+00:00 1 None 1
! records with similar symbols exist! did you mean to load one of them?
uid symbol stable_id ensembl_gene_id ncbi_gene_ids biotype synonyms description space_id source_id organism_id run_id created_at created_by_id _aux _branch_code
id
432 6Z6z8R4PcrGz TAS2R10 None ENSG00000121318 50839 protein_coding TRB2|T2R10 taste 2 receptor member 10 1 11 1 None 2025-05-13 19:58:18.468000+00:00 1 None 1
433 1zmsbmO5GP3c TAS2R10 None ENSG00000272805 50839 protein_coding TRB2|T2R10 taste 2 receptor member 10 1 11 1 None 2025-05-13 19:58:18.468000+00:00 1 None 1
434 15HmvU09gHq8 TAS2R10 None ENSG00000277238 50839 protein_coding TRB2|T2R10 taste 2 receptor member 10 1 11 1 None 2025-05-13 19:58:18.468000+00:00 1 None 1
! records with similar symbols exist! did you mean to load one of them?
uid symbol stable_id ensembl_gene_id ncbi_gene_ids biotype synonyms description space_id source_id organism_id run_id created_at created_by_id _aux _branch_code
id
287 7TBpxi4zzmMB IGLC3 None ENSG00000211679 IG_C_gene IGLC immunoglobulin lambda constant 3 (Kern-Oz+ mar... 1 11 1 None 2025-05-13 19:58:18.454000+00:00 1 None 1
5964 10LbfkUokHgx IGLC1 None ENSG00000211675 IG_C_gene IGLC immunoglobulin lambda constant 1 1 11 1 None 2025-05-13 19:58:19.128000+00:00 1 None 1
9872 2qFUCnrrxPlc IGLC7 None ENSG00000211685 IG_C_gene immunoglobulin lambda constant 7 1 11 1 None 2025-05-13 19:58:19.473000+00:00 1 None 1