diff --git a/DESCRIPTION b/DESCRIPTION index 3b599605..b8a28dec 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: spatialLIBD Title: LIBD Visium spatial transcriptomics human pilot data inspector -Version: 0.99.6 +Version: 0.99.7 Date: 2020-02-27 Authors@R: c( diff --git a/NEWS.md b/NEWS.md index 70b1d9d5..9b9709f2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# spatialLIBD 0.99.7 + +* Run a test that might help with https://github.com/r-lib/pkgdown/issues/1230. + # spatialLIBD 0.99.6 * Add mirrors for the shiny app and change the main location. diff --git a/R/check_image_path.R b/R/check_image_path.R index 52b3074c..477d1847 100644 --- a/R/check_image_path.R +++ b/R/check_image_path.R @@ -13,13 +13,13 @@ #' @examples #' #' ## Obtain the necessary data -#' if (!exists('ori_sce')) ori_sce <- fetch_data('sce') +#' if (!exists('sce')) sce <- fetch_data('sce') #' #' ## Get the path to the images #' img_path <- system.file('app', 'www', 'data', package = 'spatialLIBD') #' #' ## Check the object -#' check_image_path(img_path, ori_sce) +#' check_image_path(img_path, sce) #' check_image_path <- function(image_path, sce) { diff --git a/R/check_modeling_results.R b/R/check_modeling_results.R index ac114819..0eceef44 100644 --- a/R/check_modeling_results.R +++ b/R/check_modeling_results.R @@ -12,11 +12,11 @@ #' #' @examples #' -#' if (!exists('ori_modeling_results')) -#' ori_modeling_results <- fetch_data(type = 'modeling_results') +#' if (!exists('modeling_results')) +#' modeling_results <- fetch_data(type = 'modeling_results') #' #' ## Check the object -#' xx <- check_modeling_results(ori_modeling_results) +#' xx <- check_modeling_results(modeling_results) #' check_modeling_results <- function(modeling_results) { diff --git a/R/check_sce.R b/R/check_sce.R index b3f444e8..45db614d 100644 --- a/R/check_sce.R +++ b/R/check_sce.R @@ -16,10 +16,10 @@ #' @examples #' #' ## Obtain the necessary data -#' if (!exists('ori_sce')) ori_sce <- fetch_data('sce') +#' if (!exists('sce')) sce <- fetch_data('sce') #' #' ## Check the object -#' check_sce(ori_sce) +#' check_sce(sce) #' check_sce <- function(sce, diff --git a/R/check_sce_layer.R b/R/check_sce_layer.R index c2f71d05..d3ea293c 100644 --- a/R/check_sce_layer.R +++ b/R/check_sce_layer.R @@ -15,10 +15,10 @@ #' @examples #' #' ## Obtain the necessary data -#' if (!exists('ori_sce_layer')) ori_sce_layer <- fetch_data('sce_layer') +#' if (!exists('sce_layer')) sce_layer <- fetch_data('sce_layer') #' #' ## Check the object -#' check_sce_layer(ori_sce_layer) +#' check_sce_layer(sce_layer) #' check_sce_layer <- function(sce_layer, variables = 'layer_guess_reordered_short') { diff --git a/R/fetch_data.R b/R/fetch_data.R index 2ab94b11..dbded0b5 100644 --- a/R/fetch_data.R +++ b/R/fetch_data.R @@ -42,7 +42,7 @@ #' #' ## Download the SingleCellExperiment object #' ## at the layer-level -#' sce_layer <- fetch_data('sce_layer') +#' if (!exists('sce_layer')) sce_layer <- fetch_data('sce_layer') #' #' ## Explore the data #' sce_layer diff --git a/R/gene_set_enrichment.R b/R/gene_set_enrichment.R index 5f2f2ba3..c9bb82e8 100644 --- a/R/gene_set_enrichment.R +++ b/R/gene_set_enrichment.R @@ -41,13 +41,13 @@ #' ) #' #' ## Obtain the necessary data -#' if (!exists('ori_modeling_results')) -#' ori_modeling_results <- fetch_data(type = 'modeling_results') +#' if (!exists('modeling_results')) +#' modeling_results <- fetch_data(type = 'modeling_results') #' #' ## Compute the gene set enrichment results #' asd_sfari_enrichment <- gene_set_enrichment( #' gene_list = asd_sfari_geneList, -#' modeling_results = ori_modeling_results, +#' modeling_results = modeling_results, #' model_type = 'enrichment' #' ) #' diff --git a/R/gene_set_enrichment_plot.R b/R/gene_set_enrichment_plot.R index 3fbddc95..5aa029f5 100644 --- a/R/gene_set_enrichment_plot.R +++ b/R/gene_set_enrichment_plot.R @@ -52,13 +52,13 @@ #' ) #' #' ## Obtain the necessary data -#' if (!exists('ori_modeling_results')) -#' ori_modeling_results <- fetch_data(type = 'modeling_results') +#' if (!exists('modeling_results')) +#' modeling_results <- fetch_data(type = 'modeling_results') #' #' ## Compute the gene set enrichment results #' asd_sfari_enrichment <- gene_set_enrichment( #' gene_list = asd_sfari_geneList, -#' modeling_results = ori_modeling_results, +#' modeling_results = modeling_results, #' model_type = 'enrichment' #' ) #' diff --git a/R/geom_spatial.R b/R/geom_spatial.R index 55fca38c..bceb44de 100644 --- a/R/geom_spatial.R +++ b/R/geom_spatial.R @@ -21,11 +21,11 @@ #' #' @examples #' ## Obtain the necessary data -#' if (!exists('ori_sce')) ori_sce <- fetch_data('sce') +#' if (!exists('sce')) sce <- fetch_data('sce') #' #' ## Select the first sample and extract the data -#' sample_id <- unique(ori_sce$sample_name)[1] -#' sce_sub <- ori_sce[, ori_sce$sample_name == sample_id] +#' sample_id <- unique(sce$sample_name)[1] +#' sce_sub <- sce[, sce$sample_name == sample_id] #' sample_df <- as.data.frame(colData(sce_sub)) #' #' ## Make a plot using geom_spatial @@ -41,6 +41,9 @@ #' y = 0.5 #' ) #' +#' ## Clean up +#' rm(sce_sub) +#' geom_spatial <- function(mapping = NULL, data = NULL, diff --git a/R/get_colors.R b/R/get_colors.R index 5d580d8a..9b81ce51 100644 --- a/R/get_colors.R +++ b/R/get_colors.R @@ -19,15 +19,15 @@ #' @examples #' #' ## Obtain the necessary data -#' if (!exists('ori_sce_layer')) ori_sce_layer <- fetch_data('sce') +#' if (!exists('sce_layer')) sce_layer <- fetch_data('sce') #' #' ## Example layer colors with the corresponding names -#' get_colors(libd_layer_colors, ori_sce_layer$layer_guess) -#' get_colors(libd_layer_colors, ori_sce_layer$layer_guess_reordered_short) +#' get_colors(libd_layer_colors, sce_layer$layer_guess) +#' get_colors(libd_layer_colors, sce_layer$layer_guess_reordered_short) #' #' ## Example where colors are assigned automatically #' ## based on a pre-defined set of colors -#' get_colors(clusters = ori_sce_layer$kmeans_k7) +#' get_colors(clusters = sce_layer$kmeans_k7) #' #' ## Example where Polychrome::palette36.colors() gets used #' get_colors(clusters = letters[seq_len(13)]) diff --git a/R/layer_boxplot.R b/R/layer_boxplot.R index 21ab4206..e177fbdc 100644 --- a/R/layer_boxplot.R +++ b/R/layer_boxplot.R @@ -36,39 +36,39 @@ #' @examples #' #' ## Obtain the necessary data -#' if (!exists('ori_modeling_results')) -#' ori_modeling_results <- fetch_data(type = 'modeling_results') -#' if (!exists('ori_sce_layer')) ori_sce_layer <- fetch_data(type = 'sce_layer') +#' if (!exists('modeling_results')) +#' modeling_results <- fetch_data(type = 'modeling_results') +#' if (!exists('sce_layer')) sce_layer <- fetch_data(type = 'sce_layer') #' #' ## Top 2 genes from the enrichment model #' sig_genes <- sig_genes_extract_all(n = 2, -#' modeling_results = ori_modeling_results, -#' sce_layer = ori_sce_layer) +#' modeling_results = modeling_results, +#' sce_layer = sce_layer) #' #' ## Example default boxplot -#' layer_boxplot(sig_genes = sig_genes, sce_layer = ori_sce_layer) +#' layer_boxplot(sig_genes = sig_genes, sce_layer = sce_layer) #' #' ## Now show the long title version #' layer_boxplot(sig_genes = sig_genes, #' short_title = FALSE, -#' sce_layer = ori_sce_layer) +#' sce_layer = sce_layer) #' #' layer_boxplot( #' i = which(sig_genes$model_type == 'anova')[1], #' sig_genes = sig_genes, -#' sce_layer = ori_sce_layer +#' sce_layer = sce_layer #' ) #' layer_boxplot( #' i = which(sig_genes$model_type == 'pairwise')[1], #' sig_genes = sig_genes, -#' sce_layer = ori_sce_layer +#' sce_layer = sce_layer #' ) #' #' ## Viridis colors displayed in the shiny app #' library('viridisLite') #' layer_boxplot( #' sig_genes = sig_genes, -#' sce_layer = ori_sce_layer, +#' sce_layer = sce_layer, #' col_low_box = viridis(4)[2], #' col_low_point = viridis(4)[1], #' col_high_box = viridis(4)[3], @@ -78,7 +78,7 @@ #' ## Paper colors displayed in the shiny app #' layer_boxplot( #' sig_genes = sig_genes, -#' sce_layer = ori_sce_layer, +#' sce_layer = sce_layer, #' col_low_box = 'palegreen3', #' col_low_point = 'springgreen2', #' col_high_box = 'darkorange2', @@ -89,7 +89,7 @@ #' layer_boxplot( #' i = which(sig_genes$model_type == 'pairwise')[1], #' sig_genes = sig_genes, -#' sce_layer = ori_sce_layer, +#' sce_layer = sce_layer, #' col_bkg_box = 'grey90', #' col_bkg_point = 'grey60', #' col_low_box = 'lightcyan', diff --git a/R/layer_stat_cor.R b/R/layer_stat_cor.R index 5b14d336..0222cfa8 100644 --- a/R/layer_stat_cor.R +++ b/R/layer_stat_cor.R @@ -24,13 +24,13 @@ #' @examples #' #' ## Obtain the necessary data -#' if (!exists('ori_modeling_results')) -#' ori_modeling_results <- fetch_data(type = 'modeling_results') +#' if (!exists('modeling_results')) +#' modeling_results <- fetch_data(type = 'modeling_results') #' #' ## Compute the correlations #' cor_stats_layer <- layer_stat_cor( #' tstats_Human_DLPFC_snRNAseq_Nguyen_topLayer, -#' ori_modeling_results, +#' modeling_results, #' 'enrichment' #' ) #' diff --git a/R/layer_stat_cor_plot.R b/R/layer_stat_cor_plot.R index 1bc93036..b300913c 100644 --- a/R/layer_stat_cor_plot.R +++ b/R/layer_stat_cor_plot.R @@ -31,13 +31,13 @@ #' @examples #' #' ## Obtain the necessary data -#' if (!exists('ori_modeling_results')) -#' ori_modeling_results <- fetch_data(type = 'modeling_results') +#' if (!exists('modeling_results')) +#' modeling_results <- fetch_data(type = 'modeling_results') #' #' ## Compute the correlations #' cor_stats_layer <- layer_stat_cor( #' tstats_Human_DLPFC_snRNAseq_Nguyen_topLayer, -#' ori_modeling_results, +#' modeling_results, #' 'enrichment' #' ) #' diff --git a/R/run_app.R b/R/run_app.R index 08f84061..57ae8b79 100644 --- a/R/run_app.R +++ b/R/run_app.R @@ -93,7 +93,7 @@ run_app <- function(sce = fetch_data(type = 'sce'), sce <- check_sce(sce, variables = c(spatial_libd_var, sce_discrete_vars, sce_continuous_vars)) - sce_layer <- + if (!exists('sce_layer')) sce_layer <- check_sce_layer(sce_layer, variables = spatial_libd_var) modeling_results <- check_modeling_results(modeling_results) image_path <- check_image_path(image_path, sce) diff --git a/R/sce_image_clus.R b/R/sce_image_clus.R index 039aeba9..a4e223ec 100644 --- a/R/sce_image_clus.R +++ b/R/sce_image_clus.R @@ -27,14 +27,14 @@ #' @examples #' #' ## Obtain the necessary data -#' if (!exists('ori_sce')) ori_sce <- fetch_data('sce') +#' if (!exists('sce')) sce <- fetch_data('sce') #' #' ## Check the colors defined by Lukas M Weber #' libd_layer_colors #' #' ## Use the manual color palette by Lukas M Weber #' sce_image_clus( -#' sce = ori_sce, +#' sce = sce, #' clustervar = 'layer_guess_reordered', #' sampleid = '151673', #' colors = libd_layer_colors, @@ -43,7 +43,7 @@ #' #' ## Without histology #' sce_image_clus( -#' sce = ori_sce, +#' sce = sce, #' clustervar = 'layer_guess_reordered', #' sampleid = '151673', #' colors = libd_layer_colors, diff --git a/R/sce_image_clus_p.R b/R/sce_image_clus_p.R index 273c46bf..e06c629b 100644 --- a/R/sce_image_clus_p.R +++ b/R/sce_image_clus_p.R @@ -18,8 +18,8 @@ #' @examples #' #' ## Obtain the necessary data -#' if (!exists('ori_sce')) ori_sce <- fetch_data('sce') -#' sce_sub <- ori_sce[, ori_sce$sample_name == '151673'] +#' if (!exists('sce')) sce <- fetch_data('sce') +#' sce_sub <- sce[, sce$sample_name == '151673'] #' #' ## Use the manual color palette by Lukas M Weber #' ## Don't plot the histology information @@ -33,6 +33,9 @@ #' spatial = FALSE #' ) #' +#' ## Clean up +#' rm(sce_sub) +#' sce_image_clus_p <- function(sce, diff --git a/R/sce_image_gene.R b/R/sce_image_gene.R index 16fcf60b..a07ee8ba 100644 --- a/R/sce_image_gene.R +++ b/R/sce_image_gene.R @@ -31,15 +31,15 @@ #' @examples #' #' ## Obtain the necessary data -#' if (!exists('ori_sce')) ori_sce <- fetch_data('sce') +#' if (!exists('sce')) sce <- fetch_data('sce') #' #' ## Valid `geneid` values are those in -#' head(rowData(ori_sce)$gene_search) -#' ## or continuous variables stored in colData(ori_sce) +#' head(rowData(sce)$gene_search) +#' ## or continuous variables stored in colData(sce) #' #' ## Visualize a default gene on the non-viridis scale #' sce_image_gene( -#' sce = ori_sce, +#' sce = sce, #' sampleid = '151507', #' viridis = FALSE #' ) @@ -47,7 +47,7 @@ #' ## Visualize a continuous variable, in this case, the ratio of chrM #' ## gene expression compared to the total expression at the spot-level #' sce_image_gene( -#' sce = ori_sce, +#' sce = sce, #' sampleid = '151507', #' geneid = 'expr_chrM_ratio' #' ) diff --git a/R/sce_image_gene_p.R b/R/sce_image_gene_p.R index bceee322..bc94b7aa 100644 --- a/R/sce_image_gene_p.R +++ b/R/sce_image_gene_p.R @@ -20,10 +20,10 @@ #' @examples #' #' ## Obtain the necessary data -#' if (!exists('ori_sce')) ori_sce <- fetch_data('sce') +#' if (!exists('sce')) sce <- fetch_data('sce') #' #' ## Prepare the data for the plotting function -#' sce_sub <- ori_sce[, ori_sce$sample_name == '151673'] +#' sce_sub <- sce[, sce$sample_name == '151673'] #' df <- as.data.frame(colData(sce_sub)) #' df$COUNT <- df$expr_chrM_ratio #' @@ -37,6 +37,9 @@ #' spatial = FALSE #' ) #' +#' ## Clean up +#' rm(sce_sub) +#' sce_image_gene_p <- function(sce, diff --git a/R/sce_image_grid.R b/R/sce_image_grid.R index b1d60e35..15b864ce 100644 --- a/R/sce_image_grid.R +++ b/R/sce_image_grid.R @@ -24,10 +24,10 @@ #' @examples #' #' ## Obtain the necessary data -#' if (!exists('ori_sce')) ori_sce <- fetch_data('sce') +#' if (!exists('sce')) sce <- fetch_data('sce') #' #' ## Subset to two samples of interest -#' sce_sub <- ori_sce[, ori_sce$sample_name %in% c('151673', '151674')] +#' sce_sub <- sce[, sce$sample_name %in% c('151673', '151674')] #' #' ## Obtain the plot list #' p_list <- @@ -40,6 +40,9 @@ #' colors = libd_layer_colors #' ) #' +#' ## Clean up +#' rm(sce_sub) +#' #' ## Visualize the spatial adjacent replicates for position = 0 micro meters #' ## for subject 3 #' cowplot::plot_grid(plotlist = p_list, ncol = 2) diff --git a/R/sce_image_grid_gene.R b/R/sce_image_grid_gene.R index 166d9c63..82c1b672 100644 --- a/R/sce_image_grid_gene.R +++ b/R/sce_image_grid_gene.R @@ -19,10 +19,10 @@ #' @examples #' #' ## Obtain the necessary data -#' if (!exists('ori_sce')) ori_sce <- fetch_data('sce') +#' if (!exists('sce')) sce <- fetch_data('sce') #' #' ## Subset to two samples of interest -#' sce_sub <- ori_sce[, ori_sce$sample_name %in% c('151673', '151674')] +#' sce_sub <- sce[, sce$sample_name %in% c('151673', '151674')] #' #' ## Obtain the plot list #' p_list <- @@ -32,9 +32,13 @@ #' return_plots = TRUE #' ) #' +#' ## Clean up +#' rm(sce_sub) +#' #' ## Visualize the spatial adjacent replicates for position = 0 micro meters #' ## for subject 3 #' cowplot::plot_grid(plotlist = p_list, ncol = 2) +#' sce_image_grid_gene <- function(sce, diff --git a/R/sig_genes_extract.R b/R/sig_genes_extract.R index a0f5a380..440da786 100644 --- a/R/sig_genes_extract.R +++ b/R/sig_genes_extract.R @@ -42,21 +42,21 @@ #' @examples #' #' ## Obtain the necessary data -#' if (!exists('ori_modeling_results')) -#' ori_modeling_results <- fetch_data(type = 'modeling_results') -#' if (!exists('ori_sce_layer')) ori_sce_layer <- fetch_data(type = 'sce_layer') +#' if (!exists('modeling_results')) +#' modeling_results <- fetch_data(type = 'modeling_results') +#' if (!exists('sce_layer')) sce_layer <- fetch_data(type = 'sce_layer') #' #' ## anova top 10 genes #' sig_genes_extract( -#' modeling_results = ori_modeling_results, -#' sce_layer = ori_sce_layer +#' modeling_results = modeling_results, +#' sce_layer = sce_layer #' ) #' #' ## Extract all genes #' sig_genes_extract( -#' modeling_results = ori_modeling_results, -#' sce_layer = ori_sce_layer, -#' n = nrow(ori_sce_layer) +#' modeling_results = modeling_results, +#' sce_layer = sce_layer, +#' n = nrow(sce_layer) #' ) #' diff --git a/R/sig_genes_extract_all.R b/R/sig_genes_extract_all.R index 46be2a05..b0d673ac 100644 --- a/R/sig_genes_extract_all.R +++ b/R/sig_genes_extract_all.R @@ -17,14 +17,14 @@ #' @examples #' #' ## Obtain the necessary data -#' if (!exists('ori_modeling_results')) -#' ori_modeling_results <- fetch_data(type = 'modeling_results') -#' if (!exists('ori_sce_layer')) ori_sce_layer <- fetch_data(type = 'sce_layer') +#' if (!exists('modeling_results')) +#' modeling_results <- fetch_data(type = 'modeling_results') +#' if (!exists('sce_layer')) sce_layer <- fetch_data(type = 'sce_layer') #' #' ## top 10 genes for all models #' sig_genes_extract_all( -#' modeling_results = ori_modeling_results, -#' sce_layer = ori_sce_layer +#' modeling_results = modeling_results, +#' sce_layer = sce_layer #' ) #' diff --git a/app.R b/app.R index 87df93a3..e9eeae3f 100644 --- a/app.R +++ b/app.R @@ -14,23 +14,23 @@ options("golem.app.prod" = TRUE) ## In this case, I'm using my local files instead of downloading them ## by telling fetch_data(destdir) where my local files are stored at. -ori_sce <- +if (!exists('sce')) sce <- fetch_data('sce', here::here('data-raw/spatialLIBD_files')) -ori_sce_layer <- +if (!exists('sce_layer')) sce_layer <- fetch_data('sce_layer', here::here('data-raw/spatialLIBD_files')) -ori_modeling_results <- +if (!exists('modeling_results')) modeling_results <- fetch_data('modeling_results', here::here('data-raw/spatialLIBD_files')) -ori_sig_genes <- - sig_genes_extract_all(n = nrow(ori_sce_layer), - ori_modeling_results, - sce_layer = ori_sce_layer) +sig_genes <- + sig_genes_extract_all(n = nrow(sce_layer), + modeling_results, + sce_layer = sce_layer) options(repos = BiocManager::repositories()) spatialLIBD::run_app( - sce = ori_sce, - sce_layer = ori_sce_layer, - modeling_results = ori_modeling_results, - sig_genes = ori_sig_genes, + sce = sce, + sce_layer = sce_layer, + modeling_results = modeling_results, + sig_genes = sig_genes, ) # add parameters here (if any) diff --git a/data-raw/asd_sfari_geneList.R b/data-raw/asd_sfari_geneList.R index f223701d..969ff122 100644 --- a/data-raw/asd_sfari_geneList.R +++ b/data-raw/asd_sfari_geneList.R @@ -53,17 +53,17 @@ testthat::expect_equivalent(asd_sfari_geneList_table, as.matrix(test)) ## Test that the input data works for gene_set_enrichment() -if (!exists('ori_modeling_results')) - ori_modeling_results <- fetch_data(type = 'modeling_results') +if (!exists('modeling_results')) + modeling_results <- fetch_data(type = 'modeling_results') asd_sfari_enrichment <- gene_set_enrichment( gene_list = asd_sfari_geneList, - modeling_results = ori_modeling_results, + modeling_results = modeling_results, model_type = 'enrichment' ) test_enrichment <- gene_set_enrichment( gene_list = test, - modeling_results = ori_modeling_results, + modeling_results = modeling_results, model_type = 'enrichment' ) diff --git a/data-raw/logo.R b/data-raw/logo.R index 365e6052..ba7439ee 100644 --- a/data-raw/logo.R +++ b/data-raw/logo.R @@ -1,12 +1,12 @@ library('spatialLIBD') ## Obtain the necessary data -if (!exists('ori_sce')) ori_sce <- fetch_data('sce') +if (!exists('sce')) sce <- fetch_data('sce') pdf(here::here('data-raw', 'logo.pdf'), useDingbats = FALSE) sce_image_clus( - sce = ori_sce, + sce = sce, clustervar = 'layer_guess_reordered', sampleid = '151673', colors = libd_layer_colors, diff --git a/inst/scripts/make-data_spatialLIBD.R b/inst/scripts/make-data_spatialLIBD.R index ce7814a3..099611e2 100644 --- a/inst/scripts/make-data_spatialLIBD.R +++ b/inst/scripts/make-data_spatialLIBD.R @@ -261,23 +261,23 @@ colnames(colData(sce))[colnames(colData(sce)) == 'Cluster10X'] <- 'GraphBased' ## Double check that it all works! -# ori_sce_layer <- +# sce_layer <- # fetch_data('sce_layer', here::here('data-raw/spatialLIBD_files')) -# ori_modeling_results <- +# modeling_results <- # fetch_data('modeling_results', # here::here('data-raw/spatialLIBD_files')) # -# ori_sig_genes <- -# sig_genes_extract_all(n = nrow(ori_sce_layer), -# ori_modeling_results, -# sce_layer = ori_sce_layer) +# sig_genes <- +# sig_genes_extract_all(n = nrow(sce_layer), +# modeling_results, +# sce_layer = sce_layer) # # # spatialLIBD::run_app( # sce = sce, -# sce_layer = ori_sce_layer, -# modeling_results = ori_modeling_results, -# sig_genes = ori_sig_genes, +# sce_layer = sce_layer, +# modeling_results = modeling_results, +# sig_genes = sig_genes, # sce_discrete_vars = c('GraphBased', # 'Layer', # 'Maynard', diff --git a/man/check_image_path.Rd b/man/check_image_path.Rd index 284000ea..d9f28a69 100644 --- a/man/check_image_path.Rd +++ b/man/check_image_path.Rd @@ -29,13 +29,13 @@ structure. For more details please check the vignette documentation. \examples{ ## Obtain the necessary data -if (!exists('ori_sce')) ori_sce <- fetch_data('sce') +if (!exists('sce')) sce <- fetch_data('sce') ## Get the path to the images img_path <- system.file('app', 'www', 'data', package = 'spatialLIBD') ## Check the object -check_image_path(img_path, ori_sce) +check_image_path(img_path, sce) } \seealso{ diff --git a/man/check_modeling_results.Rd b/man/check_modeling_results.Rd index cef34495..0d80535a 100644 --- a/man/check_modeling_results.Rd +++ b/man/check_modeling_results.Rd @@ -23,11 +23,11 @@ For more details please check the vignette documentation. } \examples{ -if (!exists('ori_modeling_results')) - ori_modeling_results <- fetch_data(type = 'modeling_results') +if (!exists('modeling_results')) + modeling_results <- fetch_data(type = 'modeling_results') ## Check the object -xx <- check_modeling_results(ori_modeling_results) +xx <- check_modeling_results(modeling_results) } \seealso{ diff --git a/man/check_sce.Rd b/man/check_sce.Rd index 14bd850b..c6db4c09 100644 --- a/man/check_sce.Rd +++ b/man/check_sce.Rd @@ -36,10 +36,10 @@ For more details please check the vignette documentation. \examples{ ## Obtain the necessary data -if (!exists('ori_sce')) ori_sce <- fetch_data('sce') +if (!exists('sce')) sce <- fetch_data('sce') ## Check the object -check_sce(ori_sce) +check_sce(sce) } \seealso{ diff --git a/man/check_sce_layer.Rd b/man/check_sce_layer.Rd index 82f6f754..22101e2e 100644 --- a/man/check_sce_layer.Rd +++ b/man/check_sce_layer.Rd @@ -26,10 +26,10 @@ For more details please check the vignette documentation. \examples{ ## Obtain the necessary data -if (!exists('ori_sce_layer')) ori_sce_layer <- fetch_data('sce_layer') +if (!exists('sce_layer')) sce_layer <- fetch_data('sce_layer') ## Check the object -check_sce_layer(ori_sce_layer) +check_sce_layer(sce_layer) } \seealso{ diff --git a/man/fetch_data.Rd b/man/fetch_data.Rd index fd6cdd12..65d4b05a 100644 --- a/man/fetch_data.Rd +++ b/man/fetch_data.Rd @@ -53,7 +53,7 @@ https://github.com/LieberInstitute/spatialLIBD/blob/master/inst/scripts/make-dat ## Download the SingleCellExperiment object ## at the layer-level -sce_layer <- fetch_data('sce_layer') +if (!exists('sce_layer')) sce_layer <- fetch_data('sce_layer') ## Explore the data sce_layer diff --git a/man/gene_set_enrichment.Rd b/man/gene_set_enrichment.Rd index 0e198513..8a942e21 100644 --- a/man/gene_set_enrichment.Rd +++ b/man/gene_set_enrichment.Rd @@ -73,13 +73,13 @@ asd_sfari_geneList <- list( ) ## Obtain the necessary data -if (!exists('ori_modeling_results')) - ori_modeling_results <- fetch_data(type = 'modeling_results') +if (!exists('modeling_results')) + modeling_results <- fetch_data(type = 'modeling_results') ## Compute the gene set enrichment results asd_sfari_enrichment <- gene_set_enrichment( gene_list = asd_sfari_geneList, - modeling_results = ori_modeling_results, + modeling_results = modeling_results, model_type = 'enrichment' ) diff --git a/man/gene_set_enrichment_plot.Rd b/man/gene_set_enrichment_plot.Rd index fd3a1260..783fdf55 100644 --- a/man/gene_set_enrichment_plot.Rd +++ b/man/gene_set_enrichment_plot.Rd @@ -75,13 +75,13 @@ asd_sfari_geneList <- list( ) ## Obtain the necessary data -if (!exists('ori_modeling_results')) - ori_modeling_results <- fetch_data(type = 'modeling_results') +if (!exists('modeling_results')) + modeling_results <- fetch_data(type = 'modeling_results') ## Compute the gene set enrichment results asd_sfari_enrichment <- gene_set_enrichment( gene_list = asd_sfari_geneList, - modeling_results = ori_modeling_results, + modeling_results = modeling_results, model_type = 'enrichment' ) diff --git a/man/geom_spatial.Rd b/man/geom_spatial.Rd index 051fd5a5..66b638bf 100644 --- a/man/geom_spatial.Rd +++ b/man/geom_spatial.Rd @@ -44,11 +44,11 @@ as in \code{\link[=sce_image_gene_p]{sce_image_gene_p()}}. } \examples{ ## Obtain the necessary data -if (!exists('ori_sce')) ori_sce <- fetch_data('sce') +if (!exists('sce')) sce <- fetch_data('sce') ## Select the first sample and extract the data -sample_id <- unique(ori_sce$sample_name)[1] -sce_sub <- ori_sce[, ori_sce$sample_name == sample_id] +sample_id <- unique(sce$sample_name)[1] +sce_sub <- sce[, sce$sample_name == sample_id] sample_df <- as.data.frame(colData(sce_sub)) ## Make a plot using geom_spatial @@ -64,6 +64,9 @@ ggplot2::ggplot(sample_df, y = 0.5 ) +## Clean up +rm(sce_sub) + } \author{ 10x Genomics diff --git a/man/get_colors.Rd b/man/get_colors.Rd index db57cc12..5909f180 100644 --- a/man/get_colors.Rd +++ b/man/get_colors.Rd @@ -27,15 +27,15 @@ names. It can be used to automatically assign colors. \examples{ ## Obtain the necessary data -if (!exists('ori_sce_layer')) ori_sce_layer <- fetch_data('sce') +if (!exists('sce_layer')) sce_layer <- fetch_data('sce') ## Example layer colors with the corresponding names -get_colors(libd_layer_colors, ori_sce_layer$layer_guess) -get_colors(libd_layer_colors, ori_sce_layer$layer_guess_reordered_short) +get_colors(libd_layer_colors, sce_layer$layer_guess) +get_colors(libd_layer_colors, sce_layer$layer_guess_reordered_short) ## Example where colors are assigned automatically ## based on a pre-defined set of colors -get_colors(clusters = ori_sce_layer$kmeans_k7) +get_colors(clusters = sce_layer$kmeans_k7) ## Example where Polychrome::palette36.colors() gets used get_colors(clusters = letters[seq_len(13)]) diff --git a/man/layer_boxplot.Rd b/man/layer_boxplot.Rd index e9575709..cd557df9 100644 --- a/man/layer_boxplot.Rd +++ b/man/layer_boxplot.Rd @@ -66,39 +66,39 @@ of a given gene and display the modeling results for the given gene. \examples{ ## Obtain the necessary data -if (!exists('ori_modeling_results')) - ori_modeling_results <- fetch_data(type = 'modeling_results') -if (!exists('ori_sce_layer')) ori_sce_layer <- fetch_data(type = 'sce_layer') +if (!exists('modeling_results')) + modeling_results <- fetch_data(type = 'modeling_results') +if (!exists('sce_layer')) sce_layer <- fetch_data(type = 'sce_layer') ## Top 2 genes from the enrichment model sig_genes <- sig_genes_extract_all(n = 2, - modeling_results = ori_modeling_results, - sce_layer = ori_sce_layer) + modeling_results = modeling_results, + sce_layer = sce_layer) ## Example default boxplot -layer_boxplot(sig_genes = sig_genes, sce_layer = ori_sce_layer) +layer_boxplot(sig_genes = sig_genes, sce_layer = sce_layer) ## Now show the long title version layer_boxplot(sig_genes = sig_genes, short_title = FALSE, - sce_layer = ori_sce_layer) + sce_layer = sce_layer) layer_boxplot( i = which(sig_genes$model_type == 'anova')[1], sig_genes = sig_genes, - sce_layer = ori_sce_layer + sce_layer = sce_layer ) layer_boxplot( i = which(sig_genes$model_type == 'pairwise')[1], sig_genes = sig_genes, - sce_layer = ori_sce_layer + sce_layer = sce_layer ) ## Viridis colors displayed in the shiny app library('viridisLite') layer_boxplot( sig_genes = sig_genes, - sce_layer = ori_sce_layer, + sce_layer = sce_layer, col_low_box = viridis(4)[2], col_low_point = viridis(4)[1], col_high_box = viridis(4)[3], @@ -108,7 +108,7 @@ layer_boxplot( ## Paper colors displayed in the shiny app layer_boxplot( sig_genes = sig_genes, - sce_layer = ori_sce_layer, + sce_layer = sce_layer, col_low_box = 'palegreen3', col_low_point = 'springgreen2', col_high_box = 'darkorange2', @@ -119,7 +119,7 @@ layer_boxplot( layer_boxplot( i = which(sig_genes$model_type == 'pairwise')[1], sig_genes = sig_genes, - sce_layer = ori_sce_layer, + sce_layer = sce_layer, col_bkg_box = 'grey90', col_bkg_point = 'grey60', col_low_box = 'lightcyan', diff --git a/man/layer_stat_cor.Rd b/man/layer_stat_cor.Rd index f8409a3f..88281b9c 100644 --- a/man/layer_stat_cor.Rd +++ b/man/layer_stat_cor.Rd @@ -56,13 +56,13 @@ for a full analysis from which this family of functions is derived from. \examples{ ## Obtain the necessary data -if (!exists('ori_modeling_results')) - ori_modeling_results <- fetch_data(type = 'modeling_results') +if (!exists('modeling_results')) + modeling_results <- fetch_data(type = 'modeling_results') ## Compute the correlations cor_stats_layer <- layer_stat_cor( tstats_Human_DLPFC_snRNAseq_Nguyen_topLayer, - ori_modeling_results, + modeling_results, 'enrichment' ) diff --git a/man/layer_stat_cor_plot.Rd b/man/layer_stat_cor_plot.Rd index 51a79652..36cdc336 100644 --- a/man/layer_stat_cor_plot.Rd +++ b/man/layer_stat_cor_plot.Rd @@ -45,13 +45,13 @@ for a full analysis from which this family of functions is derived from. \examples{ ## Obtain the necessary data -if (!exists('ori_modeling_results')) - ori_modeling_results <- fetch_data(type = 'modeling_results') +if (!exists('modeling_results')) + modeling_results <- fetch_data(type = 'modeling_results') ## Compute the correlations cor_stats_layer <- layer_stat_cor( tstats_Human_DLPFC_snRNAseq_Nguyen_topLayer, - ori_modeling_results, + modeling_results, 'enrichment' ) diff --git a/man/sce_image_clus.Rd b/man/sce_image_clus.Rd index 02b11308..4bfb14b8 100644 --- a/man/sce_image_clus.Rd +++ b/man/sce_image_clus.Rd @@ -53,14 +53,14 @@ data and title for \code{\link[=sce_image_clus_p]{sce_image_clus_p()}}. \examples{ ## Obtain the necessary data -if (!exists('ori_sce')) ori_sce <- fetch_data('sce') +if (!exists('sce')) sce <- fetch_data('sce') ## Check the colors defined by Lukas M Weber libd_layer_colors ## Use the manual color palette by Lukas M Weber sce_image_clus( - sce = ori_sce, + sce = sce, clustervar = 'layer_guess_reordered', sampleid = '151673', colors = libd_layer_colors, @@ -69,7 +69,7 @@ sce_image_clus( ## Without histology sce_image_clus( - sce = ori_sce, + sce = sce, clustervar = 'layer_guess_reordered', sampleid = '151673', colors = libd_layer_colors, diff --git a/man/sce_image_clus_p.Rd b/man/sce_image_clus_p.Rd index 5bbd6002..0ff14ed9 100644 --- a/man/sce_image_clus_p.Rd +++ b/man/sce_image_clus_p.Rd @@ -44,8 +44,8 @@ gene-level (or any continuous variable) use \code{\link[=sce_image_gene_p]{sce_i \examples{ ## Obtain the necessary data -if (!exists('ori_sce')) ori_sce <- fetch_data('sce') -sce_sub <- ori_sce[, ori_sce$sample_name == '151673'] +if (!exists('sce')) sce <- fetch_data('sce') +sce_sub <- sce[, sce$sample_name == '151673'] ## Use the manual color palette by Lukas M Weber ## Don't plot the histology information @@ -59,6 +59,9 @@ sce_image_clus_p( spatial = FALSE ) +## Clean up +rm(sce_sub) + } \seealso{ Other Spatial cluster visualization functions: diff --git a/man/sce_image_gene.Rd b/man/sce_image_gene.Rd index b4c3f876..57457dc5 100644 --- a/man/sce_image_gene.Rd +++ b/man/sce_image_gene.Rd @@ -66,15 +66,15 @@ data and title for \code{\link[=sce_image_gene_p]{sce_image_gene_p()}}. It also \examples{ ## Obtain the necessary data -if (!exists('ori_sce')) ori_sce <- fetch_data('sce') +if (!exists('sce')) sce <- fetch_data('sce') ## Valid `geneid` values are those in -head(rowData(ori_sce)$gene_search) -## or continuous variables stored in colData(ori_sce) +head(rowData(sce)$gene_search) +## or continuous variables stored in colData(sce) ## Visualize a default gene on the non-viridis scale sce_image_gene( - sce = ori_sce, + sce = sce, sampleid = '151507', viridis = FALSE ) @@ -82,7 +82,7 @@ sce_image_gene( ## Visualize a continuous variable, in this case, the ratio of chrM ## gene expression compared to the total expression at the spot-level sce_image_gene( - sce = ori_sce, + sce = sce, sampleid = '151507', geneid = 'expr_chrM_ratio' ) diff --git a/man/sce_image_gene_p.Rd b/man/sce_image_gene_p.Rd index d31d1799..29079be9 100644 --- a/man/sce_image_gene_p.Rd +++ b/man/sce_image_gene_p.Rd @@ -46,10 +46,10 @@ To visualize clusters (or any discrete variable) use \code{\link[=sce_image_clus \examples{ ## Obtain the necessary data -if (!exists('ori_sce')) ori_sce <- fetch_data('sce') +if (!exists('sce')) sce <- fetch_data('sce') ## Prepare the data for the plotting function -sce_sub <- ori_sce[, ori_sce$sample_name == '151673'] +sce_sub <- sce[, sce$sample_name == '151673'] df <- as.data.frame(colData(sce_sub)) df$COUNT <- df$expr_chrM_ratio @@ -63,6 +63,9 @@ sce_image_gene_p( spatial = FALSE ) +## Clean up +rm(sce_sub) + } \seealso{ Other Spatial gene visualization functions: diff --git a/man/sce_image_grid.Rd b/man/sce_image_grid.Rd index 7f1fba67..3d9b6c01 100644 --- a/man/sce_image_grid.Rd +++ b/man/sce_image_grid.Rd @@ -61,10 +61,10 @@ objects. \examples{ ## Obtain the necessary data -if (!exists('ori_sce')) ori_sce <- fetch_data('sce') +if (!exists('sce')) sce <- fetch_data('sce') ## Subset to two samples of interest -sce_sub <- ori_sce[, ori_sce$sample_name \%in\% c('151673', '151674')] +sce_sub <- sce[, sce$sample_name \%in\% c('151673', '151674')] ## Obtain the plot list p_list <- @@ -77,6 +77,9 @@ p_list <- colors = libd_layer_colors ) +## Clean up +rm(sce_sub) + ## Visualize the spatial adjacent replicates for position = 0 micro meters ## for subject 3 cowplot::plot_grid(plotlist = p_list, ncol = 2) diff --git a/man/sce_image_grid_gene.Rd b/man/sce_image_grid_gene.Rd index 5a2491cd..a0bc45c2 100644 --- a/man/sce_image_grid_gene.Rd +++ b/man/sce_image_grid_gene.Rd @@ -71,10 +71,10 @@ objects. \examples{ ## Obtain the necessary data -if (!exists('ori_sce')) ori_sce <- fetch_data('sce') +if (!exists('sce')) sce <- fetch_data('sce') ## Subset to two samples of interest -sce_sub <- ori_sce[, ori_sce$sample_name \%in\% c('151673', '151674')] +sce_sub <- sce[, sce$sample_name \%in\% c('151673', '151674')] ## Obtain the plot list p_list <- @@ -84,9 +84,13 @@ p_list <- return_plots = TRUE ) +## Clean up +rm(sce_sub) + ## Visualize the spatial adjacent replicates for position = 0 micro meters ## for subject 3 cowplot::plot_grid(plotlist = p_list, ncol = 2) + } \seealso{ Other Spatial gene visualization functions: diff --git a/man/sig_genes_extract.Rd b/man/sig_genes_extract.Rd index 599d1ee8..b0f5dfe8 100644 --- a/man/sig_genes_extract.Rd +++ b/man/sig_genes_extract.Rd @@ -56,21 +56,21 @@ informative titles. \examples{ ## Obtain the necessary data -if (!exists('ori_modeling_results')) - ori_modeling_results <- fetch_data(type = 'modeling_results') -if (!exists('ori_sce_layer')) ori_sce_layer <- fetch_data(type = 'sce_layer') +if (!exists('modeling_results')) + modeling_results <- fetch_data(type = 'modeling_results') +if (!exists('sce_layer')) sce_layer <- fetch_data(type = 'sce_layer') ## anova top 10 genes sig_genes_extract( - modeling_results = ori_modeling_results, - sce_layer = ori_sce_layer + modeling_results = modeling_results, + sce_layer = sce_layer ) ## Extract all genes sig_genes_extract( - modeling_results = ori_modeling_results, - sce_layer = ori_sce_layer, - n = nrow(ori_sce_layer) + modeling_results = modeling_results, + sce_layer = sce_layer, + n = nrow(sce_layer) ) } diff --git a/man/sig_genes_extract_all.Rd b/man/sig_genes_extract_all.Rd index 4b49c9e0..812a21b7 100644 --- a/man/sig_genes_extract_all.Rd +++ b/man/sig_genes_extract_all.Rd @@ -39,14 +39,14 @@ functions such as \code{\link[=layer_boxplot]{layer_boxplot()}}. \examples{ ## Obtain the necessary data -if (!exists('ori_modeling_results')) - ori_modeling_results <- fetch_data(type = 'modeling_results') -if (!exists('ori_sce_layer')) ori_sce_layer <- fetch_data(type = 'sce_layer') +if (!exists('modeling_results')) + modeling_results <- fetch_data(type = 'modeling_results') +if (!exists('sce_layer')) sce_layer <- fetch_data(type = 'sce_layer') ## top 10 genes for all models sig_genes_extract_all( - modeling_results = ori_modeling_results, - sce_layer = ori_sce_layer + modeling_results = modeling_results, + sce_layer = sce_layer ) } diff --git a/man/spatialLIBD-package.Rd b/man/spatialLIBD-package.Rd index b263c917..6e9fd388 100644 --- a/man/spatialLIBD-package.Rd +++ b/man/spatialLIBD-package.Rd @@ -25,6 +25,7 @@ Useful links: Other contributors: \itemize{ + \item Kristen R. Maynard \email{Kristen.Maynard@libd.org} (\href{https://orcid.org/0000-0003-0031-8468}{ORCID}) [contributor] \item Andrew E. Jaffe \email{andrew.jaffe@libd.org} (\href{https://orcid.org/0000-0001-6886-1454}{ORCID}) [contributor] } diff --git a/vignettes/spatialLIBD.Rmd b/vignettes/spatialLIBD.Rmd index 80fb0779..86533ea5 100644 --- a/vignettes/spatialLIBD.Rmd +++ b/vignettes/spatialLIBD.Rmd @@ -188,7 +188,7 @@ ehub <- ExperimentHub::ExperimentHub() ## Maybe subsetting the sce object will help ## with the memory issues at ## https://travis-ci.com/LieberInstitute/spatialLIBD/builds/150177257?utm_medium=notification&utm_source=slack -sce <- fetch_data(type = 'sce', eh = ehub) +if (!exists('sce')) sce <- fetch_data(type = 'sce', eh = ehub) pryr::object_size(sce) # 2.08 # GB @@ -220,7 +220,7 @@ system(paste('ls -lh', here::here('data-raw', 'sce_sub_for_vignette.Rdata'))) ```{r 'download_fake', eval = FALSE} ## Query ExperimentHub and download the data -sce <- fetch_data(type = 'sce', eh = ehub) +if (!exists('sce')) sce <- fetch_data(type = 'sce', eh = ehub) ``` @@ -237,12 +237,12 @@ vignette_data <- function(destdir = tempdir()) { load(file_path, verbose = FALSE) return(sce_sub) } -sce <- vignette_data() +if (!exists('sce')) sce <- vignette_data() ``` ```{r 'download_rest'} -sce_layer <- fetch_data(type = 'sce_layer', eh = ehub) +if (!exists('sce_layer')) sce_layer <- fetch_data(type = 'sce_layer', eh = ehub) modeling_results <- fetch_data('modeling_results', eh = ehub) ```