Genomic analysis often crosses two software worlds: R for Bioconductor and Python for machine learning. BiocPy’s surprising idea is to preserve Bioconductor’s data model directly in Python, instead of forcing analysts to rebuild it at every step.
BiocPy: A Framework for Cross-Platform Genomic Data andMethods Interoperability
Kancherla, J.; Lun, A.
Bioconductor provides standardized data structures and statistical methods for high-throughput genomic analysis in R, whereas Python has become a primary environment for machine learning, image analysis, and general-purpose data science. Combining tools across both ecosystems often requires adhoc le conversions or embedded language runtimes that can lose metadata, introduce maintenance overhead, or lead to subtle di erences in downstream results. Here, we present BiocPy, a collection of Python packages that support cross-language genomic work ows through three complementary layers: (1) native Python implementations of Bioconductor's core data structures; (2) lossless data exchange via direct reading and writing of serialized R (.rds) objects and the language-neutral ArtifactDB format for persistent, multi-stage pipelines; and (3) a cross-platform method development paradigm built on shared C++ libraries wrapped across R, Python, and WebAssembly to support identical statistical analyses across environments. All packages in the BiocPy ecosystem are published to the Python Package Index (PyPI) with source code hosted at https://github.com/BiocPy.
Transcript
Genomic analysis often crosses two software worlds: R for Bioconductor and Python for machine learning. BiocPy’s surprising idea is to preserve Bioconductor’s data model directly in Python, instead of forcing analysts to rebuild it at every step.
Bioconductor provides standardized data structures and statistical methods for high-throughput genomic analysis in R, whereas Python has become a primary environment for machine learning, image analysis, and general-purpose data science. Combining tools across both ecosystems often requires ad hoc file conversions or embedded language runtimes that can lose metadata, introduce maintenance overhead, or lead to subtle differences in downstream results.
BiocPy is a collection of Python packages that support cross-language genomic workflows through three complementary layers: native Python implementations of Bioconductor’s core data structures, lossless data exchange, and a cross-platform method development paradigm. Bioconductor, built upon the R programming language, was designed with a focus on statistical analysis and visualization of genomic data.
Over the past two decades, Bioconductor has grown into a repository of over 2,000 packages organized around shared data structures and design principles. Classes such as GenomicRanges and SummarizedExperiment serve as a common currency for data exchange, allowing developers to build and compose methods without defining bespoke representations for each package.
Genomic analyses frequently span both ecosystems: an analyst may rely on Bioconductor packages for experimental design, normalization, or differential expression, and then move to Python for deep learning or large-scale integration. Bridging these steps typically relies on exporting intermediate files, which strips nested metadata and requires manual reassembly, or reimplementing statistical routines in Python, which can introduce subtle algorithmic discrepancies.
BiocPy addresses this gap by implementing Bioconductor’s core class definitions directly in Python. Rather than embedding an R session inside Python or proposing a new data standard, BiocPy provides native Python classes such as GenomicRanges and SummarizedExperiment that mirror the structure and behavior of their R counterparts.
Keeping the conceptual data model consistent reduces friction when moving data or translating workflows between languages, while still allowing direct conversion to standard Python structures when needed. Figure one presents a hierarchy of experimental containers that mirror Bioconductor S4 semantics.
SummarizedExperiment and RangedSummarizedExperiment connect assay matrices with feature and sample metadata; SingleCellExperiment extends this structure with reduced dimensions and alternative experiments. MultiAssayExperiment coordinates multiple assays across a cohort through a sample map, allowing subsetting to remain synchronized even when assays have different sample relationships.
The biocutils package provides S4-like generic functions using Python’s singledispatch mechanism, such as combine rows, combine columns, and subset, along with base one-dimensional data structures such as Factor, Names, and typed list classes. Core numerical representations build directly on NumPy and SciPy, keeping the dependency footprint minimal.
Reading across the three columns, the table shows a systematic correspondence: BiocPy packages in the first column are paired with named Bioconductor equivalents in the second, while the third column expands from basic containers to single-cell, multi-omics, storage, serialization, and annotation roles.
The lower rows also make the ecosystem’s interoperability scope visible, linking Python packages to R datasets, reference tools, and hub resources. Unlike a generic table with chromosome, start, and end columns, a GenomicRanges object couples integer intervals with sequence names, strand orientation, feature-level metadata, and reference genome metadata.
This structure enforces coordinate validity and strand-aware arithmetic across overlap detection, proximity queries, intra-range transformations, and inter-range set operations. Calling promoters on gene annotations automatically accounts for strand direction when computing upstream and downstream coordinates relative to transcription start sites.
Table two reports mean wall-clock runtimes over three runs for overlap and proximity queries across twenty-four chromosomes. For example, at one million by one million intervals, find-overlaps is listed as one point zero eight four seconds for R, compared with zero point five six three seconds for BiocPy using one thread and zero point three three two seconds using four threads; nearest is also reported across the same configurations.
The table matters because it makes the runtime and multi-threading effects directly measurable. SummarizedExperiment serves as the base container for rectangular experimental data, where rows correspond to features such as genes, transcripts, or genomic regions, and columns correspond to samples or cells.
An SE instance stores one or more identically shaped two-dimensional matrices in its assays dictionary, paired with row data and column data members represented as BiocFrame objects. RangedSummarizedExperiment extends SE by adding a row ranges member, enabling range-based queries such as subsetting an expression matrix by genomic overlap directly on the container.
To support datasets that exceed available RAM, BiocPy implements lazy array operations modeled on Bioconductor’s DelayedArray framework. Any experimental container in Section 2.3 can store DelayedArray objects directly in its assays member. Rather than executing array operations immediately, DelayedArray records subsetting, transposition, combining, and element-wise mathematical operations as delayed operations on a file, such as an on-disk HDF5 dataset or TileDB array.
Complex Bioconductor and BiocPy objects are decomposed on disk into standard, language-neutral file formats: HDF5 for dense or sparse matrices and tabular data, and JSON for object metadata. An R user can stage a SingleCellExperiment or MultiAssayExperiment to a directory using alabaster, and a Python user can read that directory using dolomite to reconstruct the corresponding BiocPy object, and vice versa.
When objects are loaded in either R or Python, assay matrices are wrapped as DelayedArray objects rather than read eagerly into memory, enabling out-of-core access to large datasets. By pairing a language-neutral C++ computational layer with consistent high-level container semantics in R and Python, method developers can write and test an algorithm once while exposing idiomatic APIs across ecosystems.
The example considers a single-cell analysis and annotation pipeline in Python to demonstrate how BiocPy connects shared data repositories with cross-language statistical methods. A curated single-cell dataset is fetched from scrnaseq as a SingleCellExperiment object.
The dataset is processed using scranpy, which performs quality control filtering, scaling normalization, variance modeling, principal component analysis, clustering, and multi-modal integration across primary RNA counts and auxiliary modalities. Figure 2 shows a shared C++ core of single-cell algorithms built on the tatami matrix abstraction layer, which provides uniform access to dense, sparse, delayed, and HDF5-backed data.
Language bindings connect this core to R through Rcpp, JavaScript through Emscripten, and Python through pybind11, while user-facing tools consume native ecosystem containers. The architecture lets high-level calls across these environments execute the same underlying implementations, helping prevent algorithmic differences.
BiocPy provides a practical bridge between the R and Bioconductor ecosystems and the Python ecosystem, though several scope boundaries and trade-offs warrant consideration. BiocPy focuses on core data structures, serialization utilities, and analysis workflows such as single-cell and interval operations; it does not aim to port the more than 2,000 specialized downstream statistical packages in Bioconductor.
BiocPy connects R and Python through matching genomic data structures, language-neutral storage, and shared C++ methods. Its scope is deliberately focused: preserve interoperability without attempting to port all of Bioconductor.
CC BY 4.0 · A derivative work by Paperi · AI-generated script, voice and captions · pages and figures unaltered
Drop in a research PDF — get a narrated video walkthrough like this one, with highlights that follow the narration. Free to start.