Skip to main content

A pandas-first, auditable meta-analysis library for Python

Project description

PyMetaAnalysis

CI Documentation License: MIT

PyMetaAnalysis is an early-stage, pandas-first Python library for conventional study-level meta-analysis. It accepts DataFrames, NumPy arrays, and ordinary Python sequences, then returns immutable, auditable result objects containing study effects, exclusions, weights, method choices, diagnostics, provenance, and structured reports.

Early-stage: the API may change during the 0.x series. Consequential results should be reviewed against the analysis protocol and independently checked.

Install

python -m pip install PyMetaAnalysis

Install optional Matplotlib plotting support with:

python -m pip install "PyMetaAnalysis[plot]"

The distribution name is PyMetaAnalysis; the import name is meta_analyze.

Quick start

import meta_analyze as ma

result = ma.meta_analysis(
    effect=[0.12, 0.35, -0.08, 0.21],
    variance=[0.04, 0.06, 0.03, 0.05],
    study=["Trial A", "Trial B", "Trial C", "Trial D"],
    model="random",
    tau2_method="REML",
)

print(result.summary())
print(result.study_results)

DataFrame column names work directly:

result = ma.meta_analysis(
    studies,
    effect="effect",
    variance="variance",
    study="citation",
    subgroup="region",
)

Omit study= to use the DataFrame index. Supplying subgroup= returns a dedicated result containing group fits, the overall fit, and a formal test for subgroup differences.

Supported analyses

Input Effects Pooling/models
Effect + sampling variance or standard error Generic Common/random inverse variance
Two-group events + totals OR, RR, RD Common MH OR/RR; common/random IV
Two-group means + SDs + sizes MD, Hedges' g Common/random inverse variance

Random-effects inverse-variance models support REML (default), Paule-Mandel, and DerSimonian-Laird tau-squared estimators. Mean confidence intervals support the normal default plus unmodified and safeguarded Hartung-Knapp variants. Eligible random-effects fits include an HTS prediction interval.

Generic analyses accept exactly one of variance= or standard_error=. Standard errors are squared internally and the conversion is recorded in the result provenance.

Sparse binary behavior is explicit: study-level and Mantel-Haenszel continuity corrections are separate, relative-effect double-zero/double-all rows remain visible as exclusions, and RD exposes rd_zero_variance="correct" | "exclude".

Inspect and report

result.estimate
result.display_estimate
result.ci
result.tau2
result.i2
result.i2_method
result.diagnostics
result.provenance

methods_text = result.method_details()
report = result.report()
payload = report.to_dict()
json_text = report.to_json()
markdown = report.to_markdown()

OR and RR remain on the log model scale in auditable numeric attributes; display_estimate, display_ci, and display_prediction_interval provide exponentiated ratios.

Rows excluded by missing-value or sparse-data policies remain in study_results with a stable row_id, included=False, and an exclusion_reason.

Sensitivity and plots

leave_one_out = result.leave_one_out().to_dataframe()
cumulative = result.cumulative(order="publication_year").to_dataframe()

ax = result.forest(show_prediction_interval=True)
ax = result.funnel()

Plotting methods return Matplotlib axes and never call show(). Funnel plots are descriptive small-study-effect diagnostics, not proof of publication bias.

Documentation

The complete documentation is published at zhaoboding.github.io/PyMetaAnalysis.

An executable end-to-end notebook uses synthetic data to demonstrate analysis, provenance, reporting, sensitivity, and plotting.

Build the complete site locally with:

python -m pip install ".[docs]"
python -m mkdocs serve

Validation status

The test suite combines hand calculations, statistical invariants, numerical edge cases, and committed R metafor reference fixtures. CI covers Python 3.10–3.13, declared dependency lower bounds, strict typing/linting, docs, and distribution builds.

This is independent cross-software validation, not a formal external statistical audit. See validation for exact coverage.

Contributing

See CONTRIBUTING.md and the full development guide. Statistical changes require formula documentation, boundary tests, and an independent comparison where available.

Security-sensitive reports should follow SECURITY.md.

License

MIT

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

pymetaanalysis-0.2.1.tar.gz (114.4 kB view details)

Uploaded Source

Built Distribution

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

pymetaanalysis-0.2.1-py3-none-any.whl (58.1 kB view details)

Uploaded Python 3

File details

Details for the file pymetaanalysis-0.2.1.tar.gz.

File metadata

  • Download URL: pymetaanalysis-0.2.1.tar.gz
  • Upload date:
  • Size: 114.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pymetaanalysis-0.2.1.tar.gz
Algorithm Hash digest
SHA256 6278cc1a0a6968902b8b407e0f4e76dfd47417876612b5fe96496f0b61dd4437
MD5 721c6cf1adf56eac8315275d3c95e947
BLAKE2b-256 3c4fb32072ff40c7be6566db425adde0f002a504391f0c2c840d007c0689d833

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymetaanalysis-0.2.1.tar.gz:

Publisher: release.yml on ZhaoboDing/PyMetaAnalysis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pymetaanalysis-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pymetaanalysis-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 58.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pymetaanalysis-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 56077465432e8989abc66273078ade3d4ff548d7755dee4bc83c00f4cb270751
MD5 f43b7058dd60a68e5da3601a9f68f1c8
BLAKE2b-256 686ff6762b079ec01c87cd3ff5c0908af99bc2df6b96c81d266206faf9619396

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymetaanalysis-0.2.1-py3-none-any.whl:

Publisher: release.yml on ZhaoboDing/PyMetaAnalysis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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