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 --schema bionty
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);
! found 56 synonyms in Bionty: ['ADGRF2', 'C12ORF4', 'SOGA1', 'DUSP13', 'C2ORF49', 'TDGF1', 'PIFO', 'RNF165', 'C12ORF57', 'C18ORF25', 'C10ORF90', 'GBAP1', 'C1ORF112', 'C17ORF97', 'FAM172A', 'C1ORF109', 'C12ORF50', 'C1ORF131', 'C9ORF78', 'SPATA5', 'C6ORF15', 'C17ORF75', 'C21ORF91', 'SLC9A3R1', 'USP41', 'C6ORF89', 'C9ORF72', 'C11ORF65', 'PDZD3', 'C8ORF17', 'C2ORF69', 'C3ORF33', 'TTC30A', 'C11ORF80', 'C12ORF29', 'C8ORF88', 'TTC26', 'ANP32C', 'C3ORF38', 'C3ORF70', 'C20ORF173', 'FAM172BP', 'TRB', 'HSPB11', 'SPATA5L1', 'C1ORF68', 'C1ORF56', 'C1ORF146', 'C1ORF43', 'SLC9A3R2', 'C15ORF62', 'C18ORF32', 'C17ORF99', 'C10ORF71', 'THEG', 'C19ORF12']
   please add corresponding Gene records via `.from_values(['AFG2B', 'C3orf70', 'GBA1LP', 'ANP32CP', 'ADGRF2P', 'AFG2A', 'MTCL2', 'C2orf49', 'C11orf65', 'C15orf62', 'C1orf56', 'RLIG1', 'C18orf32', 'ARK2C', 'ARK2N', 'C9orf78', 'C3orf38', 'C17orf99', 'NHERF4', 'ARB2BP', 'ARB2A', 'C9orf72', 'AIRIM', 'IFT70A', 'C21orf91', 'NHERF2', 'CIMAP3', 'C8orf88', 'DUSP13B', 'C1orf43', 'C6orf89', 'C17orf75', 'C12orf57', 'C10orf90', 'C12orf4', 'C3orf33', 'C1orf131', 'USP41P', 'C19orf12', 'IFT56', 'C10orf71', 'CRIPTO', 'LIAT1', 'FIRRM', 'C2orf69', 'C6orf15', 'IFT25', 'SPMAP2', 'NHERF1', 'C8orf17', 'TOP6BL', 'KPLCE', 'C20orf173', 'C1orf146', 'C12orf50', 'THRB'])`
! ambiguous validation in Bionty for 1104 records: 'SESN2', 'HSPA1B', 'DEFB4A', 'ZNF66', 'SLC2A11', 'ECSCR', 'ZBTB9', 'DUSP11', 'SPC25', 'CYP11A1', 'CTAGE1', 'IL3RA', 'CHORDC1', 'PADI4', 'TLCD2', 'STATH', 'PAK1IP1', 'RYBP', 'CNOT3', 'TAS2R41', ...
! did not create Gene records for 38 non-validated symbols: 'AFD1', 'AZF1', 'CCL3L1', 'CCL4L1', 'DGS2', 'DUX3', 'DUX5', 'FOXL3-OT1', 'IGL', 'LOC100653049', 'LOC102723475', 'LOC102723996', 'LOC102724159', 'LOC107984156', 'LOC112268384', 'LOC122319436', 'LOC122513141', 'LOC122539214', 'LOC344967', 'MDRV', ...

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)
! received 14696 unique terms, 1 empty/duplicated term is ignored
! 38 terms (0.30%) are not validated for symbol: TAS2R33, LOC344967, LOC122319436, MTRNR2L10, SEPTIN14P20, MTRNR2L11, LOC112268384, MTRNR2L7, MDRV, LOC122513141, MTRNR2L2, MTRNR2L5, AZF1, MTRNR2L8, LOC102724159, CCL4L1, AFD1, TRL-AAG2-3, MTRNR2L3, DGS2, ...
   couldn't validate 38 terms: 'DGS2', 'AFD1', 'MTRNR2L4', 'MTRNR2L11', 'LOC102724159', 'IGL', 'LOC344967', 'MTRNR2L5', 'DUX5', 'MTRNR2L7', 'LOC102723996', 'LOC102723475', 'TRL-AAG2-3', 'MTRNR2L6', 'SEPTIN14P20', 'MTRNR2L9', 'LOC122513141', 'LOC122319436', 'TAS2R33', 'CCL4L1', ...
→  if you are sure, create new records via Gene() and save to your registry