## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment  = "#>",
  eval     = FALSE
)

## ----auth---------------------------------------------------------------------
# library(ukbflow)
# 
# auth_login()
# auth_select_project("project-XXXXXXXXXXXX")

## ----extract-ls---------------------------------------------------------------
# # List all approved fields (cached after first call)
# extract_ls()
# 
# # Search by keyword
# extract_ls(pattern = "cancer")
# extract_ls(pattern = "p31|p53|p21022")
# 
# # Force refresh after switching projects or datasets
# extract_ls(refresh = TRUE)

## ----extract-batch------------------------------------------------------------
# # Submit extraction job
# job_id <- extract_batch(c(31, 53, 21022, 22189))
# 
# # Custom output name
# job_id <- extract_batch(
#   field_id = c(31, 53, 21022, 22189),
#   file     = "ukb_demographics"
# )
# 
# # High priority (faster queue, higher cost)
# job_id <- extract_batch(
#   field_id = c(31, 53, 21022, 22189),
#   priority = "high"
# )

## ----job-monitor--------------------------------------------------------------
# job_status(job_id)        # check progress
# job_path(job_id)          # get cloud file path once complete
# job_result(job_id)        # read result as data.table (inside RAP only)

## ----extract-pheno------------------------------------------------------------
# df <- extract_pheno(c(31, 53, 21022))

