hinna0818/ukbanalytica_v2/ukbsci-rap-extract
Claude Code and agent skill by hinna0818/ukbanalytica_v2
- community
Checking that the SKILL.md file is still in the repository.
Discover UK Biobank fields and extract phenotype data from inside an authenticated UK Biobank Research Analysis Platform (RAP) session using the UKBAnalytica R package (rap_find_dataset, rap_list_fields, rap_plan_extract, rap_extract_pheno, rap_submit_extract, ukb_metadata_setup, ukb_search_fields, ukb_field_info, ukb_extract_fields, ukb_decode, ukb_check_rap_env, ukb_create_extraction_manifest, ukb_write_extraction_manifest). Use this skill when the user asks to search UKB fields, check the RAP environment, plan/run a phenotype extraction on RAP, create an extraction manifest, choose between dx extract_dataset (sync) and table-exporter (async), decode RAP column names or coded values, or build the upstream phenotype table that feeds ukbsci-cohort. Triggers: UK Biobank RAP extract, dx extract_dataset, table-exporter, UKB field search, RAP 提取, 字段搜索, 表型提取, /ukbsci-rap-extract. 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-rap-extractSKILL.md
ukbsci-rap-extract — UK Biobank RAP Phenotype Extraction
0. RAP guardrails (read before generating any code)
Required runtime. Every command in this skill assumes an authenticated R session running inside a UK Biobank RAP project (typically RAP JupyterLab → Terminal → R). The DNAnexus dx CLI must be on PATH and already logged in.
Strict local-agent boundary: this skill is for script generation, extraction 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 extracted phenotype files, de-identified row-level tables, raw RAP fields, exact dates, screenshots, tracebacks, or logs containing row-level values. Generate scripts for the user to run inside RAP; only public field-level metadata, extraction manifests without participant rows, aggregate results, or rendered figures may be shared back with the agent. See ../references/agent-privacy-boundary.md.
Forbidden actions (refuse or rewrite if the user asks):
| Forbidden | Correct alternative | |
|---|---|---|
dx download <participant-level file> -o ~/Downloads/... | Keep the file on RAP project storage. | |
Writing extracted phenotypes to local laptop paths (~/, C:\\, /Users/...) | Use /mnt/project/... or dx://project-...:/... paths. | |
read.csv("https://...participant-level...") | Phenotype data must originate from rap_extract_pheno() / rap_submit_extract(). | |
| Caching participant-level data outside the approved project | Restrict caches to RAP-controlled cache dirs (tools::R_user_dir("UKBAnalytica","cache") inside the RAP node). |
It is acceptable to download/copy:
- the UKB Data Dictionary and Codings table TSVs (public, field-level metadata only)
- a
field_ids.txtlist authored by the user - the manifest CSV emitted by
rap_plan_extract()(no participant rows)
Default output locations.
1. When to load this skill
- The user wants to find or describe a UK Biobank field by keyword, number,
or coding ID.
- The user wants to plan or execute an extraction from a RAP
.dataset
file.
- The user is unsure whether to use synchronous (`rap_extract_pheno`) or
asynchronous (`rap_submit_extract`) extraction.
- The user has a RAP CSV and needs to decode column names or coded values.
- The user is starting a UKB study and needs the upstream phenotype table that
feeds ukbsci-cohort.
2. When NOT to load this skill
- The user already has a participant-level table and wants to define a disease
cohort → route to `ukbsci-cohort`.
- The user wants regression / ML / mediation / propensity-score work → route to
the corresponding ukbsci-* skill.
- The user is asking about non-UK-Biobank or non-RAP data → do not load this
skill.
- The user explicitly asks to download participant-level data to a local
laptop → refuse; redirect them to RAP-resident workflows.
3. Prerequisites
If the user is not on RAP and asks "can I just try this locally?" — explain that field-metadata helpers (e.g. ukb_metadata_setup(source = "files") with the public Data Dictionary) work offline, but extraction functions (`rap_*`) require dx + an approved RAP project.
4. Pipeline (4 phases)
Phase 0 — Check RAP environment and decide extraction scale
Start every extraction script with a RAP environment check. This fails early when the user accidentally runs RAP-only extraction code on a local machine.
Ask the user (or estimate) the number of fields and the number of participants needed.
| Scale | Recommended path | |
|---|---|---|
| ≤ ~500 columns, ≤ 1M rows, ad-hoc exploration | Sync — rap_extract_pheno() | |
| > 500 columns OR full-cohort + many array fields | Async — rap_submit_extract() (uses RAP table-exporter app, runs on a separate worker) | |
| Unknown / first time | Run rap_plan_extract(..., dry_run-style) first; check plan$n_columns. |
Skip Phase 1–2 if the user already has the exact field_id list.
Phase 1 — Discover the dataset & fields
Phase 2 — Search and inspect specific fields
ukb_metadata_setup() builds a unified, searchable metadata object. Three source modes:
Search and inspect:
For single ad-hoc inspection without a full metadata object:
Phase 3 — Plan the extraction (mandatory dry-run)
rap_plan_extract() does not hit dx; it validates the field list, expands instances/arrays, and gives you a count of output columns. Always plan before running.
If length(plan$unmatched) > 0, stop and report to the user — do not proceed with a partial extraction.
For protocol-grade runs, also write a reusable extraction manifest. This is safe to share because it contains field-level metadata, not participant rows.
Phase 4 — Execute the extraction
4a. Synchronous (small jobs)
Notes:
read = TRUEreturns adata.tablewith the original plan attached as an
attribute (attr(dt, "rap_extract_plan")).
read = FALSEreturns the CSV path (still inside RAP storage).- Synchronous mode blocks the R session — do not use for full-cohort dumps with
hundreds of array columns.
4b. Asynchronous (large jobs)
The job runs the RAP table-exporter app on a worker. Monitor with:
When done, the CSV appears at dx://<project>:/<file>.csv inside the RAP project. Do not advise dx download to a laptop. To load it back into R inside RAP:
Phase 5 — Decode column names and coded values
ukb_decode_values() automatically treats UKB negative codes (e.g. -1 "Do not know", -3 "Prefer not to answer") as NA in the label column when missing_to_na = TRUE.
5. Key functions (cheat-sheet)
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-rap-extract/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 2 Sep 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-rap-extract)