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
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)
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 (output truncated): [np.str_('C10ORF71'), np.str_('C2ORF69'), np.str_('C17ORF97'), np.str_('USP41'), np.str_('ADGRF2'), np.str_('SOGA1'), np.str_('C1ORF112'), np.str_('C9ORF78'), np.str_('SPATA5L1'), np.str_('FAM172A'), '...']
  please add corresponding Gene records via (output truncated): `.from_values([np.str_('C10ORF71'), np.str_('C2ORF69'), np.str_('C17ORF97'), np.str_('USP41'), np.str_('ADGRF2'), np.str_('SOGA1'), np.str_('C1ORF112'), np.str_('C9ORF78'), np.str_('SPATA5L1'), np.str_('FAM172A'), '...'])`
! ambiguous validation in Bionty for 1104 records: 'SLC12A7', 'PHF1', 'TAS2R31', 'MEGF11', 'MLXIP', 'NOC4L', 'PPIAL4F', 'CES1P1', 'IGHA1', 'CRHR1', 'CDHR5', 'KRT12', 'FBXL6', 'LILRA3', 'PLSCR3', 'ASMT', 'BTG3', 'TAS2R60', 'PYCR3', 'RPS3A', ...
! 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 unique terms (0.30%) are not validated for symbol: 'MTRNR2L9', 'LOC122319436', 'MDRV', 'TRL-AAG2-3', 'LOC112268384', 'AZF1', 'MTRNR2L8', 'TRA', 'LOC102723475', 'MTRNR2L1', ...
   couldn't validate 38 terms: 'LOC122539214', 'FOXL3-OT1', 'MTRNR2L13', 'MDRV', 'MTRNR2L10', 'TAS2R33', 'LOC102723475', 'MTRNR2L11', 'DUX5', 'AZF1', 'DGS2', 'MTRNR2L9', 'MTRNR2L8', 'LOC107984156', 'CCL3L1', 'LOC102723996', 'LOC112268384', 'CCL4L1', 'IGL', 'TAS2R36', ...
→  if you are sure, create new records via Gene() and save to your registry
! record with similar symbol exists! did you mean to load it?
uid symbol stable_id ensembl_gene_id ncbi_gene_ids biotype synonyms description source_id organism_id run_id created_at created_by_id
id
6365 217N4Hgazwqu JAZF1 None ENSG00000153814 221895 protein_coding TIP27|ZNF802|DKFZP761K2222 JAZF zinc finger 1 11 1 None 2024-12-20 15:05:02.945537+00:00 1
! records with similar symbols exist! did you mean to load one of them?
uid symbol stable_id ensembl_gene_id ncbi_gene_ids biotype synonyms description source_id organism_id run_id created_at created_by_id
id
300 4aXWpkO7oC2T TRAPPC8 None ENSG00000153339 22878 protein_coding GSG1|KIAA1012|HST2706|TRS85 trafficking protein particle complex subunit 8 11 1 None 2024-12-20 15:05:02.655671+00:00 1
455 OH1EkHtdQLRz TRAPPC10 None ENSG00000160218 7109 protein_coding TMEM1|EHOC-1|TRS130 trafficking protein particle complex subunit 10 11 1 None 2024-12-20 15:05:02.662288+00:00 1
1169 2xRvI0Oh2TCT TRA2A None ENSG00000164548 29896 protein_coding HTRA-2-ALPHA|AWMS1 transformer 2 alpha homolog 11 1 None 2024-12-20 15:05:02.694737+00:00 1
! records with similar symbols exist! did you mean to load one of them?
uid symbol stable_id ensembl_gene_id ncbi_gene_ids biotype synonyms description source_id organism_id run_id created_at created_by_id
id
13 4oEC1FHbExIX TAS2R31 None ENSG00000256436 259290 protein_coding TAS2R44|T2R31|T2R53 taste 2 receptor member 31 11 1 None 2024-12-20 15:05:02.640496+00:00 1
14 4e6Rg8UcUnf5 TAS2R31 None ENSG00000263097 259290 protein_coding TAS2R44|T2R31|T2R53 taste 2 receptor member 31 11 1 None 2024-12-20 15:05:02.640522+00:00 1
15 1ELqD18jbeeq TAS2R31 None ENSG00000282256 259290 protein_coding TAS2R44|T2R31|T2R53 taste 2 receptor member 31 11 1 None 2024-12-20 15:05:02.640550+00:00 1
! record with similar symbol exists! did you mean to load it?
uid symbol stable_id ensembl_gene_id ncbi_gene_ids biotype synonyms description source_id organism_id run_id created_at created_by_id
id
5734 2Z2LBAj16utl TRAFD1 None ENSG00000135148 10906 protein_coding FLN29 TRAF-type zinc finger domain containing 1 11 1 None 2024-12-20 15:05:02.914376+00:00 1
! record with similar symbol exists! did you mean to load it?
uid symbol stable_id ensembl_gene_id ncbi_gene_ids biotype synonyms description source_id organism_id run_id created_at created_by_id
id
13498 19ZTVOfazMYF SEPTIN14 None ENSG00000154997 346288 protein_coding SEPT14|FLJ44060 septin 14 11 1 None 2024-12-20 15:05:03.466370+00:00 1
! records with similar symbols exist! did you mean to load one of them?
uid symbol stable_id ensembl_gene_id ncbi_gene_ids biotype synonyms description source_id organism_id run_id created_at created_by_id
id
8223 F36vWNagki41 CCL3 None ENSG00000274221 6348 protein_coding LD78|G0S19-1|SCYA3|LD78ALPHA|SCI|MIP-1-ALPHA C-C motif chemokine ligand 3 11 1 None 2024-12-20 15:05:03.039588+00:00 1
8224 EBoWJxh70guC CCL3 None ENSG00000277632 6348 protein_coding LD78|G0S19-1|SCYA3|LD78ALPHA|SCI|MIP-1-ALPHA C-C motif chemokine ligand 3 11 1 None 2024-12-20 15:05:03.039611+00:00 1
8225 6XmKAksx3Nn4 CCL3 None ENSG00000278567 6348 protein_coding LD78|G0S19-1|SCYA3|LD78ALPHA|SCI|MIP-1-ALPHA C-C motif chemokine ligand 3 11 1 None 2024-12-20 15:05:03.039634+00:00 1
! records with similar symbols exist! did you mean to load one of them?
uid symbol stable_id ensembl_gene_id ncbi_gene_ids biotype synonyms description source_id organism_id run_id created_at created_by_id
id
5801 TfqHfw8FjZxq CCL4 None ENSG00000275302 6351 protein_coding MIP-1-BETA|SCYA4|AT744.1|LAG1|ACT-2 C-C motif chemokine ligand 4 11 1 None 2024-12-20 15:05:02.917677+00:00 1
5802 2MLaX8EEZ9sQ CCL4 None ENSG00000275824 6351 protein_coding MIP-1-BETA|SCYA4|AT744.1|LAG1|ACT-2 C-C motif chemokine ligand 4 11 1 None 2024-12-20 15:05:02.917700+00:00 1
5803 7P74Aze5sMxb CCL4 None ENSG00000277943 6351 protein_coding MIP-1-BETA|SCYA4|AT744.1|LAG1|ACT-2 C-C motif chemokine ligand 4 11 1 None 2024-12-20 15:05:02.917723+00:00 1
! records with similar symbols exist! did you mean to load one of them?
uid symbol stable_id ensembl_gene_id ncbi_gene_ids biotype synonyms description source_id organism_id run_id created_at created_by_id
id
2713 7TBpxi4zzmMB IGLC3 None ENSG00000211679 IG_C_gene IGLC immunoglobulin lambda constant 3 (Kern-Oz+ mar... 11 1 None 2024-12-20 15:05:02.767475+00:00 1
8748 10LbfkUokHgx IGLC1 None ENSG00000211675 IG_C_gene IGLC immunoglobulin lambda constant 1 11 1 None 2024-12-20 15:05:03.067440+00:00 1
11200 2qFUCnrrxPlc IGLC7 None ENSG00000211685 IG_C_gene immunoglobulin lambda constant 7 11 1 None 2024-12-20 15:05:03.344408+00:00 1
! records with similar symbols exist! did you mean to load one of them?
uid symbol stable_id ensembl_gene_id ncbi_gene_ids biotype synonyms description source_id organism_id run_id created_at created_by_id
id
13 4oEC1FHbExIX TAS2R31 None ENSG00000256436 259290 protein_coding TAS2R44|T2R31|T2R53 taste 2 receptor member 31 11 1 None 2024-12-20 15:05:02.640496+00:00 1
14 4e6Rg8UcUnf5 TAS2R31 None ENSG00000263097 259290 protein_coding TAS2R44|T2R31|T2R53 taste 2 receptor member 31 11 1 None 2024-12-20 15:05:02.640522+00:00 1
15 1ELqD18jbeeq TAS2R31 None ENSG00000282256 259290 protein_coding TAS2R44|T2R31|T2R53 taste 2 receptor member 31 11 1 None 2024-12-20 15:05:02.640550+00:00 1