Builds PaperTrail from the base skeleton into a full evidence-verification platform for the "Built with Claude: Life Sciences" hackathon (Builder Track). New named-user features (Build Beyond the Bench): - Lab Notebook Companion — rough bench notes -> structured, searchable, grounded experiment records (lib/labNotebook, /console/lab-notebook, migration 0059) - Clinical Trial Matcher — de-identified patient notes -> ranked eligible ClinicalTrials.gov trials with per-criterion inclusion/exclusion reasoning (lib/trialMatcher, /console/trial-matcher, migrations 0060) Platform: - Deterministic verification moat (biostats recompute, exact-span grounding) - 11 biomedical evidence engines (FAERS, GWAS, Open Targets, ChEMBL, ClinVar, PharmGKB, PubTator, DDI, repurposing, biomarker, unified verifier) - Evidence Intelligence (KG, dossier, provenance/export, RWE) + enterprise governance (RBAC, /api/v1 gateway, metering, audit chain, retention) - 17 OSS projects assimilated into native TypeScript on our stack (backend/engines retained + credited in NOTICE) - Multi-format upload (PDF/DOCX/XLSX/CSV/MD/TXT), logo, marketing site - Next.js 16 upgrade, benchmark harness (honest smoke-test caveat) Licensing: Apache-2.0 (LICENSE + NOTICE).
86 lines
3.2 KiB
Markdown
86 lines
3.2 KiB
Markdown
# PyMARE: Python Meta-Analysis & Regression Engine
|
|
A Python library for mixed-effects meta-regression (including meta-analysis).
|
|
|
|
[](https://pypi.python.org/pypi/pymare/)
|
|
[](https://pypi.python.org/pypi/pymare/)
|
|
[](https://opensource.org/licenses/MIT)
|
|
[](https://zenodo.org/badge/latestdoi/228903736)
|
|
[](http://pymare.readthedocs.io/en/latest/?badge=latest)
|
|

|
|
[](https://codecov.io/gh/neurostuff/pymare)
|
|
|
|
**PyMARE is alpha software under heavy development; we reserve the right to make major changes to the API.**
|
|
|
|
## Quickstart
|
|
Install PyMARE from PyPI:
|
|
```
|
|
pip install pymare
|
|
```
|
|
|
|
|
|
Or for the bleeding-edge GitHub version:
|
|
|
|
```
|
|
pip install git+https://github.com/neurostuff/pymare.git
|
|
```
|
|
|
|
Suppose we have parameter estimates from 8 studies, along with corresponding variances, and a single (fixed) covariate:
|
|
|
|
```python
|
|
y = np.array([-1, 0.5, 0.5, 0.5, 1, 1, 2, 10]) # study-level estimates
|
|
v = np.array([1, 1, 2.4, 0.5, 1, 1, 1.2, 1.5]) # study-level variances
|
|
X = np.array([1, 1, 2, 2, 4, 4, 2.8, 2.8]) # a fixed study-level covariate
|
|
```
|
|
|
|
We can conduct a mixed-effects meta-regression using restricted maximum-likelihood (ReML)estimation in PyMARE using the high-level `meta_regression` function:
|
|
|
|
```python
|
|
from pymare import meta_regression
|
|
|
|
result = meta_regression(y, v, X, names=['my_cov'], add_intercept=True,
|
|
method='REML')
|
|
print(result.to_df())
|
|
```
|
|
|
|
This produces the following output:
|
|
|
|
```
|
|
name estimate se z-score p-val ci_0.025 ci_0.975
|
|
0 intercept -0.106579 2.993715 -0.035601 0.971600 -5.974153 5.760994
|
|
1 my_cov 0.769961 1.113344 0.691575 0.489204 -1.412153 2.952075
|
|
```
|
|
|
|
Alternatively, we can achieve the same outcome using PyMARE's object-oriented API (which the `meta_regression` function wraps):
|
|
|
|
```python
|
|
|
|
from pymare import Dataset
|
|
from pymare.estimators import VarianceBasedLikelihoodEstimator
|
|
|
|
# A handy container we can pass to any estimator
|
|
dataset = Dataset(y, v, X)
|
|
# Estimator class for likelihood-based methods when variances are known
|
|
estimator = VarianceBasedLikelihoodEstimator(method='REML')
|
|
# All estimators expose a fit_dataset() method that takes a `Dataset`
|
|
# instance as the first (and usually only) argument.
|
|
estimator.fit_dataset(dataset)
|
|
# Post-fitting we can obtain a MetaRegressionResults instance via .summary()
|
|
results = estimator.summary()
|
|
# Print summary of results as a pandas DataFrame
|
|
print(result.to_df())
|
|
```
|
|
|
|
And if we want to be even more explicit, we can avoid the `Dataset` abstraction
|
|
entirely (though we'll lose some convenient validation checks):
|
|
|
|
```python
|
|
estimator = VarianceBasedLikelihoodEstimator(method='REML')
|
|
|
|
# X must be 2-d; this is one of the things the Dataset implicitly handles.
|
|
X = X[:, None]
|
|
|
|
estimator.fit(y, v, X)
|
|
|
|
results = estimator.summary()
|
|
```
|