Skip to main content

A thin wrapper around rpy2 with strong opinions on how data types should be converted.

Project description

rwrap

PyPI Tests

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 biomaRt can be as simple as follows:

from rwrap import 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

rwrap-0.1.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rwrap-0.1.1-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file rwrap-0.1.1.tar.gz.

File metadata

  • Download URL: rwrap-0.1.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for rwrap-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b564263d7c668aa39d293826a925d28192ea94f1f5e16c11e9408b9534a3958f
MD5 d18947c5abf8dff3b0a5626106e4175e
BLAKE2b-256 265754f0ad0a649b6a23aab2876712c3117738cb9b4584f3f2695d009c749dca

See more details on using hashes here.

File details

Details for the file rwrap-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: rwrap-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for rwrap-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3e7387412f49262374355545b544dfe22e7dfe4b84285b2f357ee429684c0364
MD5 2e43ae09a8970bcf62798eeb432c531e
BLAKE2b-256 468ad8776429d12f8b50c3dd7870a7bc129230ae3a6c127e8d3cc0213e713c1b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page