AI agents in
statistical genetics
Research code, explicit assumptions,
reproducible checks.
Statistical geneticist, Broad Institute
Updated November 1, 2026
j / k to navigate / for contents n for notes
Tasks worth delegating
Implementation support
- Refactoring an existing R pipeline
- Writing argument parsers and job wrappers
- Tracing an error with a minimal example
Evidence to request
- A small, reviewable diff
- A reproducible test and its output
- Assumptions and unresolved questions
Evaluate the change with the same standards as any research code.
Model, agent, environment
- Model
- Generates responses from the supplied context.
- Agent
- Uses tools to inspect files, propose edits, and run permitted checks.
- Environment
- Controls file access, execution, network access, and credentials.
Review both the generated code and the actions the environment allows.
The research toolchain
- Editor
- Source files, diagnostics, diffs, and version control.
- Agent client
- Instructions, model choice, tool connections, and action approvals.
- Compute
- A documented R environment and the project’s approved execution location.
The selected client and account must fit the project’s data-access rules.
Copilot in a research workflow
- Context: point to the relevant implementation, tests, and package documentation.
- Scope: describe the change and its acceptance criteria.
- Tools: inspect enabled actions before allowing execution.
- Review: compare the diff and validate observable behavior.
Verify the controls available in your installed client and organization.
Project instructions
Record decisions the agent cannot reliably infer from the repository.
Analysis context
- Phenotype, sample definition, genome build
- Identifier and allele conventions
- Model assumptions and expected outputs
Execution context
- R dependencies and scheduler
- Input and output locations
- Required checks and restricted actions
Example: .github/copilot-instructions.md
A reusable context file
## Analysis contract
- State phenotype, ancestry, build, and effect allele.
- Preserve source data. Write to explicit derived paths.
- Check IDs, duplicates, missingness, and join cardinality.
## Implementation
- R is primary. Prefer data.table for large tables.
- Use loops when they improve clarity or performance.
- Record package versions and random seeds.
## Validation
- Start with synthetic data and a small test region.
- Report what was run and what remains unverified.A reviewable workflow
- InspectFind existing code, inputs, conventions, and prior results.
- PlanSpecify the model, change, outputs, and acceptance checks.
- ImplementKeep the change small enough to review.
- ValidateInspect failures, diagnostics, and scientific invariants.
- RecordSave the diff, command, environment, and limitations.
Permissions and checkpoints
Bounded routine work
- Read approved source files
- Edit a dedicated working copy
- Run tests on synthetic fixtures
Explicit project decisions
- Protected-data access and external transfer
- Large job arrays or paid services
- Source overwrites, publication, or deployment
Use enforceable controls and a defined task scope.
Code isolation with worktrees
# Development branch with its own checkout
git worktree add -b agent/variant-qc ../variant-qc
# Separate checkout of a committed analysis version
git worktree add --detach ../analysis-run HEAD
git -C ../analysis-run rev-parse HEADUse distinct output directories and keep the run checkout unchanged until jobs finish.
An analysis specification
Illustrative request
Adapt the existing gene-based rare-variant workflow for a specified phenotype and chr22 pilot. First confirm the genome build, genotype and annotation format, sample matching, null model, relatedness handling, and variant masks. Propose MAF/MAC and missingness checks. Stop before a full-cohort submission.
A method name and a list of covariates are only part of the specification.
Model choice by acceptance criteria
| Task | What to evaluate |
|---|---|
| Small refactor | Behavior preservation, tests, and a focused diff |
| Pipeline design | Assumptions, failure modes, and dependency reasoning |
| Statistical implementation | Agreement with a trusted reference and diagnostics |
Compare candidates on a representative task before expanding scope.
Data boundaries
- Start with
- Synthetic examples and a reviewed schema that contains no participant records.
- Review
- Prompts, terminal output, paths, logs, and tool responses before external transfer.
- Confirm
- The permitted data, destination, account, and execution environment.
Local execution can still call a remote model. Metadata may also be sensitive.
Validation before scale
- Inputs
- Unique IDs, sample counts, join cardinality, missingness, build, and allele orientation.
- Computation
- Synthetic fixtures, a small region, reference outputs, and failed edge cases.
- Inference
- Model diagnostics, multiplicity, LD/ancestry compatibility, and replication.
Association, colocalization, and experimental validation answer different questions.
Cost and usage
Copilot’s current individual billing uses AI credits, with consumption tied to model and token usage.
- Inspect the allowance and spending controls for the actual account.
- Supply focused context and reuse verified intermediate results.
- Bound long-running tasks with explicit completion criteria.
Check live billing documentation before budgeting a project.
A small, inspectable R check
library(data.table)
ids <- c("s01", "s02", "s03")
pheno <- data.table(id = rev(ids), y = c(3, 2, 1))
stopifnot(!anyDuplicated(pheno$id))
stopifnot(setequal(pheno$id, ids))
aligned <- pheno[data.table(id = ids), on = "id"]
stopifnot(identical(aligned$id, ids))
stopifnot(identical(aligned$y, c(1, 2, 3)))This synthetic fixture tests sample alignment. It does not validate an association model.
Bounded research automation
- One trigger: a scheduled check or a completed job.
- One input: an approved status file or endpoint.
- One output: a structured summary with provenance.
- One stop rule: completion, failure, or a resource limit.
Notifications should identify an actionable change and link to its evidence.
MCP connections
MCP standardizes how AI applications connect to tools and external systems.
Possible research uses
- Search a permitted literature source
- Read versioned reference metadata
- Retrieve an approved job status
Connection review
- Server owner and credentials
- Read/write permissions and payloads
- Source identifiers and retrieval date
A protocol connection does not establish source quality or data permission.
A first task for the lab
- Choose a bounded changeFor example, a sample-alignment check in one script.
- Document the contractInputs, outputs, dependencies, and acceptance criteria.
- Use synthetic fixturesInclude a passing case and a case that must fail.
- Review and recordSave the diff and test results before broader execution.
Discussion
Which part of your workflow has
the clearest acceptance test?