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
2024-04-10 17:49:28,838:INFO - Failed to extract font properties from /usr/share/fonts/truetype/noto/NotoColorEmoji.ttf: In FT2Font: Can not load face (unknown file format; error code 0x2)
2024-04-10 17:49:28,946:INFO - generated new fontManager

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)}")
2024-04-10 17:49:29,994:INFO - Downloading and generating Enrichr library gene sets...
2024-04-10 17:49:35,006:INFO - 0001 gene_sets have been filtered out when max_size=2000 and min_size=0
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")
    """
    id = key.split(" ")[-1].replace("(", "").replace(")", "")
    name = key.replace(f" ({id})", "")
    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
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

Register gene symbols#

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

all_genes = {g for genes in go_bp.values() for g in genes}
gene_records = bt.Gene.from_values(all_genes, bt.Gene.symbol)
Hide code cell output
❗ ambiguous validation in Bionty for 1082 records: 'KRT12', 'OR6B1', 'MYO19', 'GTF2H4', 'BMERB1', 'HLA-DMA', 'NPBWR2', 'DEFB4A', 'MAGEA3', 'DLGAP2', 'SURF4', 'NOL8', 'PRAMEF9', 'OR2J2', 'MYT1', 'UBTFL6', 'GNL1', 'CABIN1', 'KLF13', 'SCRT1', ...
❗ 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', ...
gene_records[:3]
[Private registry
 Entity: Gene
 πŸ“– .df(): 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,
 Private registry
 Entity: Gene
 πŸ“– .df(): 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,
 Private registry
 Entity: Gene
 πŸ“– .df(): 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]
ln.save(gene_records);