biomed-parity
生物医学统计方法的独立 Python 实现,附可复现的 R 参考用例与数值对照。
项目状态:Alpha(v0.1.1,迁移进行中)。 方法目录中的 16 个 R 入口均已建立至少一组数值对照,其中竞争风险评分的非默认目标原因 AUC 推断为部分一致。各入口仍存在未覆盖的接口与统计路径,公开 API 可能随验收进展调整。已验证范围与剩余任务见迁移进展。
biomed-parity provides independent Python implementations of selected biomedical statistical methods, accompanied by reproducible R reference cases and numerical comparisons. The implementations depend only on NumPy and SciPy and do not require an R runtime. The project is an early-stage research prototype: public APIs may change as validation continues. Documentation is written in Chinese; docstrings and code comments are in English.
概述
本项目提供以下内容:
- 不依赖 R 运行时的 Python 统计实现,运行时仅使用 NumPy 与 SciPy;
- 每个方法的估计目标、输入约定、结果字段,以及不可估计时的返回行为;
- 基于固定输入、R oracle 脚本与版本化快照的数值对照,容差与已知差异记录在文档中;
- 方法文档与迁移进展中列出的未覆盖路径。
入口
| 内容 | 位置 |
|---|---|
| 调研与优先级 | docs/research.md |
| 方法目录(分类、R 入口、候选与依据) | catalog/methods.json |
| 迁移进展(已验证范围与剩余任务) | catalog/progress.json |
| 方法文档(接口、统计口径、验证与限制) | docs/methods |
| 开发与验收流程 | docs/development.md |
| 本地验证记录 | docs/validation.md |
方法目录覆盖的 R 入口按生物医学分类如下:
| 分类 | R 入口 |
|---|---|
| 生存与竞争风险 | survival::survdiff、survRM2::rmst2、cmprsk、riskRegression::Score、mstate |
| 诊断准确性 | pROC::roc、auc、ci.auc、roc.test(DeLong、部分 AUC、Bootstrap) |
| 临床试验设计 | gsDesign(边界、越界概率、条件把握度) |
| 临床预测与回归 | rms::lrm、calibrate、validate、glmmTMB、variancePartition::dream |
| 流行病学与证据综合 | survey(svycoxph、twophase)、mice、metafor |
| 人体表达统计 | limma、edgeR、DESeq2(含原生负二项 LRT) |
安装与验证
从 PyPI 安装:
python3 -m pip install biomed-parity
开发或验证时从源码安装并运行默认测试:
git clone https://github.com/xiangjiawei1234-prog/biomed-parity.git
cd biomed-parity
python3 -m venv .venv
.venv/bin/python -m pip install -e '.[test]'
.venv/bin/python -m pytest -q
也可直接从 GitHub 安装:
python3 -m pip install "git+https://github.com/xiangjiawei1234-prog/biomed-parity.git"
默认测试仅依赖入库的 R 参考快照,无需安装 R。当前版本默认测试套件为 366 项通过,16 项实时 R 对照按配置跳过。
实时 R 对照
需要本地 R 环境(开发使用 R 4.5.3),R 依赖安装到仓库内的 .r-lib:
Rscript --vanilla validation/install_r.R
R_LIBS_USER="$PWD/.r-lib" BIOMED_R_PARITY=1 .venv/bin/python -m pytest -q -W error
实时对照共 382 项测试,调用对应 R 包并逐项比较数值行为。
项目结构
| 目录 | 内容 |
|---|---|
src/biomed_parity/ |
Python 统计实现 |
catalog/ |
方法调研、优先级与迁移进展 |
docs/methods/ |
每个入口的估计目标、数据约定、结果字段、示例和限制 |
validation/<方法>/ |
人工构造输入、R oracle 脚本、参考输出与候选评估 |
tests/ |
Python 回归、边界条件与可选实时 R 对照 |
范围与限制
- 数值基线对应固定版本的 R 与 R 包,版本记录于方法文档和各
validation/快照。升级上游包后需重新生成快照并复核差异。 - 本项目对齐数值行为与统计口径,不提供 R 对象结构、公式接口、绘图及 S3 方法的等价实现。
- 参考输入均为人工构造或匿名数据,不包含真实患者数据。
- 上游 R 包仅作外部数值参考,未复制或翻译其源码。实现依据论文与公开接口描述独立完成,来源记录在
catalog/methods.json。 - 各方法尚未覆盖的路径见迁移进展与对应方法页。
- 本项目为研究原型,不构成经监管验证的临床统计软件。用于正式分析前应自行核对结果。
贡献
问题反馈与代码贡献通过 Issue 和 Pull Request 提交,流程见贡献指南。新增或扩展方法时,需同时提供 R 参考脚本、版本化快照、测试与文档,并更新 catalog/progress.json。
许可
MIT © 2026 xiangjiawei1234-prog
Metadata
Release files for biomed-parity 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| biomed_parity-0.1.1.tar.gz | 244.7 kB | With provenance | Details for biomed_parity-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| biomed_parity-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for biomed_parity-0.1.1-py3-none-any.whl |
Total release size: 302.0 kB
Release files / biomed_parity-0.1.1.tar.gz
| Download URL | biomed_parity-0.1.1.tar.gz |
|---|---|
| Size | 244.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b246e7c3386689c7c05341415eef7eb25fc463ae50db88eb5ed4675ec17e88fc
|
|
BLAKE2b-256 checksum How to use checksums |
72794cd58984125f7dfaa379e1bbea054f906c8689104d768f348f4f5dee619c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.
Transparency logRelease files / biomed_parity-0.1.1-py3-none-any.whl
| Download URL | biomed_parity-0.1.1-py3-none-any.whl |
|---|---|
| Size | 57.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
674d3c5e0d9750c71b86230cba90f900489aec6096535b3dd43efc6a209cd5a1
|
|
BLAKE2b-256 checksum How to use checksums |
3d3f318400c6de5776f4b994b03e6747e1c7086780d350c9d5792a1950267a9b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.
Transparency logSecurity for biomed-parity 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for biomed_parity-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.