|
26 | 26 | #' ) |
27 | 27 | #' } |
28 | 28 | #' @export |
29 | | -get_ucsc_reference <- function(cb_url, |
30 | | - cluster_col, |
31 | | - ...) { |
32 | | - if (!requireNamespace("R.utils", quietly = TRUE)) { |
33 | | - stop( |
34 | | - "This function requires the R.utils package, please install\n", |
35 | | - "install.packages('R.utils')" |
36 | | - ) |
37 | | - } |
| 29 | +get_ucsc_reference <- function(cb_url, cluster_col, ...) { |
| 30 | + if (!requireNamespace("R.utils", quietly = TRUE)) { |
| 31 | + stop( |
| 32 | + "This function requires the R.utils package, please install\n", |
| 33 | + "install.packages('R.utils')" |
| 34 | + ) |
| 35 | + } |
38 | 36 |
|
39 | | - if (!requireNamespace("data.table", quietly = TRUE)) { |
40 | | - stop( |
41 | | - "This function requires the data.table package, please install\n", |
42 | | - "install.packages('data.table')" |
43 | | - ) |
44 | | - } |
| 37 | + if (!requireNamespace("data.table", quietly = TRUE)) { |
| 38 | + stop( |
| 39 | + "This function requires the data.table package, please install\n", |
| 40 | + "install.packages('data.table')" |
| 41 | + ) |
| 42 | + } |
45 | 43 |
|
46 | | - url <- httr::parse_url(cb_url) |
47 | | - base_url <- url |
48 | | - ds <- url$query$ds |
| 44 | + url <- httr::parse_url(cb_url) |
| 45 | + base_url <- url |
| 46 | + ds <- url$query$ds |
49 | 47 |
|
50 | | - # ds can include sub-datasets with syntax, "dataset+subdataset+and-so-on" |
51 | | - # files are hosted at urls: dataset/subdataset/andsoon/..." |
52 | | - ds_split <- strsplit(ds, "+", fixed = TRUE)[[1]] |
53 | | - ds <- paste0(ds_split, collapse = "/") |
54 | | - base_url$query <- "" |
| 48 | + # ds can include sub-datasets with syntax, "dataset+subdataset+and-so-on" |
| 49 | + # files are hosted at urls: dataset/subdataset/andsoon/..." |
| 50 | + ds_split <- strsplit(ds, "+", fixed = TRUE)[[1]] |
| 51 | + ds <- paste0(ds_split, collapse = "/") |
| 52 | + base_url$query <- "" |
55 | 53 |
|
56 | | - mdata_url <- httr::modify_url(base_url, |
57 | | - path = file.path(ds, "meta.tsv") |
58 | | - ) |
59 | | - if (!httr::http_error(mdata_url)) { |
60 | | - mdata <- data.table::fread(mdata_url, data.table = FALSE, sep = "\t") |
61 | | - } else { |
62 | | - stop("unable to find metadata at url: ", mdata_url) |
63 | | - } |
| 54 | + mdata_url <- httr::modify_url(base_url, path = file.path(ds, "meta.tsv")) |
| 55 | + if (!httr::http_error(mdata_url)) { |
| 56 | + mdata <- data.table::fread(mdata_url, data.table = FALSE, sep = "\t") |
| 57 | + } else { |
| 58 | + stop("unable to find metadata at url: ", mdata_url) |
| 59 | + } |
64 | 60 |
|
65 | | - mat_url <- httr::modify_url(base_url, |
66 | | - path = file.path(ds, "exprMatrix.tsv.gz") |
67 | | - ) |
68 | | - if (!httr::http_error(mat_url)) { |
69 | | - mat <- data.table::fread(mat_url, data.table = FALSE, sep = "\t") |
70 | | - } else { |
71 | | - stop("unable to find matrix at url: ", mat_url) |
72 | | - } |
| 61 | + mat_url <- httr::modify_url( |
| 62 | + base_url, |
| 63 | + path = file.path(ds, "exprMatrix.tsv.gz") |
| 64 | + ) |
| 65 | + if (!httr::http_error(mat_url)) { |
| 66 | + mat <- data.table::fread(mat_url, data.table = FALSE, sep = "\t") |
| 67 | + } else { |
| 68 | + stop("unable to find matrix at url: ", mat_url) |
| 69 | + } |
73 | 70 |
|
74 | | - rownames(mat) <- mat[, 1] |
75 | | - mat[, 1] <- NULL |
76 | | - mat <- as.matrix(mat) |
| 71 | + rownames(mat) <- mat[, 1] |
| 72 | + mat[, 1] <- NULL |
| 73 | + mat <- as.matrix(mat) |
77 | 74 |
|
78 | | - mm <- max(mat) |
| 75 | + mm <- max(mat) |
79 | 76 |
|
80 | | - if (mm > 50) { |
81 | | - dots <- list(...) |
82 | | - if (!"if_log" %in% names(dots) || dots$if_log) { |
83 | | - warning( |
84 | | - "the data matrix has a maximum value of ", mm, "\n", |
85 | | - "the data are likely not log transformed,\n", |
86 | | - "please set the if_log argument for average clusters accordingly" |
87 | | - ) |
88 | | - } |
| 77 | + if (mm > 50) { |
| 78 | + dots <- list(...) |
| 79 | + if (!"if_log" %in% names(dots) || dots$if_log) { |
| 80 | + warning( |
| 81 | + "the data matrix has a maximum value of ", |
| 82 | + mm, |
| 83 | + "\n", |
| 84 | + "the data are likely not log transformed,\n", |
| 85 | + "please set the if_log argument for average clusters accordingly" |
| 86 | + ) |
89 | 87 | } |
| 88 | + } |
90 | 89 |
|
91 | | - average_clusters(mat, mdata, cluster_col = cluster_col, ...) |
| 90 | + average_clusters(mat, mdata, cluster_col = cluster_col, ...) |
92 | 91 | } |
0 commit comments