Protein¶
lamindb provides access to the following public Protein ontologies through bionty:
Here we show how to access and search Protein ontologies to standardize new data.
import bionty as bt
import pandas as pd
PublicOntology objects¶
Let us create a public ontology accessor with .public
method, which chooses a default public ontology source from Source
.
It’s a PublicOntology object, which you can think about as a public registry:
proteins = bt.Protein.public(organism="human")
proteins
→ connected lamindb: testuser1/test-public-ontologies
PublicOntology
Entity: Protein
Organism: human
Source: uniprot, 2024-03
#terms: 204088
As for registries, you can export the ontology as a DataFrame
:
df = proteins.df()
df.head()
uniprotkb_id | name | description | length | synonyms | gene_symbol | ensembl_gene_ids | |
---|---|---|---|---|---|---|---|
0 | A0A023HJ61 | Ras-related protein Rab-4A | 121 | RAB4A | None | ||
1 | A0A023HN28 | SRSF3 | USP6 fusion protein | 16 | None | None | |
2 | A0A023I7F4 | Cytochrome b | 380 | CYTB | None | ||
3 | A0A023I7H2 | NADH-ubiquinone oxidoreductase chain 5 | 603 | EC 7.1.1.2 | ND5 | None | |
4 | A0A023I7H5 | ATP synthase subunit a | 226 | ATP6 | None |
Unlike registries, you can also export it as a Pronto object via public.ontology
.
Look up terms¶
As for registries, terms can be looked up with auto-complete:
lookup = proteins.lookup()
The .
accessor provides normalized terms (lower case, only contains alphanumeric characters and underscores):
lookup.ac3
Protein(uniprotkb_id='Q8IX81', name='AC3', description='', length=502, synonyms='', gene_symbol=None, ensembl_gene_ids=None)
To look up the exact original strings, convert the lookup object to dict and use the []
accessor:
lookup_dict = lookup.dict()
lookup_dict["AC3"]
Protein(uniprotkb_id='Q8IX81', name='AC3', description='', length=502, synonyms='', gene_symbol=None, ensembl_gene_ids=None)
By default, the name
field is used to generate lookup keys. You can specify another field to look up:
lookup = proteins.lookup(proteins.gene_symbol)
lookup.rab4a
! 3 records found for 'rab4a'. Returning based on keep='first'.
Protein(uniprotkb_id='A0A023HJ61', name='Ras-related protein Rab-4A', description='', length=121, synonyms='', gene_symbol='RAB4A', ensembl_gene_ids=None)
Search terms¶
Search behaves in the same way as it does for registries:
proteins.search("RAS").head(3)
uniprotkb_id | name | description | length | synonyms | gene_symbol | ensembl_gene_ids | |
---|---|---|---|---|---|---|---|
189295 | Q96PV0 | Ras | Rap GTPase-activating protein SynGAP | 1343 | Neuronal RasGAP|Synaptic Ras GTPase-activating... | SYNGAP1 | ENST00000395071.6 [Q96PV0-4];ENST00000414753.6... |
16769 | A0A140T8W4 | Ras | Rap GTPase-activating protein SynGAP | 487 | SYNGAP1 | ENST00000355818.3; | |
158749 | P20936 | Ras GTPase-activating protein 1 | 1047 | GAP|GTPase-activating protein|RasGAP|Ras p21 p... | RASA1 | ENST00000274376.11 [P20936-1];ENST00000456692.... |
By default, search also covers synonyms and all other fileds containing strings:
proteins.search("member of RAS oncogene family like 2B").head(3)
uniprotkb_id | name | description | length | synonyms | gene_symbol | ensembl_gene_ids | |
---|---|---|---|---|---|---|---|
71092 | A0A8I5KRY9 | RAB | member of RAS oncogene family like 2B | 58 | RABL2B | ENST00000685352.1; | |
71734 | A0A8I5KX29 | RAB | member of RAS oncogene family like 2B | 51 | RABL2B | ENST00000690024.1; | |
81780 | A8MXF6 | RAB | member of RAS oncogene family like 2B | 165 | RABL2B | ENST00000395591.5; |
Search specific field (by default, search is done on all fields containing strings):
proteins.search(
"RABL2B",
field=proteins.gene_symbol,
).head()
uniprotkb_id | name | description | length | synonyms | gene_symbol | ensembl_gene_ids | |
---|---|---|---|---|---|---|---|
71092 | A0A8I5KRY9 | RAB | member of RAS oncogene family like 2B | 58 | RABL2B | ENST00000685352.1; | |
71734 | A0A8I5KX29 | RAB | member of RAS oncogene family like 2B | 51 | RABL2B | ENST00000690024.1; | |
81780 | A8MXF6 | RAB | member of RAS oncogene family like 2B | 165 | RABL2B | ENST00000395591.5; | |
101750 | C9JFZ0 | RAB | member of RAS oncogene family like 2B | 20 | RABL2B | ENST00000413505.1; | |
119224 | F2Z2T3 | RAB | member of RAS oncogene family like 2B | 99 | RABL2B | ENST00000395590.5; |
Standardize Protein identifiers¶
Let us generate a DataFrame
that stores a number of Protein identifiers, some of which corrupted:
df_orig = pd.DataFrame(
index=[
"A0A024QZ08",
"X6RLV5",
"X6RM24",
"A0A024QZQ1",
"This protein does not exist",
]
)
df_orig
A0A024QZ08 |
---|
X6RLV5 |
X6RM24 |
A0A024QZQ1 |
This protein does not exist |
We can check whether any of our values are validated against the ontology reference:
validated = proteins.validate(df_orig.index, proteins.name)
df_orig.index[~validated]
! 5 unique terms (100.00%) are not validated: 'A0A024QZ08', 'X6RLV5', 'X6RM24', 'A0A024QZQ1', 'This protein does not exist'
Index(['A0A024QZ08', 'X6RLV5', 'X6RM24', 'A0A024QZQ1',
'This protein does not exist'],
dtype='object')
Ontology source versions¶
For any given entity, we can choose from a number of versions:
bt.Source.filter(entity="bionty.Protein").df()
# only lists the sources that are currently used
bt.Source.filter(entity="bionty.Protein", currently_used=True).df()
uid | entity | organism | name | in_db | currently_used | description | url | md5 | source_website | space_id | dataframe_artifact_id | version | run_id | created_at | created_by_id | _aux | branch_id | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
id | ||||||||||||||||||
10 | 3EYyGRYN | bionty.Protein | human | uniprot | False | True | Uniprot | s3://bionty-assets/df_human__uniprot__2024-03_... | None | https://www.uniprot.org | 1 | None | 2024-03 | None | 2025-07-14 06:41:44.843000+00:00 | 1 | None | 1 |
11 | 01RWXN2V | bionty.Protein | mouse | uniprot | False | True | Uniprot | s3://bionty-assets/df_mouse__uniprot__2024-03_... | None | https://www.uniprot.org | 1 | None | 2024-03 | None | 2025-07-14 06:41:44.843000+00:00 | 1 | None | 1 |
When instantiating a Bionty object, we can choose a source or version:
source = bt.Source.filter(
name="uniprot", organism="human"
).first()
proteins= bt.Protein.public(source=source)
proteins
PublicOntology
Entity: Protein
Organism: human
Source: uniprot, 2024-03
#terms: 204088
The currently used ontologies can be displayed using:
bt.Source.filter(currently_used=True).df()