6 Guide 3 — AI Research Experiment Agent
6.1 “Virtual Research Assistant”
6.2 The problem
Researchers — especially in biology, medicine and agriculture — struggle with:
- experimental design (controls, replicates, power),
- data analysis (QC, normalisation, differential analysis),
- coding (Python/R pipelines),
- statistics (which test, multiple-testing correction, effect sizes),
- reporting (figures, tables, a defensible Methods section).
A lab typically waits weeks for a bioinformatician or statistician.
6.3 The solution
An agent that manages the experiment from plan to report:
| Agent | Role | Output |
|---|---|---|
| Experiment Planner | Turns a one-line description into a design: groups, replicates, covariates, power notes, analysis plan | design.json |
| Analysis (Bioinformatics/Data) Agent | Runs QC, normalisation, differential analysis (e.g. control vs. treatment) using pandas/scipy | tables + figures |
| ML Agent | Trains baseline models (logistic regression, random forest), cross-validation, feature importance | ml_results.json, figures |
| Statistics Agent | Checks assumptions, corrects for multiple testing, flags bias/leakage, interprets effect sizes | stats_report.md |
| Report Writer | Produces the Methods + Results text and a reproducible notebook | methods_results.md, analysis_notebook.ipynb |
6.3.1 Example
Input: “I have RNA-seq data from heat-stressed rice (control vs heat, n=3 each).”
Output: design (control vs heat stress, n=3), QC summary, differential-expression table (log2FC, p, FDR), volcano plot, a random-forest classifier with CV accuracy, a statistics sanity report, and a Methods/Results section — plus a Jupyter notebook that reproduces everything.
6.4 Architecture — code does the math, the LLM does the reasoning
description ─► Experiment Planner (LLM, structured) ─► ExperimentDesign
│
data.csv (or synthetic demo) ─► Analysis Engine (pure Python: pandas/scipy/sklearn/statsmodels)
│ numbers, tables, figures
▼
Statistics Agent (LLM reads the numbers → assumptions, warnings)
│
▼
Report Writer (LLM → Methods & Results) + Notebook generator (code)
Why this split matters: LLMs are unreliable at arithmetic and p-values. All statistics are computed by deterministic Python; the LLM only plans, interprets and writes. This keeps results reproducible and defensible.
6.5 Build steps
| Step | File | What you learn |
|---|---|---|
| 1 | data.py |
Loading real CSVs or generating a synthetic omics-style dataset (genes × samples) |
| 2 | analysis.py |
QC, normalisation (log/CPM-like), t-tests per feature, BH-FDR, volcano plot, RF classifier with CV |
| 3 | agents.py |
Planner (structured), Statistics reviewer (structured), Report writer |
| 4 | notebook.py |
Generating a runnable .ipynb with nbformat |
| 5 | main.py |
CLI: --description, --data path.csv, --group-col, --demo |
Run (demo data):
python agent_03_research_experiment\main.py --description "RNA-seq of heat-stressed rice, control vs heat, n=3" --demoRun (your data):
python agent_03_research_experiment\main.py --description "..." --data mydata.csv --group-col condition6.6 Product extensions
- Domain plugins: RNA-seq (DESeq2 via rpy2 / pydeseq2), GWAS, metabolomics, field trials (ANOVA/mixed models), clinical trials (survival analysis), social science (regressions/SEM).
- Sandboxed code execution so the agent can write and run custom analysis code safely (Docker / Claude code-execution tool).
- Figure styling to journal specs; automatic figure legends.
- Lab data connectors: LIMS, Google Sheets, S3, sequencing cores.
- Power analysis & sample-size calculator at design time.
6.7 Market value
| Customer | Value | Price |
|---|---|---|
| Biology / medical / agriculture labs | Replace weeks of waiting for an analyst | $50–100/month per researcher; lab $5k/year |
| Core facilities & bioinformatics units | Handle 5× the projects | $20k–50k/year |
| Universities | Standardised, reproducible analysis for theses | $50k–150k/year |
| Pharma / agri-biotech R&D | Private deployment, custom pipelines, audit trails | $150k–500k/year |
This is the highest-value enterprise agent in the set because the alternative is hiring specialists.
6.8 How to sell it
- Free “analyse my CSV” demo (synthetic or uploaded, capped size).
- Core-facility partnership: give the facility a dashboard; they resell analysis to labs.
- Grant-budget line: position at $5k/year as a “bioinformatics support” line item in grants.
- Pharma/agri pilots: 3-month pilot on one dataset with a reproducibility report.
- Training: “Data analysis for biologists with AI agents” workshops (Codanics-style) → lab plans.
6.9 Risks & mitigations
| Risk | Mitigation |
|---|---|
| Wrong statistical test chosen | Statistics Agent checks assumptions and explains alternatives; rule-based defaults per data type |
| Data leakage in ML | Explicit CV pipeline; agent flags leakage patterns |
| Users trust numbers blindly | Every result carries method, n, test, correction; report includes “limitations” |
| Data privacy (clinical) | On-prem / VPC option; no raw data sent to the LLM — only summary statistics |
6.10 90-day roadmap
- Weeks 1–2: CLI with synthetic pipeline (this repo) → Weeks 3–6: CSV/Excel upload UI, figure export → Weeks 7–10: RNA-seq & field-trial plugins → Weeks 11–13: sandboxed custom code + notebook editor.
Codanics — Python ka Chilla: Build AI Agents
- Course: https://codanics.com/courses/python-ka-chilla-build-ai-agents/
- Website: https://codanics.com · YouTube: @codanics
- WhatsApp channel: https://whatsapp.com/channel/0029Va7nRDq3QxRzGqaQvS3r
- Complete free course: https://www.youtube.com/watch?v=UE3o-7KRNXs&list=PLaQmdklCcX40