A thin wrapper around rpy2 with strong opinions on how data types should be converted.
Project description
rwrap
A thin wrapper around rpy2 with strong opinions on how data types should be converted. This enables easy usage of R packages from Python with no boilerplate code.
Warning: still work-in-progress, issues and PRs welcome
Installation
pip install rwrap
Usage
For example, accessing Bioconductor's biomaRt package can be as simple as follows:
from rwrap import biomaRt
biomaRt
## <module 'biomaRt' from '/Library/Frameworks/R.framework/Versions/4.1/Resources/library/biomaRt'>
snp_list = ["rs7329174", "rs4948523", "rs479445"]
ensembl = biomaRt.useMart("ENSEMBL_MART_SNP", dataset="hsapiens_snp")
df = biomaRt.getBM(
attributes=["refsnp_id", "chr_name", "chrom_start", "consequence_type_tv"],
filters="snp_filter", values=snp_list, mart=ensembl
)
print(df) # pandas.DataFrame
## refsnp_id chr_name chrom_start consequence_type_tv
## 1 rs479445 1 60875960 intron_variant
## 2 rs479445 1 60875960 NMD_transcript_variant
## 3 rs4948523 10 58579338 intron_variant
## 4 rs7329174 13 40983974 intron_variant
Check the tests/ directory for more examples showing how to rewrite R scripts in Python.
Tests
A comprehensive test suite aims at providing stability and avoiding regressions.
The examples in tests/ are validated using pytest.
Run tests as follows:
$ pytest tests/
Project details
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rwrap-0.1.2.tar.gz.
File metadata
- Download URL: rwrap-0.1.2.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bdd4978a289669f3b024547653dea9ac0a578e70f0ab1ce966629b394568b735
|
|
| MD5 |
bf25dc6bf6b1fc53078e5fcd1e04649c
|
|
| BLAKE2b-256 |
881ed1fd1b5fc852f34b1040fd38869d77f000a380566d8438fc31bf54da6f02
|
File details
Details for the file rwrap-0.1.2-py3-none-any.whl.
File metadata
- Download URL: rwrap-0.1.2-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7aaaed73053e2b4ff4f067535ba9099cbeda791901164dcc9ab9cb0ca0606196
|
|
| MD5 |
3685ed95fd41acee3e36ea20937b1d01
|
|
| BLAKE2b-256 |
aa26058d94ce96a5a807953c71bf393c58ca63c4daa34a7486ee4b36ac48cc5e
|