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.


!lamin init --storage ./use-cases-registries --schema bionty
Hide code cell output
💡 connected 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)
('ATF6-mediated Unfolded Protein Response',
 ['MBTPS1', 'MBTPS2', 'XBP1', 'ATF6B', 'DDIT3', 'CREBZF'])

Register pathway ontology in LaminDB

bionty = bt.Pathway.public()
Hide code cell output
Entity: Pathway
Organism: all
Source: go, 2023-05-10
#terms: 47514

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, parents=False)  # not recursing through parents

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)
❗ found 56 synonyms in Bionty: ['C8ORF17', 'C12ORF29', 'C1ORF146', 'C12ORF4', 'DUSP13', 'C18ORF32', 'FAM172A', 'C2ORF49', 'C12ORF50', 'PIFO', 'C3ORF38', 'C19ORF12', 'C21ORF91', 'SPATA5L1', 'C11ORF65', 'C2ORF69', 'HSPB11', 'C15ORF62', 'C1ORF68', 'USP41', 'C3ORF70', 'C1ORF109', 'C17ORF97', 'TDGF1', 'C10ORF71', 'SPATA5', 'C8ORF88', 'C18ORF25', 'TTC30A', 'SLC9A3R2', 'C12ORF57', 'C6ORF15', 'C1ORF112', 'C11ORF80', 'PDZD3', 'SOGA1', 'SLC9A3R1', 'C6ORF89', 'RNF165', 'C3ORF33', 'THEG', 'FAM172BP', 'ADGRF2', 'C9ORF78', 'TRB', 'C10ORF90', 'C1ORF43', 'C9ORF72', 'C1ORF56', 'C1ORF131', 'C17ORF99', 'TTC26', 'GBAP1', 'C17ORF75', 'ANP32C', 'C20ORF173']
   please add corresponding Gene records via `.from_values(['C2orf69', 'C6orf89', 'FIRRM', 'C2orf49', 'NHERF4', 'ARB2BP', 'ARB2A', 'THRB', 'C6orf15', 'IFT25', 'LIAT1', 'C17orf75', 'C3orf38', 'C9orf72', 'IFT70A', 'C8orf88', 'C10orf90', 'KPLCE', 'C3orf70', 'AIRIM', 'CRIPTO', 'NHERF2', 'MTCL2', 'C9orf78', 'C1orf43', 'AFG2B', 'C19orf12', 'TOP6BL', 'C8orf17', 'C21orf91', 'IFT56', 'C1orf131', 'C18orf32', 'ANP32CP', 'SPMAP2', 'C12orf57', 'NHERF1', 'CIMAP3', 'ARK2N', 'C1orf146', 'GBA1LP', 'C12orf4', 'ADGRF2P', 'USP41P', 'C10orf71', 'C15orf62', 'C3orf33', 'RLIG1', 'C20orf173', 'AFG2A', 'ARK2C', 'C12orf50', 'C1orf56', 'C17orf99', 'C11orf65', 'DUSP13B'])`
❗ ambiguous validation in Bionty for 1104 records: 'KIF5C', 'MUC6', 'GOLGA8M', 'NCR3', 'RABGGTA', 'OR2T34', 'OR2T3', 'OR2T11', 'GUCY1B2', 'LGALS9C', 'AGK', 'PSME1', 'NTAN1', 'OR2T4', 'NDUFA6', 'MSL3P1', 'RPS9', 'PFDN5', 'SLC25A24', 'ARHGAP11A', ...
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:

❗ received 14696 unique terms, 1 empty/duplicated term is ignored
38 terms (0.30%) are not validated for symbol: AFD1, DUX5, MTRNR2L4, LOC344967, TAS2R36, LOC107984156, TAS2R33, MTRNR2L1, LOC112268384, LOC122539214, MTRNR2L11, LOC102724159, MTRNR2L5, MTRNR2L8, TRL-AAG2-3, MTRNR2L2, MTRNR2L13, FOXL3-OT1, MTRNR2L10, MTRNR2L9, ...
   couldn't validate 38 terms: 'MTRNR2L9', 'MTRNR2L10', 'MTRNR2L12', 'MTRNR2L5', 'MTRNR2L8', 'LOC122539214', 'CCL4L1', 'TRL-AAG2-3', 'SEPTIN14P20', 'DUX3', 'LOC107984156', 'LOC122319436', 'MTRNR2L13', 'MTRNR2L6', 'IGL', 'AZF1', 'TRA', 'LOC102723475', 'AFD1', 'FOXL3-OT1', ...
→  if you are sure, create new records via ln.Gene() and save to your registry