
AI for Clinical Research: How to Pull Sample Sizes, Primary Endpoints, and Hazard Ratios From PubMed Studies
On this page
- Manual clinical evidence tables break down because endpoint phrasing varies across journals and abstracts pack multiple statistics into a single dense paragraph.
- Semantic search across peer-reviewed literature and clinical preprints retrieves the right trials in one pass without brittle keyword queries.
- Enforcing a strict extraction schema with explicit null defaults prevents sample sizes, event rates, hazard ratios, and follow-up periods from drifting across columns.
- Keep peer-reviewed articles and preprints clearly tagged, and use DeepResearch when you need a finished comparison brief instead of raw extracted rows.
If you're an agent: Set up Valyu and make your first search.
If you're a human: Create an account and get an API key.
MCP onboarding: Connect to https://mcp.valyu.ai/mcp and follow the MCP setup guide.
The Tuesday morning evidence-table bottleneck
If you work in biomedical research, medical affairs, or biotech equity analysis, you know this request by heart.
Someone asks for a clean table covering every major randomized trial in a drug class over the last five years: sample size, primary endpoint, hazard ratio, confidence interval, and follow-up duration.
Two hours later you have 37 PubMed tabs open, four paywalled PDFs, and a spreadsheet where half the rows mix relative risk reduction with absolute event rates.
Pasting the question into an ungrounded chatbot makes the problem harder to spot. Without primary retrieval, models routinely blend figures across neighboring trials, drop confidence intervals, or substitute a subgroup result for the primary endpoint.
This guide lays out a repeatable workflow to pull auditable trial metrics from PubMed and medRxiv using Valyu Search and DeepResearch, illustrated with a worked row from the published SELECT cardiovascular outcomes trial.
Three reasons naive PubMed scripts break
Building a trustworthy clinical table sounds straightforward until three real-world quirks show up:
1. Keyword queries miss semantic endpoints
PubMed's E-utilities API expects exact Boolean and MeSH expressions. One trial reports "3-point MACE," while the next writes "a composite of death from cardiovascular causes, nonfatal myocardial infarction, or nonfatal stroke." Miss one phrasing and you drop a pivotal study.
2. Abstracts pack too many numbers into one paragraph
A single randomized-trial abstract often lists total enrollment, per-arm counts, primary event percentages, a hazard ratio, a 95% confidence interval, mean treatment exposure, and mean follow-up side by side. Without a strict extraction schema, those numbers slide into the wrong columns.
3. Peer-reviewed journals lag preprints
Searching PubMed alone misses late-breaking clinical readouts sitting on medRxiv. Searching both without tracking peer-review status mixes unrefereed preprints into journal-grade evidence.
Step 1: Retrieve candidate trials across PubMed and medRxiv
Instead of maintaining an E-utilities XML parser alongside a separate preprint scraper, query valyu/valyu-pubmed (37M+ papers) and valyu/valyu-medrxiv (80K+ clinical preprints) together with date bounds and abstracts enabled.
import osfrom valyu import Valyuvalyu = Valyu(api_key=os.environ["VALYU_API_KEY"])results = valyu.search("randomized placebo-controlled cardiovascular outcomes trial ""GLP-1 receptor agonist primary MACE endpoint hazard ratio",included_sources=["valyu/valyu-pubmed", "valyu/valyu-medrxiv"],start_date="2021-01-01",max_num_results=20,include_abstracts=True,)if not results.success:raise RuntimeError("PubMed literature search failed")for item in results.results:print(f"{item.title}\n Source: {item.source} | URL: {item.url}\n")
Scoping included_sources to primary literature keeps commentary blogs, investor decks, and press releases out of your candidate pool while semantic matching captures endpoint synonyms automatically.
Step 2: Lock every metric to an explicit JSON schema
Pass only the retrieved abstracts and passages into your extraction step, and instruct the parser to emit null whenever a paper omits a field. Never allow fallback guesses from model memory.
{"study_name": "string | null","pmid_or_doi": "string","peer_reviewed": "boolean","population": "string","total_n": "integer | null","arm_breakdown": "string | null","primary_endpoint": "string","primary_event_rates": "string | null","hazard_ratio": "number | null","ci_95": "string | null","p_value": "string | null","mean_or_median_followup": "string | null","source_url": "string"}
Worked example: the SELECT trial
Applied to the published SELECT trial (Lincoff et al., New England Journal of Medicine, 2023; PMID: 37952131; DOI 10.1056/NEJMoa2307563), the schema produces an exact, auditable row:
| Field | Extracted Value |
|---|---|
| Study | SELECT (Lincoff et al., NEJM 2023) |
| Identifier | PMID: 37952131 / 10.1056/NEJMoa2307563 |
| Peer-Reviewed | true (PubMed) |
| Population | Adults aged >= 45 with preexisting CVD and BMI >= 27, without diabetes |
| Total `n` | 17,604 ( 8,803 semaglutide 2.4 mg weekly vs. 8,801 placebo) |
| Primary Endpoint | Composite of CV death, nonfatal MI, or nonfatal stroke |
| Event Rates | 6.5% (semaglutide) vs. 8.0% (placebo) |
| Effect Size | HR 0.80 ( 95% CI, 0.72 to 0.90 ; P < 0.001 ) |
| Follow-Up | Mean follow-up 39.8 months (mean treatment exposure 34.2 months ) |
Notice what stays clean here: follow-up duration (39.8 months) stays separate from treatment exposure (34.2 months), and the population boundary (without diabetes, BMI >= 27, age >= 45) travels with the row so nobody misstates who the trial enrolled.
Step 3: Add four guardrails before exporting
Before your table goes into a CSV, manuscript, or slide deck, enforce four simple pipeline rules:
- Tag preprints explicitly. Mark every
valyu/valyu-medrxivrecord aspeer_reviewed: falseso reviewers can filter them cleanly from published journal trials. - Pair relative and absolute numbers. An HR of
0.80means a 20% relative reduction, yet the clinical impact depends on whether event rates moved from6.5%to8.0%(1.5 percentage points) or from25%to31%. - Isolate subgroup results. Store age, sex, or biomarker subgroup HRs in a dedicated
subgroup_notesfield so they never overwrite the trial-wide primary outcome. - Prefer `null` over interpolation. When an abstract omits a confidence interval or arm count, leave the field
nulland flag the row for full-text or registry follow-up.
Step 4: Generate a cited evidence brief with DeepResearch
When a stakeholder wants a finished Markdown comparison report with inline citations and trial-design commentary rather than raw JSON rows, run the synthesis loop with Valyu DeepResearch:
task = valyu.deepresearch.create(query=("Build a structured Markdown comparison table of major randomized ""cardiovascular outcomes trials for GLP-1 receptor agonists published ""since 2021. For each trial report PMID/DOI, peer-reviewed status, ""sample size, eligibility population, primary endpoint, event rates, ""hazard ratio with 95% CI, p-value, and follow-up duration. Leave ""unreported fields blank rather than estimating."),mode="fast",output_formats=["markdown"],)if not task.success or not task.deepresearch_id:raise RuntimeError("DeepResearch task creation was not confirmed")# Persist task.deepresearch_id in your workflow before polling for completion.status = valyu.deepresearch.status(task.deepresearch_id)if status.success and status.status == "completed":evidence_brief = {"markdown": status.output, "sources": status.sources}
Dataset coverage and refresh cadence
| Dataset | Coverage | Refresh Cadence | Best Use |
|---|---|---|---|
| valyu/valyu-pubmed | 37M+ papers | Monthly | Peer-reviewed biomedical literature |
| valyu/valyu-medrxiv | 80K+ preprints | Monthly | Recent clinical preprints before journal publication |
| valyu/valyu-clinical-trials | 500K+ studies | Real-time | Breaking registry updates and full protocol fields |
If a trial was presented at ACC, AHA, or ASCO yesterday and has not reached monthly literature indexing yet, include valyu/valyu-clinical-trials or web search while keeping peer-reviewed status clearly labeled.
Frequently Asked Questions
Why use semantic search over PubMed instead of querying NCBI E-utilities directly?
NCBI E-utilities requires exact Boolean and MeSH syntax and caps traffic at 3 requests per second without an API key (or 10 requests per second with a free NCBI API key) before returning HTTP 429 errors. Semantic retrieval over valyu/valyu-pubmed (37M+ citations) matches endpoint phrasing variations automatically in a single call alongside valyu/valyu-medrxiv.
Why should an evidence table capture both the hazard ratio and absolute event rates?
Relative metrics alone can overstate clinical impact when baseline event rates are low. In the SELECT trial (PMID: 37952131, n = 17,604), a hazard ratio of `0.80` (95% CI 0.72 to 0.90; P < 0.001) reflects primary endpoint rates of `6.5%` vs. `8.0%`, an absolute risk reduction of 1.5 percentage points (roughly 67 patients treated over a mean 39.8 months to prevent one primary event). Keeping both columns side by side prevents misreading the effect size.
How should pipelines handle medRxiv preprints alongside peer-reviewed PubMed trials?
Query both sources together so late-breaking clinical studies do not slip through the cracks, then tag every valyu/valyu-medrxiv row with peer_reviewed: false. Preprint endpoints, enrollment counts, and subgroup estimates can shift during peer review and should stay clearly separated from journal publications.
What if an abstract omits confidence intervals or per-arm sample sizes?
Require null defaults in your extraction schema instead of letting an LLM infer missing figures. Route any row with a null confidence interval or missing arm split to full-text verification or a real-time lookup against valyu/valyu-clinical-trials (500K+ trials).
Next steps
Start automating your clinical evidence tables with the Valyu Python SDK Search docs, or run a cited multi-trial synthesis directly through Valyu DeepResearch.
Related Blogs
Clinical Trial AI Agent Workflows: Automate Trial Tracking and Readout Analysis
AI for Literature Review: 6 Jobs AI Agents Do for Researchers
How to Run a Literature Review in Claude or ChatGPT with Verified Citations
How to Build a Biomedical Research Agent with PubMed and ClinicalTrials.gov
More from the blog





Valyu Add
Join 12,000+ professionals and knowledge workers.
Valyu Add is a free weekly research briefing for builders, investors and operators. Every issue is sourced, cited and verified with Valyu DeepResearch.
