hinna0818/ukbanalytica_v2/ukbsci-cohort
Claude Code and agent skill by hinna0818/ukbanalytica_v2
- community
Checking that the SKILL.md file is still in the repository.
Build a UK Biobank disease cohort from a phenotype table extracted on the Research Analysis Platform (RAP), using the UKBAnalytica R package. Covers disease-definition construction and catalog lookup (get_predefined_diseases, get_disease_catalog, get_pomegranate_diseases, create_disease_definition, combine_disease_definitions), source parsers (parse_icd10_diagnoses, parse_icd9_diagnoses, parse_opcs4_procedures, parse_cancer_registry, parse_death_records, parse_self_reported_illnesses), multi-source case extraction (extract_cases_by_source, extract_disease_diagnosis, extract_disease_history, extract_disease_history_sensitivity, compare_data_sources), reusable follow-up time skeletons (ukb_time_skeleton), and the Cox-ready dataset builder build_survival_dataset() with prevalent vs incident separation and follow-up time computation, plus select_incident_by_years() for time-window stratification. Use this skill when the user asks to define a UKB disease phenotype, inspect curated/Pomegranate diagnostic codes, separate prevalent from incident cases, build a survival dataset, compare diagnostic sources, or compute follow-up time. Triggers: UKB cohort, UKB disease definition, prevalent vs incident, survival dataset, build_survival_dataset, ICD10 phenotyping, UKB 队列, 病例定义, 生存数据集, /ukbsci-cohort. Hard rule: local agents must not read or inspect real UKB RAP participant-level data; generate scripts for RAP execution and interpret aggregate outputs only.
Install
npx vskill@latest install hinna0818/ukbanalytica_v2/ukbsci-cohortSKILL.md
ukbsci-cohort — UK Biobank disease cohort & survival dataset builder
0. RAP guardrails (must always hold)
Strict local-agent boundary: this skill is for script generation, workflow planning, package guidance, and interpretation of aggregate outputs. The agent must not read, inspect, summarize, or process real UK Biobank RAP participant-level data, including de-identified row-level tables, raw RAP fields, exact dates, per-row predictions, row-level SHAP matrices, screenshots, tracebacks, or logs containing row-level values. Generate scripts for the user to run inside RAP; only aggregate results or rendered figures may be shared back with the agent. See ../references/agent-privacy-boundary.md.
This skill assumes its input — the phenotype data.table — was extracted by `ukbsci-rap-extract` (or equivalent rap_* calls) and lives in RAP project storage. The same rules carry over:
- Inputs and outputs default to
/mnt/project/.... Do not emit code that
writes the cohort table or per-disease case files to a local laptop path.
- Aggregate results (cohort flow tables, Table 1, regression coefficients)
may be shared with the local agent. Per-participant tables are not.
- If the user asks "can I just run this locally with a small sample?", answer
with a simulated toy dataset — never a sample of real participants.
1. When to load this skill
- Define a UKB disease phenotype from scratch (
create_disease_definition)
or pick one of the pre-validated definitions (get_predefined_diseases).
- Combine multiple definitions into one composite endpoint
(combine_disease_definitions).
- Identify cases from one or several diagnostic sources (ICD-10, ICD-9, OPCS-4,
death registry, cancer registry, first-occurrence, self-report, UKB algorithmically-defined outcomes).
- Separate prevalent (baseline-or-earlier) from incident (post-baseline)
cases and compute follow-up time for Cox / competing-risks models.
- Run a sensitivity analysis where the definition source set varies.
- Stratify incident cases by years since enrollment (e.g. ≤5y vs >5y).
2. When NOT to load this skill
- The user has not extracted phenotype data yet → load `ukbsci-rap-extract`.
- The user wants to fit a regression / Cox model on the survival dataset →
load `ukbsci-regression` or `ukbsci-survival`.
- The user wants a Table 1 summary of the cohort → load `ukbsci-baseline`.
- The user wants propensity-score matching → load `ukbsci-propensity`.
3. Prerequisites
Required columns in the input data.table:
| Purpose | UKB field IDs / RAP columns | |
|---|---|---|
| Participant ID | eid | |
| Baseline date | p53_i0 (date of attending assessment centre, instance 0) | |
| ICD-10 | p41270 (concatenated codes) + p41280_a* (date array) | |
| ICD-9 | p41271 + p41281_a* | |
| OPCS-4 procedures | p41272 or p41272_a* + p41282_a* | |
| Death | p40000_i* (date) + p40001_i* (primary cause) + p40002_i*_a* (secondary causes) | |
| Cancer registry | p40005_i*, p40006_i*, p40011_i*, p40012_i* | |
| Self-report | p20002_i*_a* (codes) + p20008_i*_a* (year as fractional decimal) | |
| First Occurrence | UKB Category 1712 date fields (p131xxx) + source fields (p131xxx + 1) | |
| Algorithmic outcomes | UKB Category 42 date field (e.g. p42016 for COPD) + source field (p42017) |
The skill must inspect dt and warn the user about any source they request that is not represented in the columns.
4. Pipeline (4 phases)
Phase 1 — Pick or build disease definitions
Start with the curated catalogue. In UKBAnalytica 1.0.0, the curated library contains 86 analysis-ready disease definitions. The source-aware catalog also exposes 313 Pomegranate-derived definitions. The expanded union of curated and Pomegranate definitions currently contains 331 usable disease keys; the conservative intersection contains 56 shared keys.
Inspect exact code evidence before committing to an endpoint:
Use source = "curated" for protocol-driven analyses where stable manual definitions are preferred. Use source = "both", merge_type = "union" for endpoint discovery or sensitivity analysis. When the exact source matters, write the selected source and merge strategy into the analysis script.
Define a custom phenotype:
Custom cancer phenotype using histology + behaviour codes:
Combine definitions when you need composite endpoints:
Phase 2 — Parse source tables (optional inspection)
You normally don't call the parsers directly — extract_cases_by_source() does it for you. But for QC / debugging it is useful to know the schemas:
If a parser returns a 0-row table, the corresponding source columns were not present — warn the user before they request that source downstream.
Phase 3 — Extract cases (one disease, one source, or many of each)
3a. Single-disease diagnosis table — extract_disease_diagnosis()
Use this when the user wants a compact diagnosis table before building a full survival dataset.
3b. The flexible primitive — extract_cases_by_source()
diagnosis_source is the winning source per participant–disease (whichever gave the earliest valid date). For "Algorithm", it is further refined to "Algorithm_<source-code>".
3c. The history-only helper — extract_disease_history()
For "did the participant ever have disease X (per the chosen sources)?":
3d. Sensitivity variants — extract_disease_history_sensitivity()
For pre-baked sensitivity strata (ICD-10-only, ICD-10+ICD-9, all sources):
3e. Source-by-source comparison — compare_data_sources()
QC tool. Returns a per-disease table of how many cases each source uncovers and how much they overlap:
Phase 4 — Build reusable time skeleton, then Cox-ready dataset
For prospective analyses, first standardize the time backbone once and reuse it across disease endpoints.
admin_censor_date remains the database-level administrative censoring date. followup_end_date is participant-specific and uses the earliest of death, loss-to-follow-up, and administrative censoring.
The main entry point. Most user requests should resolve here.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckinginst/skills/UKBAnalytica_skills/ukbsci-cohort/SKILL.md
Popularity
- Repository stars
- 35
- 7-day trend score
- 18
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/hinna0818/ukbanalytica_v2/ukbsci-cohort)