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 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.

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.1.0.tar.gz (111.9 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.1.0-py3-none-any.whl (57.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pymetaanalysis-0.1.0.tar.gz
Algorithm Hash digest
SHA256 12734335a90209d899b073b2a9d578bd3201c940b90fcbdf9cc39c9072ba4cf7
MD5 b4f98ce793a75d964c18966acdd5828e
BLAKE2b-256 6f0fd0b800bb506ed48b1638b5880a846b080d9c7529d2a44b8a87d0eea91f5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymetaanalysis-0.1.0.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.1.0-py3-none-any.whl.

File metadata

  • Download URL: pymetaanalysis-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 57.2 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3bbf2ab236b90c84fe98beb3248a143708ddf878bc35e7278c62c0e2d139913d
MD5 ccbec860f8cdcacb956f5079db6bd8fb
BLAKE2b-256 773c82e0e27552d450903415fb60b5ab6509ca8f0a6509086e011e37cd058d7c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pymetaanalysis-0.1.0-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