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
Show 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: ['C10ORF71', 'C1ORF131', 'C2ORF69', 'THEG', 'SPATA5', 'ANP32C', 'TTC30A', 'C17ORF75', 'RNF165', 'C1ORF112', 'C3ORF33', 'ADGRF2', 'C17ORF97', 'C11ORF80', 'TDGF1', 'C1ORF146', 'C3ORF38', 'C1ORF56', 'PIFO', 'C9ORF78', 'C12ORF29', 'USP41', 'C1ORF109', 'GBAP1', 'C11ORF65', 'C12ORF50', 'C1ORF68', 'C18ORF32', 'C15ORF62', 'C12ORF4', 'C2ORF49', 'FAM172BP', 'SPATA5L1', 'C6ORF15', 'C9ORF72', 'SOGA1', 'C6ORF89', 'C19ORF12', 'TRB', 'FAM172A', 'C20ORF173', 'PDZD3', 'SLC9A3R2', 'C10ORF90', 'C17ORF99', 'DUSP13', 'C8ORF88', 'C1ORF43', 'C21ORF91', 'TTC26', 'HSPB11', 'SLC9A3R1', 'C18ORF25', 'C8ORF17', 'C3ORF70', 'C12ORF57']
please add corresponding Gene records via `.from_values(['AIRIM', 'IFT25', 'C12orf57', 'USP41P', 'C11orf65', 'C15orf62', 'IFT56', 'C12orf50', 'C19orf12', 'C6orf89', 'C8orf17', 'THRB', 'C3orf70', 'AFG2A', 'C12orf4', 'C6orf15', 'SPMAP2', 'AFG2B', 'C21orf91', 'TOP6BL', 'FIRRM', 'C1orf146', 'LIAT1', 'GBA1LP', 'ARB2A', 'C20orf173', 'C1orf43', 'C1orf131', 'ARK2C', 'C2orf69', 'ANP32CP', 'NHERF4', 'C17orf75', 'MTCL2', 'ARK2N', 'NHERF2', 'C9orf72', 'DUSP13B', 'C3orf38', 'IFT70A', 'C17orf99', 'C10orf71', 'C1orf56', 'C2orf49', 'ARB2BP', 'CIMAP3', 'ADGRF2P', 'C9orf78', 'NHERF1', 'RLIG1', 'C10orf90', 'KPLCE', 'C18orf32', 'C8orf88', 'C3orf33', 'CRIPTO'])`
! ambiguous validation in Bionty for 1104 records: 'LTB4R', 'MSL3P1', 'SLC16A1', 'CWC25', 'GREM1', 'ADAM32', 'AGPAT5', 'PEX5', 'WEE2', 'TAS2R42', 'CFHR2', 'PFDN6', 'NSUN5P2', 'RRP7BP', 'BTN2A1', 'OR2J1', 'MED16', 'LST1', 'PTPRK', 'DUSP11', ...
! 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: MTRNR2L11, LOC100653049, AFD1, MTRNR2L3, MTRNR2L7, MTRNR2L10, MTRNR2L12, LOC107984156, LOC102723996, MTRNR2L8, LOC122513141, TRL-AAG2-3, MTRNR2L6, MTRNR2L1, DUX3, SEPTIN14P20, LOC122539214, LOC102724159, CCL4L1, LOC102723475, ...
couldn't validate 38 terms: 'MTRNR2L8', 'MTRNR2L3', 'DGS2', 'MTRNR2L6', 'AZF1', 'CCL3L1', 'LOC102723475', 'LOC122319436', 'DUX3', 'TAS2R33', 'CCL4L1', 'IGL', 'LOC344967', 'MTRNR2L5', 'DUX5', 'LOC100653049', 'MTRNR2L2', 'MTRNR2L1', 'TRL-AAG2-3', 'MTRNR2L11', ...
→ if you are sure, create new records via Gene() and save to your registry
Link pathway to genes¶
Now that we are tracking all pathways and genes records, we can link both of them to make the pathways even more queryable.
symbols_gene_records = {record.symbol: record for record in gene_records}
for pathway_record in pathway_records:
pathway_genes = go_bp_parsed.get(pathway_record.ontology_id)[1]
pathway_genes_records = [symbols_gene_records.get(gene) for gene in pathway_genes]
pathway_record.genes.set(pathway_genes_records)
Now genes are linked to pathways:
pathway_record.genes.list("symbol")
['CAST', 'CARD8', 'CARD18', 'XIAP', 'CST7']
pathway_record.genes.list("ensembl_gene_id")
['ENSG00000153113',
'ENSG00000105483',
'ENSG00000255501',
'ENSG00000101966',
'ENSG00000077984']
Move on to the next analysis: Standardize metadata on-the-fly