Skip to content

Commit

Permalink
Try writing sample info to a temporary location instead of using Bioc…
Browse files Browse the repository at this point in the history
…FileCache
  • Loading branch information
Nick-Eagles committed Oct 16, 2024
1 parent 39fb432 commit 52d84a8
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 108 deletions.
24 changes: 6 additions & 18 deletions R/add_array_coords.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@
#' # Prepare sample_info
#' ########################################################################
#'
#' # Cache sample_info across examples
#' bfc <- BiocFileCache::BiocFileCache()
#' cached_file <- BiocFileCache::bfcquery(bfc, 'visiumStitched_sample_info')
#'
#' if (nrow(cached_file) == 0) {
#' # Then we need to construct the table of sample information
#' sample_info_path = file.path(tempdir(), "sample_info.rds")
#' if (file.exists(sample_info_path)) {
#' sample_info <- readRDS(sample_info_path)
#' } else {
#' sample_info <- dplyr::tibble(
#' group = "Br2719",
#' capture_area = c("V13B23-283_A1", "V13B23-283_C1", "V13B23-283_D1")
Expand All @@ -95,18 +93,8 @@
#'
#' ## Re-size images and add more information to the sample_info
#' sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir())
#'
#' # Cache sample info for later
#' sample_info_path <- BiocFileCache::bfcnew(
#' bfc, "visiumStitched_sample_info", ext = "csv"
#' )
#' readr::write_csv(sample_info, sample_info_path)
#' } else {
#' # Pull sample info from the cache
#' sample_info_path <- BiocFileCache::bfcquery(
#' bfc, 'visiumStitched_sample_info'
#' )$rpath
#' sample_info = readr::read_csv(sample_info_path)
#'
#' saveRDS(sample_info, sample_info_path)
#' }
#'
#' ## Preparing Fiji coordinates and images for build_SpatialExperiment()
Expand Down
24 changes: 6 additions & 18 deletions R/build_SpatialExperiment.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@
#' # Prepare sample_info
#' ########################################################################
#'
#' # Cache sample_info across examples
#' bfc <- BiocFileCache::BiocFileCache()
#' cached_file <- BiocFileCache::bfcquery(bfc, 'visiumStitched_sample_info')
#'
#' if (nrow(cached_file) == 0) {
#' # Then we need to construct the table of sample information
#' sample_info_path = file.path(tempdir(), "sample_info.rds")
#' if (file.exists(sample_info_path)) {
#' sample_info <- readRDS(sample_info_path)
#' } else {
#' sample_info <- dplyr::tibble(
#' group = "Br2719",
#' capture_area = c("V13B23-283_A1", "V13B23-283_C1", "V13B23-283_D1")
Expand All @@ -70,18 +68,8 @@
#'
#' ## Re-size images and add more information to the sample_info
#' sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir())
#'
#' # Cache sample info for later
#' sample_info_path <- BiocFileCache::bfcnew(
#' bfc, "visiumStitched_sample_info", ext = "csv"
#' )
#' readr::write_csv(sample_info, sample_info_path)
#' } else {
#' # Pull sample info from the cache
#' sample_info_path <- BiocFileCache::bfcquery(
#' bfc, 'visiumStitched_sample_info'
#' )$rpath
#' sample_info = readr::read_csv(sample_info_path)
#'
#' saveRDS(sample_info, sample_info_path)
#' }
#'
#' ## Preparing Fiji coordinates and images for build_SpatialExperiment()
Expand Down
24 changes: 6 additions & 18 deletions R/prep_fiji.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,10 @@
#' @author Nicholas J. Eagles
#'
#' @examples
#' # Cache sample_info across examples
#' bfc <- BiocFileCache::BiocFileCache()
#' cached_file <- BiocFileCache::bfcquery(bfc, 'visiumStitched_sample_info')
#'
#' if (nrow(cached_file) == 0) {
#' # Then we need to construct the table of sample information
#' sample_info_path = file.path(tempdir(), "sample_info.rds")
#' if (file.exists(sample_info_path)) {
#' sample_info <- readRDS(sample_info_path)
#' } else {
#' sample_info <- dplyr::tibble(
#' group = "Br2719",
#' capture_area = c("V13B23-283_A1", "V13B23-283_C1", "V13B23-283_D1")
Expand All @@ -70,18 +68,8 @@
#'
#' ## Re-size images and add more information to the sample_info
#' sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir())
#'
#' # Cache sample info for later
#' sample_info_path <- BiocFileCache::bfcnew(
#' bfc, "visiumStitched_sample_info", ext = "csv"
#' )
#' readr::write_csv(sample_info, sample_info_path)
#' } else {
#' # Pull sample info from the cache
#' sample_info_path <- BiocFileCache::bfcquery(
#' bfc, 'visiumStitched_sample_info'
#' )$rpath
#' sample_info = readr::read_csv(sample_info_path)
#'
#' saveRDS(sample_info, sample_info_path)
#' }
#'
#' spe_input_dir <- tempdir()
Expand Down
24 changes: 6 additions & 18 deletions man/add_array_coords.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 6 additions & 18 deletions man/build_SpatialExperiment.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 6 additions & 18 deletions man/prep_fiji.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 52d84a8

Please sign in to comment.