|
a |
|
b/R/XenaQueryProbeMap.R |
|
|
1 |
##' Query ProbeMap URL of Datasets |
|
|
2 |
##' |
|
|
3 |
##' If dataset has no ProbeMap, it will be ignored. |
|
|
4 |
##' |
|
|
5 |
##' @author Shixiang Wang <w_shixiang@163.com> |
|
|
6 |
##' @param x a [XenaHub] object |
|
|
7 |
##' @return a `data.frame` contains hosts, datasets and url |
|
|
8 |
##' @importFrom dplyr filter select pull rename mutate |
|
|
9 |
##' @export |
|
|
10 |
##' @examples |
|
|
11 |
##' xe = XenaGenerate(subset = XenaHostNames == "tcgaHub") |
|
|
12 |
##' hosts(xe) |
|
|
13 |
##' \dontrun{ |
|
|
14 |
##' xe_query = XenaQueryProbeMap(xe) |
|
|
15 |
##' } |
|
|
16 |
XenaQueryProbeMap <- function(x) { |
|
|
17 |
message("Check ProbeMap urls of datasets.") |
|
|
18 |
datasetsName <- datasets(x) |
|
|
19 |
query <- UCSCXenaTools::XenaData %>% |
|
|
20 |
dplyr::filter((XenaDatasets %in% datasetsName) & (!is.na(ProbeMap))) |
|
|
21 |
|
|
|
22 |
if (nrow(query) == 0) { |
|
|
23 |
invisible(data.frame(stringsAsFactors = FALSE)) |
|
|
24 |
} else { |
|
|
25 |
query <- query %>% |
|
|
26 |
dplyr::rename(hosts = XenaHosts, datasets = ProbeMap) %>% |
|
|
27 |
dplyr::mutate(url = ifelse(.data$XenaHostNames %in% c("gdcHub", "gdcHubV18"), |
|
|
28 |
file.path(hosts, "download", url_encode(basename(datasets))), |
|
|
29 |
file.path(hosts, "download", url_encode(datasets)) |
|
|
30 |
)) %>% |
|
|
31 |
dplyr::mutate(url = ifelse(!sapply(url, http_error2), |
|
|
32 |
url, paste0(url, ".gz") |
|
|
33 |
)) %>% |
|
|
34 |
dplyr::select(hosts, datasets, url) %>% |
|
|
35 |
as.data.frame() |
|
|
36 |
|
|
|
37 |
invisible(unique(query)) |
|
|
38 |
} |
|
|
39 |
} |