Skip to content

Instantly share code, notes, and snippets.

@chapmanb
Created November 8, 2018 17:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chapmanb/26428c375d1d32761cb98e1669345cfa to your computer and use it in GitHub Desktop.
Save chapmanb/26428c375d1d32761cb98e1669345cfa to your computer and use it in GitHub Desktop.
Query TCGA API for exome capture BED files -- thanks to Sehyun Oh
#!/usr/bin/env Rscript
library(GenomicDataCommons)
library(dplyr)
manifest = GenomicDataCommons::files() %>%
GenomicDataCommons::filter(~ cases.project.project_id == "TCGA-LUAD" &
experimental_strategy == "WXS" &
data_format == "BAM") %>%
GenomicDataCommons::manifest()
manifest = manifest %>%
slice(1:10) %>%
select(id, filename)
res = lapply(manifest$id, function(uuid) {
#con = curl::curl(paste0("https://api.gdc.cancer.gov/files/", uuid, "?pretty=true&fields=analysis.metadata.read_groups.target_capture_kit_target_region,analysis.metadata.read_groups.target_capture_kit_name,analysis.metadata.read_groups.target_capture_kit_vendor,analysis.metadata.read_groups.target_capture_kit_catalog_number"))
con = curl::curl(paste0("https://api.gdc.cancer.gov/files/", uuid, "?pretty=true&fields=analysis.metadata.read_groups.target_capture_kit_target_region"))
x = jsonlite::fromJSON(con)
return(x)
})
y = lapply(res, function(x) unique(x$data$analysis$metadata$read_groups))
y = do.call(rbind, y)
manifest = cbind(manifest, y)
print(manifest)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment