Skip to content

Repository files navigation

resprpy

resprpy is a complete Python port of the respR 2.3.4 R package (Harianto & Carey, Methods in Ecology and Evolution 2019, doi:10.1111/2041-210X.13162) for processing and analysis of respirometry (oxygen uptake / metabolic rate) data.

The goal is numeric parity with R: every exported function is verified against outputs generated by R 4.5.3 (pytest parity tests, all 57 passing).

🇨🇳 中文版说明见 README.zh-CN.md · Full usage guide (EN): docs/respR_resprpy_guide.en.html · 使用手册(中文): docs/respR_resprpy_guide.zh.html

Installation

pip install -e .            # or: pip install -e ".[plot,test]"

Dependencies: numpy, scipy (optional: matplotlib, pytest, openpyxl).

Feature parity (all 27 respR exports)

respR (R) resprpy (Python) Status
calc_rate calc_rate ✅ ≤1e-13
calc_rate.int calc_rate_int ✅ ≤1e-6
calc_rate.bg calc_rate_bg ✅ ≤1e-6
calc_rate.ft calc_rate_ft ✅ ≤1e-5
auto_rate auto_rate ✅ bw.SJ/density bit-exact
auto_rate.int auto_rate_int ✅ ≤1e-5
adjust_rate adjust_rate ✅ 6 methods
adjust_rate.ft adjust_rate_ft ✅ ≤1e-6
select_rate select_rate ✅ all 34 methods
select_rate.ft select_rate_ft ✅ ≤1e-5
convert_DO convert_DO ✅ ≤1e-12
convert_MR convert_MR ✅ ≤1e-12
convert_rate convert_rate ✅ ≤1e-12
convert_rate.ft convert_rate_ft ✅ ≤1e-8
convert_val convert_val ✅ ≤1e-12
format_time format_time ✅ exact
inspect inspect ✅ checks/locs match
inspect.ft inspect_ft
oxy_crit oxy_crit ✅ bsr + segmented
import_file import_file ✅ NeoFox exact (14 parsers)
sim_data sim_data ✅ structure
subsample subsample
subset_data subset_data
select select
%>% — (Python chaining) ➖ n/a
test_lin test_lin 🟡 structure matches
unit_args unit_args
S3 plot() plot_inspect plot_calc_rate plot_auto_rate plot_oxy_crit ✅ matplotlib

Highlights

  • Segmented (Muggeo 2003) breakpoint analysis ported from the segmented 2.2-1 package including R's MT19937 RNG (bit-exact set.seed sequences, bootstrap-restart search) — crit values match R exactly (e.g. 7.719111…).
  • select_rate — all 34 methods verified against R, including error behaviour (methods R rejects raise the same errors).
  • convert_* — physical anchors exact (sw_dens=1024.64077347883, molvol=24.03038425, mg/L→%Air=108.4419).
  • No C/C++ runtime: the rolling regression, kernel density, marelac physics and segmented algorithm used by respR's dependencies are all inlined into pure numpy/scipy — PyInstaller-friendly.

Tests

python -m pytest tests/ -v        # 57 tests, all green

Reference CSVs under tests/reference/ were generated by R 4.5.3 (reference/gen_refs_*.R); pytest compares element-wise with graded tolerances (coeffs 1e-8, rsq 1e-12, time 1e-9, density 1e-3).

Package structure (vs respR)

See the structure comparison section in the usage guides.

Citation

resprpy is a Python port of the R package respR. If you use resprpy in publications or derived software, please cite the original respR work:

Harianto, J., Carey, N., & Byrne, M. (2019). respR — An R package for the manipulation and analysis of respirometry data. Methods in Ecology and Evolution, 10(6), 912–920. doi:10.1111/2041-210X.13162

Machine-readable citation metadata: CITATION.cff.

License

GPL-3 (same as respR). This is a clean-room style port of respR's algorithms and its dependencies' algorithms; distributing it requires GPL-3 compliance.

About

Python port of the respR R package: respirometry data processing and metabolic rate analysis

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages