Skip to main content

Parse and read RDS files as Python representations

Project description

Project generated with PyScaffold PyPI-Server Unit tests

rds2py

Parse and construct Python representations for datasets stored in RDS files. rds2py supports a few base classes from R and Bioconductor's SummarizedExperiment and SingleCellExperiment S4 classes. This is possible because of Aaron's rds2cpp library.

The package uses memory views (except for strings) to access the same memory from C++ in Python (through Cython of course). This is especially useful for large datasets so we don't make multiple copies of data.

Install

Package is published to PyPI

pip install rds2py

Usage

If you do not have an RDS object handy, feel free to download one from single-cell-test-files.

from rds2py import as_summarized_experiment, read_rds

r_obj = read_rds(<path_to_file>)

This r_obj holds a dictionary representation of the RDS file, we can now transform this object into Python representations.

rObj always contains two keys

  • data: If atomic entities, contains the NumPy view of the array.
  • attributes: Additional properties available for the object.

In addition, the package provides functions to convert parsed R objects into Python representations.

from rds2py import as_spase_matrix, as_summarized_experiment

# to convert an robject to a sparse matrix
sp_mat = as_sparse(rObj)

# to convert an robject to SCE
sce = as_summarized_experiment(rObj)

For more examples converting data.frame, dgCMatrix, dgRMatrix, dgTMatrix to Python, checkout the documentation.

Developer Notes

This project uses Cython to provide bindings from C++ to Python.

Steps to setup dependencies -

  • git submodules is initialized in extern/rds2cpp
  • cmake . in extern/rds2cpp directory to download dependencies, especially the byteme library

First one needs to build the extern library, this would generate a shared object file to src/rds2py/core-[*].so

python setup.py build_ext --inplace

For typical development workflows, run

python setup.py build_ext --inplace && tox

Note

This project has been set up using PyScaffold 4.5. For details and usage information on PyScaffold see https://pyscaffold.org/.

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

rds2py-0.4.2.tar.gz (2.1 MB view hashes)

Uploaded Source

Built Distributions

rds2py-0.4.2-cp311-cp311-musllinux_1_1_x86_64.whl (2.2 MB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.1+ x86-64

rds2py-0.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

rds2py-0.4.2-cp311-cp311-macosx_11_0_arm64.whl (322.3 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

rds2py-0.4.2-cp311-cp311-macosx_10_9_x86_64.whl (334.1 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

rds2py-0.4.2-cp310-cp310-musllinux_1_1_x86_64.whl (2.2 MB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.1+ x86-64

rds2py-0.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

rds2py-0.4.2-cp310-cp310-macosx_11_0_arm64.whl (322.0 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

rds2py-0.4.2-cp310-cp310-macosx_10_9_x86_64.whl (333.8 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

rds2py-0.4.2-cp39-cp39-musllinux_1_1_x86_64.whl (2.2 MB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.1+ x86-64

rds2py-0.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

rds2py-0.4.2-cp39-cp39-macosx_11_0_arm64.whl (322.4 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

rds2py-0.4.2-cp39-cp39-macosx_10_9_x86_64.whl (334.4 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

rds2py-0.4.2-cp38-cp38-musllinux_1_1_x86_64.whl (2.2 MB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.1+ x86-64

rds2py-0.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.6 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

rds2py-0.4.2-cp38-cp38-macosx_11_0_arm64.whl (321.9 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

rds2py-0.4.2-cp38-cp38-macosx_10_9_x86_64.whl (333.8 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

Supported by

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