Skip to content

Commit 8a94f8b

Browse files
committed
🚀 RELEASE: v1.2.1
1 parent 54d1b4e commit 8a94f8b

16 files changed

+312
-47
lines changed

CRAN-RELEASE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This package was submitted to CRAN on 2019-04-18.
2+
Once it is accepted, delete this file and tag the release (commit 54d1b4e1d9).

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: UCSCXenaTools
22
Title: Download and Explore Datasets from UCSC Xena Data Hubs
3-
Version: 1.2.0.9000
3+
Version: 1.2.1
44
Authors@R: c(person("Shixiang", "Wang", email = "w_shixiang@163.com", role = c("aut", "cre"),
55
comment = c(ORCID = "0000-0001-9855-7357")),
66
person("Martin", "Morgan", role="aut"))

NAMESPACE

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export(XenaGenerate)
99
export(XenaHub)
1010
export(XenaPrepare)
1111
export(XenaQuery)
12+
export(XenaQueryProbeMap)
1213
export(XenaShiny)
1314
export(availTCGA)
1415
export(cohorts)
@@ -25,6 +26,11 @@ import(dplyr)
2526
import(methods)
2627
import(shiny)
2728
import(shinydashboard)
29+
importFrom(dplyr,filter)
30+
importFrom(dplyr,mutate)
31+
importFrom(dplyr,pull)
32+
importFrom(dplyr,rename)
33+
importFrom(dplyr,select)
2834
importFrom(httr,POST)
2935
importFrom(httr,content)
3036
importFrom(httr,stop_for_status)

NEWS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@
44

55
* fix API functions cannot be called from outside
66

7+
## New features
8+
9+
* Add option to `XenaDownload` function for downloading gene id mapping data
10+
* Add `XenaQueryProbeMap()` for querying probemap of datasets.
11+
712
## Minor changes
813

914
* export `XenaHub` Class
15+
* improve `XenaQuery` function
16+
* update website and documentation
1017

1118
# v1.2.0
1219

R/workflow.R

Lines changed: 59 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ XenaFilter = function(x,
116116
##' Query URL of Datasets before Downloading
117117
##' @author Shixiang Wang <w_shixiang@163.com>
118118
##' @param x a [XenaHub] object
119-
##' @return a `tibble` contains hosts, datasets and url
119+
##' @return a `data.frame` contains hosts, datasets and url
120+
##' @importFrom dplyr filter select pull rename mutate
120121
##' @export
121122
##' @examples
122123
##' \donttest{
@@ -125,42 +126,54 @@ XenaFilter = function(x,
125126
##' xe_query = XenaQuery(xe)
126127
##' }
127128
XenaQuery = function(x) {
128-
hostsName = hosts(x)
129+
message("This will check url status, please be patient.")
129130
datasetsName = datasets(x)
131+
query = UCSCXenaTools::XenaData %>%
132+
dplyr::filter(XenaDatasets %in% datasetsName) %>%
133+
dplyr::rename(hosts = XenaHosts, datasets = XenaDatasets) %>%
134+
dplyr::mutate(url = file.path(hosts, "download", datasets)) %>%
135+
dplyr::mutate(url = ifelse(!sapply(url, httr::http_error),
136+
url, paste0(url, ".gz"))) %>%
137+
dplyr::select(hosts, datasets, url) %>%
138+
as.data.frame()
130139

131-
message("This will check url status, please be patient.")
132-
if (length(hostsName) == 1) {
133-
urls = file.path(hostsName, "download", datasetsName)
134-
# if file and file.gz all exist, download file # see issue#2
135-
dlink = ifelse(!sapply(urls, httr::http_error),
136-
urls, paste0(urls, ".gz"))
137-
query = data.frame(
138-
hosts = hostsName,
139-
datasets = datasetsName,
140-
url = dlink,
141-
stringsAsFactors = FALSE
142-
)
143-
} else{
144-
# identify relationship of hosts and datasets
145-
query = data.frame(
146-
hosts = "NA",
147-
datasets = datasetsName,
148-
url = "NA",
149-
stringsAsFactors = FALSE
150-
)
151-
for (onehost in hostsName) {
152-
xe = XenaHub(hosts = onehost)
153-
dataset_list = datasets(xe)
154-
query$hosts[query$datasets %in% dataset_list] = hosts(xe)
155-
}
156-
urls = paste0(query$hosts, "/download/", query$datasets)
157-
# if file and file.gz all exist, download file # see issue#2
158-
query$url = ifelse(!sapply(urls, httr::http_error),
159-
urls, paste0(urls, ".gz"))
140+
invisible(query)
141+
}
160142

161-
}
143+
##' Query ProbeMap URL of Datasets
144+
##'
145+
##' If dataset has no ProbeMap, it will be ignored.
146+
##'
147+
##' @author Shixiang Wang <w_shixiang@163.com>
148+
##' @param x a [XenaHub] object
149+
##' @return a `data.frame` contains hosts, datasets and url
150+
##' @importFrom dplyr filter select pull rename mutate
151+
##' @export
152+
##' @examples
153+
##' \donttest{
154+
##' xe = XenaGenerate(subset = XenaHostNames == "tcgaHub")
155+
##' hosts(xe)
156+
##' xe_query = XenaQueryProbeMap(xe)
157+
##' }
158+
XenaQueryProbeMap = function(x) {
159+
message("Check ProbeMap urls of datasets.")
160+
datasetsName = datasets(x)
161+
query = UCSCXenaTools::XenaData %>%
162+
dplyr::filter((XenaDatasets %in% datasetsName) & (!is.na(ProbeMap)))
162163

163-
invisible(query)
164+
if (nrow(query) == 0) {
165+
invisible(data.frame(stringsAsFactors = FALSE))
166+
} else {
167+
query = query %>%
168+
dplyr::rename(hosts = XenaHosts, datasets = ProbeMap) %>%
169+
dplyr::mutate(url = file.path(hosts, "download", datasets)) %>%
170+
dplyr::mutate(url = ifelse(!sapply(url, httr::http_error),
171+
url, paste0(url, ".gz"))) %>%
172+
dplyr::select(hosts, datasets, url) %>%
173+
as.data.frame()
174+
175+
invisible(unique(query))
176+
}
164177
}
165178

166179
##' Download Datasets from UCSC Xena Hubs
@@ -170,6 +183,7 @@ XenaQuery = function(x) {
170183
##' @author Shixiang Wang <w_shixiang@163.com>
171184
##' @param xquery a tibble object generated by [XenaQuery] function.
172185
##' @param destdir specify a location to store download data. Default is system temp directory.
186+
##' @param download_probeMap if `TRUE`, also download ProbeMap data, which used for id mapping.
173187
##' @param trans_slash logical, default is `FALSE`. If `TRUE`, transform slash '/' in dataset id
174188
##' to '__'. This option is for backwards compatibility.
175189
##' @param force logical. if `TRUE`, force to download data no matter whether files exist.
@@ -178,6 +192,7 @@ XenaQuery = function(x) {
178192
##' @return a `tibble`
179193
##' @export
180194
##' @importFrom utils download.file
195+
##' @importFrom dplyr filter
181196
##' @examples
182197
##' \donttest{
183198
##' xe = XenaGenerate(subset = XenaHostNames == "tcgaHub")
@@ -188,10 +203,19 @@ XenaQuery = function(x) {
188203

189204
XenaDownload = function(xquery,
190205
destdir = tempdir(),
206+
download_probeMap = FALSE,
191207
trans_slash = FALSE,
192208
force = FALSE,
193209
...) {
194-
stopifnot(is.data.frame(xquery), c("url") %in% names(xquery))
210+
stopifnot(is.data.frame(xquery), c("url") %in% names(xquery), is.logical(download_probeMap))
211+
212+
if (download_probeMap) {
213+
xquery_probe = UCSCXenaTools::XenaData %>%
214+
dplyr::filter(XenaDatasets %in% xquery$datasets) %>%
215+
XenaGenerate() %>%
216+
XenaQueryProbeMap()
217+
xquery = rbind(xquery, xquery_probe)
218+
}
195219

196220
if (trans_slash) {
197221
xquery$fileNames = gsub(pattern = "/",
@@ -592,3 +616,4 @@ XenaBrowse = function(x, type = c("dataset", "cohort"), multiple=FALSE) {
592616
invisible(NULL)
593617
}
594618

619+
utils::globalVariables(c("XenaDatasets", "XenaHosts", "ProbeMap"))

docs/articles/USCSXenaTools.html

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/articles/xena-apis.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/XenaDownload.html

Lines changed: 6 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/reference/XenaQuery.html

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)