skills/43-wentorai-research-plugins/skills/domains/pharma/pharmacovigilance-guide/SKILL.md
Adverse drug event detection, safety signal mining, and drug monitoring
npx skillsauth add brycewang-stanford/Awesome-Agent-Skills-for-Empirical-Research pharmacovigilance-guideInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
A skill for computational pharmacovigilance research, covering adverse drug event (ADE) databases, signal detection algorithms, disproportionality analysis, and safety surveillance methods used in post-market drug monitoring.
| Database | Operator | Coverage | Access | |----------|----------|----------|--------| | FAERS (FDA Adverse Event Reporting System) | FDA | US spontaneous reports | Free quarterly downloads | | EudraVigilance | EMA | European reports | Research access via application | | VigiBase | WHO-UMC | Global (150+ countries) | Research license | | VAERS | CDC/FDA | US vaccine adverse events | Free download | | MAUDE | FDA | Medical device reports | Free download |
import pandas as pd
import zipfile
import os
def load_faers_quarter(data_dir: str, year: int, quarter: int) -> dict:
"""
Load FAERS quarterly data files into DataFrames.
Downloads available from: fis.fda.gov/extensions/FPD-QDE-FAERS/FPD-QDE-FAERS.html
Returns dict of DataFrames for each file type.
"""
prefix = f"faers_ascii_{year}Q{quarter}"
tables = {}
file_map = {
"DEMO": "demographics", # Patient demographics
"DRUG": "drugs", # Drug information
"REAC": "reactions", # Adverse reactions (MedDRA terms)
"OUTC": "outcomes", # Patient outcomes
"INDI": "indications", # Drug indications
"THER": "therapy", # Therapy dates
"RPSR": "report_sources", # Report source
}
for suffix, name in file_map.items():
filepath = os.path.join(data_dir, f"{suffix}{year}Q{quarter}.txt")
if os.path.exists(filepath):
tables[name] = pd.read_csv(
filepath, sep="$", encoding="latin-1",
low_memory=False, on_error="warn"
)
return tables
# Example: Load and inspect
faers = load_faers_quarter("./faers_data", 2024, 3)
print(f"Reports: {len(faers['demographics']):,}")
print(f"Drug-reaction pairs: {len(faers['reactions']):,}")
Disproportionality measures compare the observed frequency of a drug-event pair against the expected frequency under independence:
import numpy as np
from scipy.stats import chi2
def compute_disproportionality(a: int, b: int, c: int, d: int) -> dict:
"""
Compute disproportionality measures from a 2x2 contingency table:
Event+ Event-
Drug+ a b
Drug- c d
a: reports with both the drug and the event
b: reports with the drug but not the event
c: reports with the event but not the drug
d: reports with neither
"""
n = a + b + c + d
expected = (a + b) * (a + c) / n if n > 0 else 0
# Reporting Odds Ratio (ROR)
ror = (a * d) / (b * c) if b * c > 0 else float("inf")
ln_ror = np.log(ror) if ror > 0 and ror != float("inf") else 0
se_ln_ror = np.sqrt(1/a + 1/b + 1/c + 1/d) if min(a, b, c, d) > 0 else float("inf")
ror_lower = np.exp(ln_ror - 1.96 * se_ln_ror)
# Proportional Reporting Ratio (PRR)
prr = (a / (a + b)) / (c / (c + d)) if (a + b) > 0 and (c + d) > 0 else 0
# Information Component (IC, Bayesian shrinkage)
ic = np.log2((a + 0.5) / (expected + 0.5)) if expected > 0 else 0
# Chi-squared with Yates correction
chi2_val = (n * (abs(a * d - b * c) - n / 2) ** 2) / (
(a + b) * (c + d) * (a + c) * (b + d)
) if min(a + b, c + d, a + c, b + d) > 0 else 0
return {
"a": a, "b": b, "c": c, "d": d,
"expected": round(expected, 2),
"ROR": round(ror, 3),
"ROR_lower_95": round(ror_lower, 3),
"PRR": round(prr, 3),
"IC": round(ic, 3),
"chi2": round(chi2_val, 3),
"signal": ror_lower > 1 and a >= 3 and chi2_val > 3.84,
}
The MGPS method (used by FDA) applies empirical Bayesian shrinkage to stabilize estimates for rare events:
def empirical_bayes_geometric_mean(observed: np.ndarray,
expected: np.ndarray) -> np.ndarray:
"""
Simplified EBGM computation.
Shrinks observed/expected ratios toward the overall mean,
reducing false positives from small counts.
"""
# Raw ratio
rr = observed / np.maximum(expected, 0.01)
# Empirical Bayes shrinkage (simplified two-component mixture)
# Full implementation uses EM algorithm to fit mixture of gammas
global_mean = np.mean(rr)
shrinkage = expected / (expected + 1) # more shrinkage for small expected
ebgm = shrinkage * rr + (1 - shrinkage) * global_mean
return ebgm
MedDRA provides the standardized terminology for adverse event coding:
Hierarchy (5 levels):
System Organ Class (SOC) -- e.g., "Cardiac disorders"
High Level Group Term (HLGT) -- e.g., "Cardiac arrhythmias"
High Level Term (HLT) -- e.g., "Supraventricular tachyarrhythmias"
Preferred Term (PT) -- e.g., "Atrial fibrillation"
Lowest Level Term (LLT) -- e.g., "Auricular fibrillation"
Pre-defined search strategies for known safety topics:
def time_to_onset_analysis(drug_start_dates: pd.Series,
event_dates: pd.Series) -> dict:
"""
Analyze time-to-onset distribution for a drug-event pair.
Useful for distinguishing causal signals from coincidental reports.
"""
ttp = (event_dates - drug_start_dates).dt.days
ttp = ttp[ttp >= 0] # exclude negative (data quality issue)
return {
"n_reports": len(ttp),
"median_days": ttp.median(),
"mean_days": ttp.mean(),
"q25_days": ttp.quantile(0.25),
"q75_days": ttp.quantile(0.75),
"within_30_days_pct": (ttp <= 30).mean() * 100,
"within_90_days_pct": (ttp <= 90).mean() * 100,
}
Standard frameworks for evaluating whether a drug caused an adverse event:
| Method | Type | Key Criteria | |--------|------|-------------| | WHO-UMC | Algorithmic | Temporal, dechallenge, rechallenge, alternative causes | | Naranjo Score | Scoring scale | 10 questions, score 0-13 (definite/probable/possible/doubtful) | | Bradford Hill | Principles | Strength, consistency, specificity, temporality, biological gradient |
development
Conduct rigorous thematic analysis (TA) of qualitative data following Braun and Clarke's (2006) six-phase framework. Use whenever the user mentions 'thematic analysis', 'TA', 'Braun and Clarke', 'qualitative coding', 'identifying themes', or asks for help analysing interviews, focus groups, open-ended survey responses, or transcripts to identify patterns. Also trigger for questions about inductive vs theoretical coding, semantic vs latent themes, essentialist vs constructionist epistemology, building a thematic map, or writing up a qualitative findings section. Covers all six phases, the four upfront analytic decisions, the 15-point quality checklist, and the five common pitfalls. Produces a Word document write-up and an annotated thematic map. Does NOT cover IPA, grounded theory, discourse analysis, conversation analysis, or narrative analysis — use a different method for those.
development
Guide users through writing a systematic literature review (SLR) following the PRISMA 2020 framework. Use this skill whenever the user mentions 'systematic review', 'systematic literature review', 'SLR', 'PRISMA', 'PRISMA 2020', 'PRISMA flow diagram', 'PRISMA checklist', or asks for help writing, structuring, or auditing a literature review that follows reporting guidelines. Also trigger when the user asks about inclusion/exclusion criteria for a review, search strategies for databases like Scopus/WoS/PubMed, study selection processes, risk of bias assessment, or narrative synthesis for a review paper. This skill covers the full PRISMA 2020 checklist (27 items), produces a Word document manuscript in strict journal article format, generates an annotated PRISMA flow diagram, and enforces APA 7th Edition referencing throughout. It does NOT cover meta-analysis or statistical pooling. By Chuah Kee Man.
testing
Performs placebo-in-time sensitivity analysis with hierarchical null model and optional Bayesian assurance. Use when checking model robustness, verifying lack of pre-intervention effects, or estimating study power.
data-ai
Fit, summarize, plot, and interpret a chosen CausalPy experiment. Use after the causal method has been selected, including when configuring PyMC/sklearn models and scale-aware custom priors.