ExperimentalFactor¶
lamindb provides access to the following public ExperimentalFactor ontologies through bionty:
Here we show how to access and search ExperimentalFactor 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:
experimentalfactors = bt.ExperimentalFactor.public(organism="all")
experimentalfactors
→ connected lamindb: testuser1/test-public-ontologies
PublicOntology
Entity: ExperimentalFactor
Organism: all
Source: efo, 3.70.0
#terms: 18131
As for registries, you can export the ontology as a DataFrame
:
df = experimentalfactors.df()
df.head()
name | definition | synonyms | parents | molecule | instrument | measurement | |
---|---|---|---|---|---|---|---|
ontology_id | |||||||
EFO:0000001 | experimental factor | An Experimental Factor In Array Express Which ... | ExperimentalFactor | [] | None | None | None |
EFO:0000002 | CS57511 | Cs57511 Is An Arabidopsis Thaliana Strain As D... | None | [] | None | None | None |
EFO:0000003 | CS57512 | Cs57512 Is An Arabidopsis Thaliana Strain As D... | None | [] | None | None | None |
EFO:0000004 | CS57515 | Cs57515 Is An Arabidopsis Thaliana Strain As D... | None | [] | None | None | None |
EFO:0000005 | CS57520 | Cs57520 Is An Arabidopsis Thaliana Strain As D... | None | [] | None | None | 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 = experimentalfactors.lookup()
The .
accessor provides normalized terms (lower case, only contains alphanumeric characters and underscores):
lookup.sequencer
ExperimentalFactor(ontology_id='EFO:0003739', name='sequencer', definition=None, synonyms=None, parents=array(['EFO:0000548'], dtype=object), molecule=None, instrument=None, measurement=None)
To look up the exact original strings, convert the lookup object to dict and use the []
accessor:
lookup_dict = lookup.dict()
lookup_dict["sequencer"]
ExperimentalFactor(ontology_id='EFO:0003739', name='sequencer', definition=None, synonyms=None, parents=array(['EFO:0000548'], dtype=object), molecule=None, instrument=None, measurement=None)
By default, the name
field is used to generate lookup keys. You can specify another field to look up:
lookup = experimentalfactors.lookup(experimentalfactors.ontology_id)
lookup.efo_0003739
ExperimentalFactor(ontology_id='EFO:0003739', name='sequencer', definition=None, synonyms=None, parents=array(['EFO:0000548'], dtype=object), molecule=None, instrument=None, measurement=None)
Search terms¶
Search behaves in the same way as it does for registries:
experimentalfactors.search("single-cell rna seq").head(3)
name | definition | synonyms | parents | molecule | instrument | measurement | |
---|---|---|---|---|---|---|---|
ontology_id | |||||||
EFO:0008913 | single-cell RNA sequencing | A Protocol That Provides The Expression Profil... | single-cell RNA-seq|scRNA-seq|single cell RNA ... | [EFO:0001457, EFO:0007832] | RNA assay | single cell sequencing | None |
EFO:0010964 | barcoded plate-based single cell RNA-seq | A Single-Cell Rna Sequencing Library Construct... | barcoded plate-based single-cell RNA-seq | [EFO:0010183] | None | None | None |
EFO:0022488 | Smart-seq3 | Smart-Seq3 Is An Advanced Single-Cell Rna Sequ... | None | [EFO:0010184] | None | None | None |
By default, search also covers synonyms and all other fileds containing strings:
experimentalfactors.search("single-cell RNA-seq").head(3)
name | definition | synonyms | parents | molecule | instrument | measurement | |
---|---|---|---|---|---|---|---|
ontology_id | |||||||
EFO:0008913 | single-cell RNA sequencing | A Protocol That Provides The Expression Profil... | single-cell RNA-seq|scRNA-seq|single cell RNA ... | [EFO:0001457, EFO:0007832] | RNA assay | single cell sequencing | None |
EFO:0008797 | MATQ-seq | Multiple Annealing And Dc-Tailing-Based Quanti... | None | [EFO:0001457] | RNA assay | None | None |
EFO:0009919 | SPLiT-seq | Split-Pool Ligation-Based Transcriptome Sequen... | split-pool ligation-based transcriptome sequen... | [EFO:0001457, EFO:0010183] | RNA assay | None | None |
Search specific field (by default, search is done on all fields containing strings):
experimentalfactors.search(
"protocol that provides the expression profiles of single cells",
field=experimentalfactors.definition,
).head()
name | definition | synonyms | parents | molecule | instrument | measurement | |
---|---|---|---|---|---|---|---|
ontology_id | |||||||
EFO:0008913 | single-cell RNA sequencing | A Protocol That Provides The Expression Profil... | single-cell RNA-seq|scRNA-seq|single cell RNA ... | [EFO:0001457, EFO:0007832] | RNA assay | single cell sequencing | None |
Standardize ExperimentalFactor identifiers¶
Let us generate a DataFrame
that stores a number of ExperimentalFactor identifiers, some of which corrupted:
df_orig = pd.DataFrame(
index=[
"EFO:0011021",
"EFO:1002050",
"EFO:1002047",
"EFO:1002049",
"This experimentalfactor does not exist",
]
)
df_orig
EFO:0011021 |
---|
EFO:1002050 |
EFO:1002047 |
EFO:1002049 |
This experimentalfactor does not exist |
We can check whether any of our values are validated against the ontology reference:
validated = experimentalfactors.validate(df_orig.index, experimentalfactors.name)
df_orig.index[~validated]
! 5 unique terms (100.00%) are not validated: 'EFO:0011021', 'EFO:1002050', 'EFO:1002047', 'EFO:1002049', 'This experimentalfactor does not exist'
Index(['EFO:0011021', 'EFO:1002050', 'EFO:1002047', 'EFO:1002049',
'This experimentalfactor 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.ExperimentalFactor").df()
# only lists the sources that are currently used
bt.Source.filter(entity="bionty.ExperimentalFactor", 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 | ||||||||||||||||||
21 | 2a1HvjdB | bionty.ExperimentalFactor | all | efo | False | True | The Experimental Factor Ontology | http://www.ebi.ac.uk/efo/releases/v3.70.0/efo.owl | None | https://bioportal.bioontology.org/ontologies/EFO | 1 | None | 3.70.0 | 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="efo", organism="all"
).first()
experimentalfactors= bt.ExperimentalFactor.public(source=source)
experimentalfactors
PublicOntology
Entity: ExperimentalFactor
Organism: all
Source: efo, 3.70.0
#terms: 18131
The currently used ontologies can be displayed using:
bt.Source.filter(currently_used=True).df()