No project description provided
Project description
scibiomart
This is just a simple wrapper around the API from BioMart, but I found existing packages were not quite sufficent for what I was wanting to do i.e. cli interface and python interface with tsv API.
Here you can simply get the list of all genes and perform other biomart functions such as mapping between human and mouse.
Have a look at the docs which explains things in more detail.
Installation
pip install scibiomart
Usage
For the most simple usage, use API which will get the latest mouse and human and map gene IDs to gene names.
Examples
from scibiomart import SciBiomartApi
sb = SciBiomartApi()
# Get only the default for those genes
results_df = sb.get_mouse_default({'ensembl_gene_id': 'ENSMUSG00000029844,ENSMUSG00000032446'})
# Select attributes
results_df = sb.get_mouse_default({'ensembl_gene_id': 'ENSMUSG00000020875,ENSMUSG00000038210'},
attr_list=['entrezgene_id'])
# Get all genes
results_df = sb.get_mouse_default()
# Sort the results based on TSS (takes direction into account)
results_df = sb.sort_df_on_starts(results_df)
# Get human
results_df = sb.get_human_default()
Examples extended
If you are interested in more than the simple API, see the tests for all examples, however, you can list the datasets etc, and query other attributes.
Print marts
sb = SciBiomart()
marts = sb.list_marts()
print('\n'.join(marts))
Print datasets
sb = SciBiomart()
sb.set_mart('ENSEMBL_MART_ENSEMBL')
err = sb.list_datasets()
List attributes
sb = SciBiomart()
sb.set_mart('ENSEMBL_MART_ENSEMBL')
sb.set_dataset('fcatus_gene_ensembl')
err = sb.list_attributes()
List configs
sb = SciBiomart()
sb.set_mart('ENSEMBL_MART_ENSEMBL')
sb.set_dataset('fcatus_gene_ensembl')
err = sb.list_configs()
List filters
sb = SciBiomart()
sb.set_mart('ENSEMBL_MART_ENSEMBL')
sb.set_dataset('fcatus_gene_ensembl')
err = sb.list_filters()
Run generic query
Here we show a generic query for two genes (as a comma separated list) and the attributes we're interested in are 'ensembl_gene_id', 'hgnc_symbol', 'uniprotswissprot'.
Run query: def run_query(self, filter_dict: dict, attr_list: list):
i.e. you can pass it a filter dictionary and a list of attributes. This will make it quicker, you can also run it and it
will get all genes (i.e. if filter_dict is empty).
sb = SciBiomart()
sb.set_mart('ENSEMBL_MART_ENSEMBL')
sb.set_dataset('hsapiens_gene_ensembl')
results = sb.run_query({'ensembl_gene_id': 'ENSG00000139618,ENSG00000091483'},
['ensembl_gene_id', 'hgnc_symbol', 'uniprotswissprot'])
print(results)
Match mouse to human
Get mouse orthologs for human genes
sb = SciBiomart()
sb.set_mart('ENSEMBL_MART_ENSEMBL')
sb.set_dataset('hsapiens_gene_ensembl')
attributes = ['ensembl_gene_id', 'mmusculus_homolog_ensembl_gene', 'mmusculus_homolog_perc_id_r1']
results = sb.run_query({'ensembl_gene_id': 'ENSG00000139618,ENSG00000091483'}, attributes)
print(results)
See docs for more info
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file scibiomart-1.0.1.tar.gz
.
File metadata
- Download URL: scibiomart-1.0.1.tar.gz
- Upload date:
- Size: 22.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eda0a9b72d81bba427ed37c1e5e0a61fdbb8365c2690478f185165562063ef98 |
|
MD5 | 6be055b1cda249097d60e000f695b2e1 |
|
BLAKE2b-256 | a395406f2506a8b0e21bbc83fa9c7967596d9cceac471a741e6032bc87fadc63 |
File details
Details for the file scibiomart-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: scibiomart-1.0.1-py3-none-any.whl
- Upload date:
- Size: 39.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1da4431c6d0463dd196bb1ea88555ddd1700535519e3c1847c3d542c75154d7a |
|
MD5 | dc2c24d0ec8d815ba5b240101226c7a7 |
|
BLAKE2b-256 | 0f66c7cb10b9ad4b33146cdef82b9101d17852932bd69c53e7212efc94b220ff |