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.

Setup

!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
field FieldAttr(Organism.name)
organism None
public_source None

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, 2023-05-10
#terms: 47514

📖 .df(): ontology reference table
🔎 .lookup(): autocompletion of terms
🎯 .search(): free text search of terms
✅ .validate(): strictly validate values
🧐 .inspect(): full inspection of values
👽 .standardize(): convert to standardized names
🪜 .diff(): difference between two versions
🔗 .to_pronto(): Pronto.Ontology object

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
field FieldAttr(Pathway.ontology_id)
organism None
public_source None

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 40 synonyms in Bionty: ['C1ORF146', 'C1ORF109', 'C2ORF69', 'C12ORF4', 'C9ORF72', 'C12ORF29', 'C17ORF97', 'C1ORF131', 'C15ORF62', 'C11ORF65', 'C6ORF15', 'C19ORF12', 'C6ORF89', 'C21ORF91', 'C3ORF70', 'C8ORF88', 'C17ORF75', 'SLC9A3R2', 'C1ORF112', 'C3ORF38', 'C18ORF25', 'C1ORF43', 'HSPB11', 'C11ORF80', 'SLC9A3R1', 'C2ORF49', 'C12ORF50', 'C12ORF57', 'C18ORF32', 'C3ORF33', 'C20ORF173', 'C17ORF99', 'TRB', 'PDZD3', 'C8ORF17', 'C10ORF71', 'C1ORF68', 'C1ORF56', 'C9ORF78', 'C10ORF90']
   please add corresponding Gene records via `.from_values(['C1orf43', 'C9orf72', 'C21orf91', 'C1orf56', 'THRB', 'C11orf65', 'C1orf112', 'NHERF1', 'C18orf32', 'C8orf17', 'C12orf57', 'C12orf29', 'C1orf131', 'C2orf69', 'C3orf38', 'C1orf146', 'C1orf109', 'C3orf33', 'C3orf70', 'C2orf49', 'C17orf99', 'C12orf4', 'C11orf80', 'C17orf75', 'C1orf68', 'C10orf90', 'C9orf78', 'C20orf173', 'C18orf25', 'C12orf50', 'C19orf12', 'C10orf71', 'C6orf89', 'NHERF4', 'C8orf88', 'C17orf97', 'C6orf15', 'C15orf62', 'NHERF2', 'IFT25'])`
field FieldAttr(Gene.symbol)
organism Organism(uid='1dpCL6Td', name='human', ontology_id='NCBITaxon:9606', scientific_name='homo_sapiens', updated_at=2024-05-14 15:58:41 UTC, public_source_id=1, created_by_id=1)
public_source None
❗ ambiguous validation in Bionty for 1082 records: 'ADAMTS12', 'ADAM2', 'HS3ST6', 'PRR4', 'GCSAM', 'NTAN1', 'LRP6', 'MEF2D', 'GAA', 'GTF2H1', 'MAML1', 'MICB', 'CD300C', 'FBXO17', 'OR2I1P', 'SMN1', 'ZG16B', 'OR2B3', 'DOC2B', 'PCDHB3'
did not create Gene records for 37 non-validated symbols: 'AFD1', 'AZF1', 'CCL4L1', 'DGS2', 'DUX3', 'DUX5', 'FOXL3-OT1', 'IGL', 'LOC100653049', 'LOC102723475', 'LOC102723996', 'LOC102724159', 'LOC107984156', 'LOC112268384', 'LOC122319436', 'LOC122513141', 'LOC122539214', 'LOC344967', 'MDRV', 'MTRNR2L1'

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
37 terms (0.30%) are not validated for symbol: MTRNR2L3, LOC102724159, FOXL3-OT1, MTRNR2L7, DUX3, LOC102723996, MTRNR2L5, LOC102723475, LOC112268384, DGS2, TRL-AAG2-3, MTRNR2L9, MTRNR2L2, LOC344967, LOC107984156, LOC122513141, DUX5, MTRNR2L10, MTRNR2L8, MTRNR2L11, ...
   couldn't validate 37 terms: 'LOC122319436', 'TRL-AAG2-3', 'MTRNR2L2', 'MDRV', 'LOC102723475', 'MTRNR2L11', 'AFD1', 'MTRNR2L3', 'LOC100653049', 'MTRNR2L6', 'CCL4L1', 'LOC122539214', 'LOC344967', 'TAS2R36', 'LOC102724159', 'LOC122513141', 'FOXL3-OT1', 'DUX5', 'DUX3', 'MTRNR2L9'
→  if you are sure, create new records via ln.Gene() and save to your registry