Snippets

Dénes Türei Short guide for the annotations and intercell databases in pypath

Created by Dénes Türei last modified
#!/usr/bin/env python

# Saez Lab 2020
# Denes Turei
# turei.denes@gmail.com

import importlib as imp

from pypath import omnipath
from pypath.core import intercell
from pypath.core import annot
from pypath.core import intercell_annot
from pypath.utils import mapping

a = omnipath.db.get_db('annotations')
i = omnipath.db.get_db('intercell')

# the annotation database

# individual annotation databases:
a.annots

# select one database
comppi = a.annots['ComPPI']

# query the fields
comppi.get_names()

# query the values for one field
comppi.get_values('location')

# query the proteins by field-value pairs
comppi.get_subset(location = 'nucleus')
comppi.get_subset(location = {'nucleus', 'cytosol'})

# the intercell database

# the category names
i.class_names

# their labels
i.class_labels

# get all the classes for a protein
i.classes_by_entity('P00533')

# count the members in each class
i.counts_by_class()

# get the entities annotated by each resource
i.entities_by_resource()

# get all members from one class
i.get_class('tight_junction')

# to see gene symbols
mapping.map_names(i.get_class('ligand'), 'uniprot', 'genesymbol')

# how to change the annotation definitions
# -- edit the definition in the pypath/core/intercell_annot.py file in your
#    local repo
# -- reload the modules
# -- rebuild the intercell database
# -- if you are satisfied with the result, commit your changes with a good
#    commit message and push it to the origin
# -- please commit each change separately so we can keep track what's going on

# once you have the definitions changed, reload the modules
imp.reload(intercell_annot)
imp.reload(annot)
imp.reload(intercell)

# rebuild the intercell database (this takes time but is relatively quick
# as the annotations and complex databases are already loaded and we don't
# need to change them)
i = intercell.IntercellAnnotation()

# then inspect the new `i` object if your changes could address the wrong
# annotations; if you are satisfied commit your changes

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.