hinna0818/ukbanalytica_v2/ukbsci-preprocess
Claude Code and agent skill by hinna0818/ukbanalytica_v2
- community
Checking that the SKILL.md file is still in the repository.
Variable cleaning and feature construction for UK Biobank Research Analysis Platform (RAP) cohorts using UKBAnalytica. Negative-code sanitation (ukb_clean_missing), unified preprocessing with predefined variable sets (preprocess_baseline, prepare_analysis_dataset), composite variable builders (calculate_blood_pressure, calculate_air_pollution, calculate_diet_score), and curated variable-set lookups (get_variable_set, get_variable_sets, get_variable_info). Use this skill when the user asks to clean UKB negative-codes (-1, -3, -7, …), derive blood pressure / air pollution / diet score, compose an analysis-ready table, or look up predefined UKB variable sets. Triggers: UKB preprocessing, variable cleaning, derive BP, air pollution exposure, diet score, negative code, UKB 变量预处理, 缺失码处理, 复合变量, /ukbsci-preprocess. 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-preprocessSKILL.md
ukbsci-preprocess — UKB variable cleaning & composite-feature builders
0. RAP guardrails
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.
The cleaned cohort is participant-level. Stay inside /mnt/project/.... Summary statistics, missingness counts, and pre-vs-post sanity tables are aggregate and may be shared with the local agent.
1. When to load
- Convert UKB negative sentinel codes (-1, -2, -3, -7, -9, -10, -11, -13,
-15) to NA.
- Build composite variables: averaged blood pressure, averaged air pollution,
diet score.
- Apply a predefined variable set (e.g.
clinical_core) to a freshly
extracted RAP table.
- Wrap up preprocessing + optional imputation in one call
(prepare_analysis_dataset).
2. When NOT to load
- Pulling fields off RAP →
ukbsci-rap-extract. - Multiple imputation (more than the optional flag here) →
ukbsci-imputation.
- Defining disease cases / survival outcome →
ukbsci-cohort.
3. Prerequisites
4. Pipeline
Phase 1 — Browse predefined variables
The catalogues cover: demographics, anthropometrics, lifestyle, socioeconomic, blood_pressure, medications, biomarkers, pollution, diet.
Phase 2 — Sanitize negative codes
This is the first transformation. Run it before computing composite variables — otherwise the means / scores are silently corrupted by sentinels.
Phase 3 — Build composite variables
Phase 4 — Unified call (preprocess_baseline)
For routine workflows:
preprocess_baseline() understands the same variable names as get_variable_info(); passing a name not in the catalogue raises an error.
Phase 5 — Optional imputation
For full multiple-imputation model fitting and pooling, use ukbsci-imputation.
5. Common pitfalls
- Order matters. Always
ukb_clean_missing()before any composite
variable; otherwise sentinel codes contaminate the means.
- `calculate_diet_score()` rounds to one decimal place in some
versions. If you need higher precision for downstream Cox, scale the raw components yourself.
- `prefer = "manual"` in
calculate_blood_pressure()swaps the
precedence — handy if your cohort has more manual readings than automated.
- `na_handling = "partial"` in
calculate_diet_score()averages
available components and scales — useful but introduces a different missingness mechanism. Document it explicitly.
- `missing_action = "drop"` in
preprocess_baseline()removes any
row with any NA in the listed variables. Confirm this is what the user wants, especially for high-dimensional feature sets.
- Custom mappings.
custom_mapping = list(my_alias = "p123_i0")
lets you rename without touching the catalogue. Useful for non-standard fields (e.g. derived imaging metrics).
- Predefined variables can drift. When UKB releases new fields, the
catalogue is updated. Run get_variable_info() interactively before freezing scripts.
6. Key functions
| Function | Purpose | |
|---|---|---|
ukb_clean_missing(df, cols = NULL, invalid_codes = c(-1,-3,-7,-9,-11,-13,-15)) | Replace sentinel codes with NA | |
calculate_blood_pressure(df, type = c("sbp","dbp"), prefer = c("auto","manual")) | Mean BP across readings | |
calculate_air_pollution(df, pollutants = c("NO2","PM10","PM2.5","NOx")) | Time-averaged exposures | |
calculate_diet_score(df, components = c("fruit","vegetable","fish","meat","cereal","milk"), na_handling = c("strict","partial")) | 0–7 healthy diet score | |
preprocess_baseline(df, variables, custom_mapping = NULL, missing_action = c("keep","drop"), invalid_codes = c(-1,-3)) | Unified pipeline using predefined variable map | |
get_variable_info(category = "all") | Catalogue rows | |
get_variable_set(set, output = c("data.frame","field_id","ukb_col")) | One set | |
get_variable_sets(set = NULL, category = NULL) | All sets with filter |
See `references/variable-catalog.md` for the 9 categories and example variables.
7. Related skills
| Skill | When | |
|---|---|---|
ukbsci-rap-extract | Get the raw fields first. | |
ukbsci-cohort | Build outcomes from the cleaned table. | |
ukbsci-baseline | Table 1 of the cleaned cohort. | |
ukbsci-imputation | Full MI pooling (vs. the one-shot option here). |
8. References
9 categories and what's in each
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckinginst/skills/UKBAnalytica_skills/ukbsci-preprocess/SKILL.md
Popularity
- Repository stars
- 35
- 7-day trend score
- 18
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 12 Aug 2026, 2 months ago.
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-preprocess)