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.0.tar.gz (114.2 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.0-py3-none-any.whl (58.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pymetaanalysis-0.2.0.tar.gz
  • Upload date:
  • Size: 114.2 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.0.tar.gz
Algorithm Hash digest
SHA256 f22b11185630ad49e4725a7f6111fc71ab8b15065ecb99086fdf80f7de00f614
MD5 a962cf3346d77383ef9efe5010b3df05
BLAKE2b-256 6de1396f2d6a32b2a0d87d580002cc10c3d39398749db0f070709116e5bccbb1

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pymetaanalysis-0.2.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a8a43e20411eea1bd4cdce8f8ae8e22c261a0b6ae562cea3a88d4c181d9d0dd9
MD5 363475a57f305fb5bd9f887ca0168b4e
BLAKE2b-256 36f228616a73005d0d62881a1ea2c893e584742e5b3643885b68e6bb9b184286

See more details on using hashes here.

Provenance

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