|
17 | 17 | #' @param level `character(1L)` One of "slide_level" or "tile_level" specifying |
18 | 18 | #' the desired ProvGiga data level. Default is "slide_level". |
19 | 19 | #' |
| 20 | +#' @returns `listHoverNet`,`listProvGiga`: A `tibble` listing available HoverNet |
| 21 | +#' or ProvGigaPath files with `Filename`, `Modified`, and `Size` columns. |
| 22 | +#' |
20 | 23 | #' @examplesIf interactive() |
21 | 24 | #' ## List available HoverNet data for TCGA-OV |
22 | 25 | #' listHoverNet(format = "h5ad") |
@@ -52,11 +55,47 @@ listProvGiga <- function( |
52 | 55 | table[!grepl("^\\.\\.", table[["Filename"]]), ] |
53 | 56 | } |
54 | 57 |
|
55 | | -getCatalog <- function(pipeline = c("hovernet", "provgigapath")) { |
56 | | - pipeline <- match.arg(pipeline) |
57 | | - catalog_url <- paste( |
58 | | - .BASE_URL, pipeline, paste0(pipeline, "_catalog.tsv"), |
59 | | - sep = "/" |
60 | | - ) |> |
61 | | - readr::read_tsv(show_col_types = FALSE) |
| 58 | +.CATALOG_COL_TYPES <- "ccccccccccccccccccccccddc" |
| 59 | + |
| 60 | +#' @rdname listFiles |
| 61 | +#' |
| 62 | +#' @description The `getCatalog` function retrieves a catalog of all available |
| 63 | +#' HoVerNet and ProvGigaPath files, including filenames, sizes, pipelines |
| 64 | +#' used, tumor types, and data levels. |
| 65 | +#' |
| 66 | +#' @param pipeline `character()` One or both "hovernet" and/or "provgigapath" |
| 67 | +#' specifying which pipeline(s) to include in the catalog. Default includes |
| 68 | +#' both. |
| 69 | +#' |
| 70 | +#' @param redownload `logical(1L)` Whether to redownload the catalog file even |
| 71 | +#' if it is already cached locally. Default is `FALSE`. |
| 72 | +#' |
| 73 | +#' @returns `getCatalog`: A `tibble` containing the full catalog of available |
| 74 | +#' files for the specified pipeline(s). |
| 75 | +#' |
| 76 | +#' @examplesIf interactive() |
| 77 | +#' ## Get the full catalog of available files |
| 78 | +#' getCatalog(pipeline = c("hovernet", "provgigapath")) |
| 79 | +#' @export |
| 80 | +getCatalog <- |
| 81 | + function(pipeline = c("hovernet", "provgigapath"), redownload = FALSE) |
| 82 | +{ |
| 83 | + pipeline <- match.arg(pipeline, several.ok = TRUE) |
| 84 | + catalog <- .download_catalog(redownload = redownload) |
| 85 | + readr::read_tsv(catalog, col_types = .CATALOG_COL_TYPES) |> |
| 86 | + subset(pipeline %in% pipeline) |
| 87 | +} |
| 88 | + |
| 89 | +#' @importFrom httr2 request req_headers req_perform resp_body_json |
| 90 | +.download_catalog <- function(redownload) { |
| 91 | + resp <- request("https://zenodo.org/api/records/17981132") |> |
| 92 | + req_headers( |
| 93 | + Accept = "application/json" |
| 94 | + ) |> |
| 95 | + req_perform() |> |
| 96 | + resp_body_json() |
| 97 | + |
| 98 | + .cache_url_file( |
| 99 | + resp$files[[1L]]$links$self, redownload = redownload |
| 100 | + ) |
62 | 101 | } |
0 commit comments