Skip to content

Commit

Permalink
Cache 'sample_info' in memory to reduce time for examples and tests t…
Browse files Browse the repository at this point in the history
…o run
  • Loading branch information
Nick-Eagles committed Aug 23, 2024
1 parent 35a8f0e commit a4739b5
Show file tree
Hide file tree
Showing 14 changed files with 296 additions and 268 deletions.
54 changes: 28 additions & 26 deletions R/add_array_coords.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,37 +56,39 @@
#' # Prepare sample_info
#' ########################################################################
#'
#' sample_info <- dplyr::tibble(
#' group = "Br2719",
#' capture_area = c("V13B23-283_A1", "V13B23-283_C1", "V13B23-283_D1")
#' )
#' # Add 'spaceranger_dir' column
#' sr_dir <- tempdir()
#' temp <- unzip(
#' spatialLIBD::fetch_data("visiumStitched_brain_spaceranger"),
#' exdir = sr_dir
#' )
#' sample_info$spaceranger_dir <- file.path(
#' sr_dir, sample_info$capture_area, "outs", "spatial"
#' )
#'
#' # Add Fiji-output-related columns
#' fiji_dir <- tempdir()
#' temp <- unzip(
#' spatialLIBD::fetch_data("visiumStitched_brain_Fiji_out"),
#' exdir = fiji_dir
#' )
#' sample_info$fiji_xml_path <- temp[grep("xml$", temp)]
#' sample_info$fiji_image_path <- temp[grep("png$", temp)]
#'
#' ## Re-size images and add more information to the sample_info
#' sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir())
#' if (!(exists("sample_info"))) {
#' sample_info <- dplyr::tibble(
#' group = "Br2719",
#' capture_area = c("V13B23-283_A1", "V13B23-283_C1", "V13B23-283_D1")
#' )
#' # Add 'spaceranger_dir' column
#' sr_dir <- tempdir()
#' temp <- unzip(
#' spatialLIBD::fetch_data("visiumStitched_brain_spaceranger"),
#' exdir = sr_dir
#' )
#' sample_info$spaceranger_dir <- file.path(
#' sr_dir, sample_info$capture_area, "outs", "spatial"
#' )
#'
#' # Add Fiji-output-related columns
#' fiji_dir <- tempdir()
#' temp <- unzip(
#' spatialLIBD::fetch_data("visiumStitched_brain_Fiji_out"),
#' exdir = fiji_dir
#' )
#' sample_info$fiji_xml_path <- temp[grep("xml$", temp)]
#' sample_info$fiji_image_path <- temp[grep("png$", temp)]
#'
#' ## Re-size images and add more information to the sample_info
#' sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir())
#' }
#'
#' ## Preparing Fiji coordinates and images for build_spe()
#' spe_input_dir <- tempdir()
#' prep_fiji_coords(sample_info, out_dir = spe_input_dir)
#' prep_fiji_image(sample_info, out_dir = spe_input_dir)
#'
#'
#' ########################################################################
#' # Add array coordinates
#' ########################################################################
Expand Down
52 changes: 27 additions & 25 deletions R/build_spe.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,33 @@
#' # Prepare sample_info
#' ########################################################################
#'
#' sample_info <- dplyr::tibble(
#' group = "Br2719",
#' capture_area = c("V13B23-283_A1", "V13B23-283_C1", "V13B23-283_D1")
#' )
#' # Add 'spaceranger_dir' column
#' sr_dir <- tempdir()
#' temp <- unzip(
#' spatialLIBD::fetch_data("visiumStitched_brain_spaceranger"),
#' exdir = sr_dir
#' )
#' sample_info$spaceranger_dir <- file.path(
#' sr_dir, sample_info$capture_area, "outs", "spatial"
#' )
#'
#' # Add Fiji-output-related columns
#' fiji_dir <- tempdir()
#' temp <- unzip(
#' spatialLIBD::fetch_data("visiumStitched_brain_Fiji_out"),
#' exdir = fiji_dir
#' )
#' sample_info$fiji_xml_path <- temp[grep("xml$", temp)]
#' sample_info$fiji_image_path <- temp[grep("png$", temp)]
#'
#' ## Re-size images and add more information to the sample_info
#' sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir())
#' if (!(exists("sample_info"))) {
#' sample_info <- dplyr::tibble(
#' group = "Br2719",
#' capture_area = c("V13B23-283_A1", "V13B23-283_C1", "V13B23-283_D1")
#' )
#' # Add 'spaceranger_dir' column
#' sr_dir <- tempdir()
#' temp <- unzip(
#' spatialLIBD::fetch_data("visiumStitched_brain_spaceranger"),
#' exdir = sr_dir
#' )
#' sample_info$spaceranger_dir <- file.path(
#' sr_dir, sample_info$capture_area, "outs", "spatial"
#' )
#'
#' # Add Fiji-output-related columns
#' fiji_dir <- tempdir()
#' temp <- unzip(
#' spatialLIBD::fetch_data("visiumStitched_brain_Fiji_out"),
#' exdir = fiji_dir
#' )
#' sample_info$fiji_xml_path <- temp[grep("xml$", temp)]
#' sample_info$fiji_image_path <- temp[grep("png$", temp)]
#'
#' ## Re-size images and add more information to the sample_info
#' sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir())
#' }
#'
#' ## Preparing Fiji coordinates and images for build_spe()
#' spe_input_dir <- tempdir()
Expand Down
53 changes: 27 additions & 26 deletions R/prep_fiji_coords.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,33 @@
#' @author Nicholas J. Eagles
#'
#' @examples
#' # Define sample information for the example human brain data
#' sample_info <- dplyr::tibble(
#' group = "Br2719",
#' capture_area = c("V13B23-283_A1", "V13B23-283_C1", "V13B23-283_D1")
#' )
#' # Add 'spaceranger_dir' column
#' sr_dir <- tempdir()
#' temp <- unzip(
#' spatialLIBD::fetch_data("visiumStitched_brain_spaceranger"),
#' exdir = sr_dir
#' )
#' sample_info$spaceranger_dir <- file.path(
#' sr_dir, sample_info$capture_area, "outs", "spatial"
#' )
#'
#' # Add Fiji-output-related columns
#' fiji_dir <- tempdir()
#' temp <- unzip(
#' spatialLIBD::fetch_data("visiumStitched_brain_Fiji_out"),
#' exdir = fiji_dir
#' )
#' sample_info$fiji_xml_path <- temp[grep("xml$", temp)]
#' sample_info$fiji_image_path <- temp[grep("png$", temp)]
#'
#' ## Re-size images and add more information to the sample_info
#' sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir())
#' if (!(exists("sample_info"))) {
#' sample_info <- dplyr::tibble(
#' group = "Br2719",
#' capture_area = c("V13B23-283_A1", "V13B23-283_C1", "V13B23-283_D1")
#' )
#' # Add 'spaceranger_dir' column
#' sr_dir <- tempdir()
#' temp <- unzip(
#' spatialLIBD::fetch_data("visiumStitched_brain_spaceranger"),
#' exdir = sr_dir
#' )
#' sample_info$spaceranger_dir <- file.path(
#' sr_dir, sample_info$capture_area, "outs", "spatial"
#' )
#'
#' # Add Fiji-output-related columns
#' fiji_dir <- tempdir()
#' temp <- unzip(
#' spatialLIBD::fetch_data("visiumStitched_brain_Fiji_out"),
#' exdir = fiji_dir
#' )
#' sample_info$fiji_xml_path <- temp[grep("xml$", temp)]
#' sample_info$fiji_image_path <- temp[grep("png$", temp)]
#'
#' ## Re-size images and add more information to the sample_info
#' sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir())
#' }
#'
#' spe_input_dir <- tempdir()
#' out_file <- prep_fiji_coords(sample_info, out_dir = spe_input_dir)
Expand Down
53 changes: 27 additions & 26 deletions R/prep_fiji_image.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,33 @@
#' @author Nicholas J. Eagles
#'
#' @examples
#' # Define sample information for the example human brain data
#' sample_info <- dplyr::tibble(
#' group = "Br2719",
#' capture_area = c("V13B23-283_A1", "V13B23-283_C1", "V13B23-283_D1")
#' )
#' # Add 'spaceranger_dir' column
#' sr_dir <- tempdir()
#' temp <- unzip(
#' spatialLIBD::fetch_data("visiumStitched_brain_spaceranger"),
#' exdir = sr_dir
#' )
#' sample_info$spaceranger_dir <- file.path(
#' sr_dir, sample_info$capture_area, "outs", "spatial"
#' )
#'
#' # Add Fiji-output-related columns
#' fiji_dir <- tempdir()
#' temp <- unzip(
#' spatialLIBD::fetch_data("visiumStitched_brain_Fiji_out"),
#' exdir = fiji_dir
#' )
#' sample_info$fiji_xml_path <- temp[grep("xml$", temp)]
#' sample_info$fiji_image_path <- temp[grep("png$", temp)]
#'
#' ## Re-size images and add more information to the sample_info
#' sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir())
#' if (!(exists("sample_info"))) {
#' sample_info <- dplyr::tibble(
#' group = "Br2719",
#' capture_area = c("V13B23-283_A1", "V13B23-283_C1", "V13B23-283_D1")
#' )
#' # Add 'spaceranger_dir' column
#' sr_dir <- tempdir()
#' temp <- unzip(
#' spatialLIBD::fetch_data("visiumStitched_brain_spaceranger"),
#' exdir = sr_dir
#' )
#' sample_info$spaceranger_dir <- file.path(
#' sr_dir, sample_info$capture_area, "outs", "spatial"
#' )
#'
#' # Add Fiji-output-related columns
#' fiji_dir <- tempdir()
#' temp <- unzip(
#' spatialLIBD::fetch_data("visiumStitched_brain_Fiji_out"),
#' exdir = fiji_dir
#' )
#' sample_info$fiji_xml_path <- temp[grep("xml$", temp)]
#' sample_info$fiji_image_path <- temp[grep("png$", temp)]
#'
#' ## Re-size images and add more information to the sample_info
#' sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir())
#' }
#'
#' spe_input_dir <- tempdir()
#' out_paths <- prep_fiji_image(
Expand Down
52 changes: 28 additions & 24 deletions man/add_array_coords.Rd

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

4 changes: 3 additions & 1 deletion man/add_overlap_info.Rd

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

48 changes: 25 additions & 23 deletions man/build_spe.Rd

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

Loading

0 comments on commit a4739b5

Please sign in to comment.