From f25860feda852255423fe315fd99a13f0b0db6a8 Mon Sep 17 00:00:00 2001 From: lcolladotor Date: Thu, 9 May 2024 10:44:47 -0400 Subject: [PATCH 01/28] Update citation info for spatialDLPFC --- inst/CITATION | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/inst/CITATION b/inst/CITATION index 36731c8c..bc6d454d 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -45,7 +45,7 @@ c( url = "https://www.nature.com/articles/s41593-020-00787-0" ), bibentry(bibtype="article", - title = "Integrated single cell and unsupervised spatial transcriptomic analysis defines molecular anatomy of the human dorsolateral prefrontal cortex", + title = "A data-driven single-cell and spatial transcriptomic map of the human prefrontal cortex", author = personList( as.person("Louise A. Huuki-Myers"), as.person("Abby Spangler"), @@ -72,10 +72,10 @@ c( as.person("Leonardo Collado-Torres"), as.person("Kristen R. Maynard") ), - year = 2023, - journal = "bioRxiv", - doi = "10.1101/2023.02.15.528722", - url = "https://www.biorxiv.org/content/10.1101/2023.02.15.528722v1" + year = 2024, + journal = "Science", + doi = "10.1126/science.adh1938", + url = "https://doi.org/10.1126/science.adh1938" ), bibentry(bibtype="article", title = "Influence of Alzheimer’s disease related neuropathology on local microenvironment gene expression in the human inferior temporal cortex", From a3cbd4022573a27b676fcce57bfa473d333912fb Mon Sep 17 00:00:00 2001 From: lcolladotor Date: Fri, 24 May 2024 00:51:37 -0400 Subject: [PATCH 02/28] Update README with some videos + link to blog posts + fix citation info displayed. --- README.Rmd | 10 ++ README.md | 77 +++++++++----- inst/app/www/README.md | 229 +++++++++++++++++++++++++++++++---------- 3 files changed, 231 insertions(+), 85 deletions(-) diff --git a/README.Rmd b/README.Rmd index 27248ae7..573bd17d 100644 --- a/README.Rmd +++ b/README.Rmd @@ -70,6 +70,16 @@ spatialLIBD::run_app() * [Main shiny application website](http://spatial.libd.org/spatialLIBD/) (note that the link must have a trailing slash `/` for it to work) * [Shinyapps](https://libd.shinyapps.io/spatialLIBD/) This version has less RAM memory but is typically deployed using the latest version of `spatialLIBD`. +## Introductory material + +If you prefer to watch a video overview of the `HumanPilot` project, check the following journal club presentation of the main results. + + + +You might also be interested in the explainer video and [companion blog post](https://lcolladotor.github.io/2024/05/23/humanpilot-first-spatially-resolved-transcriptomics-study-using-visium/) as well as [the original Feb 29, 2020 blog post](https://lcolladotor.github.io/2020/02/29/diving-together-into-the-unknown-world-of-spatial-transcriptomics/) from when we first made this project public. + + + ## R/Bioconductor package The `spatialLIBD` package contains functions for: diff --git a/README.md b/README.md index b15cfbdc..23a0513e 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,23 @@ spatialLIBD::run_app() less RAM memory but is typically deployed using the latest version of `spatialLIBD`. +## Introductory material + +If you prefer to watch a video overview of the `HumanPilot` project, +check the following journal club presentation of the main results. + + + +You might also be interested in the explainer video and [companion blog +post](https://lcolladotor.github.io/2024/05/23/humanpilot-first-spatially-resolved-transcriptomics-study-using-visium/) +as well as [the original Feb 29, 2020 blog +post](https://lcolladotor.github.io/2020/02/29/diving-together-into-the-unknown-world-of-spatial-transcriptomics/) +from when we first made this project public. + + + ## R/Bioconductor package The `spatialLIBD` package contains functions for: @@ -198,10 +215,16 @@ spe #> altExpNames(0): #> spatialCoords names(2) : pxl_col_in_fullres pxl_row_in_fullres #> imgData names(4): sample_id image_id data scaleFactor +``` + +``` r ## Note the memory size lobstr::obj_size(spe) #> 2.04 GB +``` + +``` r ## Remake the logo image with histology information vis_clus( @@ -222,20 +245,20 @@ You can access all the raw data through Furthermore, below you can find the links to the raw data we received from 10x Genomics. -| SampleID | h5_filtered | h5_raw | image_full | image_hi | image_lo | loupe | HTML_report | -|---------:|:------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------| -| 151507 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151507_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151507_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151507_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151507_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151507_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151507.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151507/151507_web_summary.html) | -| 151508 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151508_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151508_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151508_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151508_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151508_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151508.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151508/151508_web_summary.html) | -| 151509 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151509_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151509_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151509_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151509_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151509_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151509.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151509/151509_web_summary.html) | -| 151510 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151510_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151510_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151510_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151510_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151510_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151510.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151510/151510_web_summary.html) | -| 151669 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151669_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151669_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151669_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151669_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151669_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151669.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151669/151669_web_summary.html) | -| 151670 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151670_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151670_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151670_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151670_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151670_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151670.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151670/151670_web_summary.html) | -| 151671 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151671_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151671_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151671_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151671_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151671_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151671.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151671/151671_web_summary.html) | -| 151672 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151672_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151672_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151672_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151672_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151672_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151672.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151672/151672_web_summary.html) | -| 151673 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151673_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151673_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151673_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151673_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151673_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151673.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151673/151673_web_summary.html) | -| 151674 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151674_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151674_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151674_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151674_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151674_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151674.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151674/151674_web_summary.html) | -| 151675 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151675_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151675_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151675_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151675_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151675_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151675.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151675/151675_web_summary.html) | -| 151676 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151676_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151676_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151676_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151676_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151676_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151676.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151676/151676_web_summary.html) | +| SampleID | h5_filtered | h5_raw | image_full | image_hi | image_lo | loupe | HTML_report | +|---:|:---|:---|:---|:---|:---|:---|:---| +| 151507 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151507_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151507_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151507_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151507_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151507_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151507.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151507/151507_web_summary.html) | +| 151508 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151508_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151508_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151508_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151508_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151508_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151508.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151508/151508_web_summary.html) | +| 151509 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151509_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151509_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151509_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151509_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151509_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151509.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151509/151509_web_summary.html) | +| 151510 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151510_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151510_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151510_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151510_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151510_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151510.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151510/151510_web_summary.html) | +| 151669 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151669_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151669_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151669_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151669_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151669_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151669.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151669/151669_web_summary.html) | +| 151670 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151670_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151670_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151670_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151670_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151670_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151670.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151670/151670_web_summary.html) | +| 151671 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151671_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151671_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151671_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151671_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151671_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151671.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151671/151671_web_summary.html) | +| 151672 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151672_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151672_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151672_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151672_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151672_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151672.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151672/151672_web_summary.html) | +| 151673 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151673_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151673_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151673_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151673_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151673_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151673.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151673/151673_web_summary.html) | +| 151674 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151674_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151674_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151674_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151674_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151674_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151674.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151674/151674_web_summary.html) | +| 151675 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151675_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151675_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151675_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151675_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151675_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151675.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151675/151675_web_summary.html) | +| 151676 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151676_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151676_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151676_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151676_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151676_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151676.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151676/151676_web_summary.html) | ## Citation @@ -289,22 +312,21 @@ print(citation("spatialLIBD"), bibtex = TRUE) #> B, Grant-Peters M, Divecha HR, Tippani M, Sriworarat C, Nguyen AB, #> Ravichandran P, Tran MN, Seyedian A, Consortium P, Hyde TM, Kleinman #> JE, Battle A, Page SC, Ryten M, Hicks SC, Martinowich K, -#> Collado-Torres L, Maynard KR (2023). "Integrated single cell and -#> unsupervised spatial transcriptomic analysis defines molecular -#> anatomy of the human dorsolateral prefrontal cortex." _bioRxiv_. -#> doi:10.1101/2023.02.15.528722 -#> , -#> . +#> Collado-Torres L, Maynard KR (2024). "A data-driven single-cell and +#> spatial transcriptomic map of the human prefrontal cortex." +#> _Science_. doi:10.1126/science.adh1938 +#> , +#> . #> #> A BibTeX entry for LaTeX users is #> #> @Article{, -#> title = {Integrated single cell and unsupervised spatial transcriptomic analysis defines molecular anatomy of the human dorsolateral prefrontal cortex}, +#> title = {A data-driven single-cell and spatial transcriptomic map of the human prefrontal cortex}, #> author = {Louise A. Huuki-Myers and Abby Spangler and Nicholas J. Eagles and Kelsey D. Montgomergy and Sang Ho Kwon and Boyi Guo and Melissa Grant-Peters and Heena R. Divecha and Madhavi Tippani and Chaichontat Sriworarat and Annie B. Nguyen and Prashanthi Ravichandran and Matthew N. Tran and Arta Seyedian and PsychENCODE Consortium and Thomas M. Hyde and Joel E. Kleinman and Alexis Battle and Stephanie C. Page and Mina Ryten and Stephanie C. Hicks and Keri Martinowich and Leonardo Collado-Torres and Kristen R. Maynard}, -#> year = {2023}, -#> journal = {bioRxiv}, -#> doi = {10.1101/2023.02.15.528722}, -#> url = {https://www.biorxiv.org/content/10.1101/2023.02.15.528722v1}, +#> year = {2024}, +#> journal = {Science}, +#> doi = {10.1126/science.adh1938}, +#> url = {https://doi.org/10.1126/science.adh1938}, #> } #> #> Kwon SH, Parthiban S, Tippani M, Divecha HR, Eagles NJ, Lobana JS, @@ -349,7 +371,7 @@ By contributing to this project, you agree to abide by its terms. *[rcmdcheck](https://CRAN.R-project.org/package=rcmdcheck)* customized to use [Bioconductor’s docker containers](https://www.bioconductor.org/help/docker/) and - *[BiocCheck](https://bioconductor.org/packages/3.17/BiocCheck)*. + *[BiocCheck](https://bioconductor.org/packages/3.19/BiocCheck)*. - Code coverage assessment is possible thanks to [codecov](https://codecov.io/gh) and *[covr](https://CRAN.R-project.org/package=covr)*. @@ -366,7 +388,7 @@ By contributing to this project, you agree to abide by its terms. For more details, check the `dev` directory. This package was developed using -*[biocthis](https://bioconductor.org/packages/3.17/biocthis)*. +*[biocthis](https://bioconductor.org/packages/3.19/biocthis)*. @@ -379,6 +401,5 @@ This package was developed using window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); - gtag('config', 'G-QKT3SV9EFL'); diff --git a/inst/app/www/README.md b/inst/app/www/README.md index 5a4d943a..adb3c1b8 100644 --- a/inst/app/www/README.md +++ b/inst/app/www/README.md @@ -25,29 +25,31 @@ coverage](https://codecov.io/gh/LieberInstitute/spatialLIBD/branch/devel/graph/b status](https://github.com/LieberInstitute/spatialLIBD/workflows/R-CMD-check-bioc/badge.svg)](https://github.com/LieberInstitute/spatialLIBD/actions) [![GitHub issues](https://img.shields.io/github/issues/LieberInstitute/spatialLIBD)](https://github.com/LieberInstitute/spatialLIBD/issues) +[![GitHub +pulls](https://img.shields.io/github/issues-pr/LieberInstitute/spatialLIBD)](https://github.com/LieberInstitute/spatialLIBD/pulls) [![DOI](https://zenodo.org/badge/225913568.svg)](https://zenodo.org/badge/latestdoi/225913568) Welcome to the `spatialLIBD` project! It is composed of: -- a [shiny](https://shiny.rstudio.com/) web application that we are - hosting at - [spatial.libd.org/spatialLIBD/](http://spatial.libd.org/spatialLIBD/) - that can handle a - [limited](https://github.com/LieberInstitute/spatialLIBD/issues/2) - set of concurrent users, -- a Bioconductor package at - [bioconductor.org/packages/spatialLIBD](http://bioconductor.org/packages/spatialLIBD) - (or from [here](http://research.libd.org/spatialLIBD/)) that lets - you analyze the data and run a local version of our web application - (with our data or yours), -- and a [research article](https://doi.org/10.1038/s41593-020-00787-0) - with the scientific knowledge we drew from this dataset. The - analysis code for our project is available - [here](https://github.com/LieberInstitute/HumanPilot/) and the high - quality figures for the manuscript are available through - [Figshare](https://doi.org/10.6084/m9.figshare.13623902.v1). +- a [shiny](https://shiny.rstudio.com/) web application that we are + hosting at + [spatial.libd.org/spatialLIBD/](http://spatial.libd.org/spatialLIBD/) + that can handle a + [limited](https://github.com/LieberInstitute/spatialLIBD/issues/2) set + of concurrent users, +- a Bioconductor package at + [bioconductor.org/packages/spatialLIBD](http://bioconductor.org/packages/spatialLIBD) + (or from [here](http://research.libd.org/spatialLIBD/)) that lets you + analyze the data and run a local version of our web application (with + our data or yours), +- and a [research article](https://doi.org/10.1038/s41593-020-00787-0) + with the scientific knowledge we drew from this dataset. The analysis + code for our project is available + [here](https://github.com/LieberInstitute/HumanPilot/) and the high + quality figures for the manuscript are available through + [Figshare](https://doi.org/10.6084/m9.figshare.13623902.v1). The web application allows you to browse the LIBD human dorsolateral pre-frontal cortex (DLPFC) spatial transcriptomics data generated with @@ -115,19 +117,35 @@ spatialLIBD::run_app() less RAM memory but is typically deployed using the latest version of `spatialLIBD`. +## Introductory material + +If you prefer to watch a video overview of the `HumanPilot` project, +check the following journal club presentation of the main results. + + + +You might also be interested in the explainer video and [companion blog +post](https://lcolladotor.github.io/2024/05/23/humanpilot-first-spatially-resolved-transcriptomics-study-using-visium/) +as well as [the original Feb 29, 2020 blog +post](https://lcolladotor.github.io/2020/02/29/diving-together-into-the-unknown-world-of-spatial-transcriptomics/) +from when we first made this project public. + + + ## R/Bioconductor package The `spatialLIBD` package contains functions for: -- Accessing the spatial transcriptomics data from the LIBD Human Pilot - project ([code on - GitHub](https://github.com/LieberInstitute/HumanPilot)) generated - with the Visium platform from 10x Genomics. The data is retrieved - from [Bioconductor](http://bioconductor.org/)’s `ExperimentHub`. -- Visualizing the spot-level spatial gene expression data and - clusters. -- Inspecting the data interactively either on your computer or through - [spatial.libd.org/spatialLIBD/](http://spatial.libd.org/spatialLIBD/). +- Accessing the spatial transcriptomics data from the LIBD Human Pilot + project ([code on + GitHub](https://github.com/LieberInstitute/HumanPilot)) generated with + the Visium platform from 10x Genomics. The data is retrieved from + [Bioconductor](http://bioconductor.org/)’s `ExperimentHub`. +- Visualizing the spot-level spatial gene expression data and clusters. +- Inspecting the data interactively either on your computer or through + [spatial.libd.org/spatialLIBD/](http://spatial.libd.org/spatialLIBD/). For more details, please check the [documentation website](http://lieberinstitute.github.io/spatialLIBD) or the @@ -190,18 +208,23 @@ spe #> rowData names(9): source type ... gene_search is_top_hvg #> colnames(47681): AAACAACGAATAGTTC-1 AAACAAGTATCTCCCA-1 ... #> TTGTTTCCATACAACT-1 TTGTTTGTGTAAATTC-1 -#> colData names(66): sample_id Cluster ... spatialLIBD ManualAnnotation +#> colData names(69): sample_id Cluster ... array_row array_col #> reducedDimNames(6): PCA TSNE_perplexity50 ... TSNE_perplexity80 #> UMAP_neighbors15 #> mainExpName: NULL #> altExpNames(0): -#> spatialData names(3) : in_tissue array_row array_col #> spatialCoords names(2) : pxl_col_in_fullres pxl_row_in_fullres #> imgData names(4): sample_id image_id data scaleFactor +``` + +``` r ## Note the memory size -lobstr::obj_size(spe) +lobstr::obj_size(spe) #> 2.04 GB +``` + +``` r ## Remake the logo image with histology information vis_clus( @@ -222,20 +245,20 @@ You can access all the raw data through Furthermore, below you can find the links to the raw data we received from 10x Genomics. -| SampleID | h5\_filtered | h5\_raw | image\_full | image\_hi | image\_lo | loupe | HTML\_report | -|---------:|:------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------| -| 151507 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151507_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151507_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151507_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151507_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151507_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151507.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151507/151507_web_summary.html) | -| 151508 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151508_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151508_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151508_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151508_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151508_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151508.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151508/151508_web_summary.html) | -| 151509 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151509_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151509_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151509_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151509_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151509_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151509.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151509/151509_web_summary.html) | -| 151510 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151510_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151510_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151510_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151510_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151510_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151510.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151510/151510_web_summary.html) | -| 151669 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151669_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151669_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151669_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151669_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151669_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151669.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151669/151669_web_summary.html) | -| 151670 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151670_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151670_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151670_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151670_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151670_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151670.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151670/151670_web_summary.html) | -| 151671 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151671_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151671_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151671_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151671_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151671_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151671.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151671/151671_web_summary.html) | -| 151672 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151672_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151672_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151672_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151672_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151672_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151672.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151672/151672_web_summary.html) | -| 151673 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151673_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151673_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151673_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151673_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151673_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151673.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151673/151673_web_summary.html) | -| 151674 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151674_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151674_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151674_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151674_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151674_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151674.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151674/151674_web_summary.html) | -| 151675 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151675_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151675_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151675_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151675_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151675_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151675.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151675/151675_web_summary.html) | -| 151676 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151676_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151676_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151676_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151676_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151676_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151676.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151676/151676_web_summary.html) | +| SampleID | h5_filtered | h5_raw | image_full | image_hi | image_lo | loupe | HTML_report | +|---:|:---|:---|:---|:---|:---|:---|:---| +| 151507 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151507_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151507_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151507_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151507_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151507_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151507.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151507/151507_web_summary.html) | +| 151508 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151508_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151508_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151508_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151508_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151508_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151508.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151508/151508_web_summary.html) | +| 151509 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151509_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151509_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151509_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151509_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151509_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151509.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151509/151509_web_summary.html) | +| 151510 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151510_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151510_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151510_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151510_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151510_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151510.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151510/151510_web_summary.html) | +| 151669 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151669_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151669_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151669_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151669_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151669_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151669.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151669/151669_web_summary.html) | +| 151670 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151670_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151670_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151670_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151670_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151670_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151670.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151670/151670_web_summary.html) | +| 151671 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151671_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151671_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151671_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151671_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151671_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151671.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151671/151671_web_summary.html) | +| 151672 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151672_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151672_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151672_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151672_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151672_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151672.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151672/151672_web_summary.html) | +| 151673 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151673_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151673_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151673_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151673_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151673_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151673.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151673/151673_web_summary.html) | +| 151674 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151674_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151674_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151674_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151674_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151674_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151674.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151674/151674_web_summary.html) | +| 151675 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151675_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151675_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151675_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151675_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151675_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151675.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151675/151675_web_summary.html) | +| 151676 | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151676_filtered_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/h5/151676_raw_feature_bc_matrix.h5) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151676_full_image.tif) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151676_tissue_hires_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/images/151676_tissue_lowres_image.png) | [AWS](https://spatial-dlpfc.s3.us-east-2.amazonaws.com/loupe/151676.cloupe) | [GitHub](https://github.com/LieberInstitute/HumanPilot/blob/master/10X/151676/151676_web_summary.html) | ## Citation @@ -245,13 +268,14 @@ Please run this yourself to check for any updates on how to cite ``` r print(citation("spatialLIBD"), bibtex = TRUE) +#> To cite package 'spatialLIBD' in publications use: #> -#> Pardo B, Spangler A, Weber LM, Hicks SC, Jaffe AE, Martinowich K, -#> Maynard KR, Collado-Torres L (2022). "spatialLIBD: an R/Bioconductor -#> package to visualize spatially-resolved transcriptomics data." -#> _BMC Genomics_. doi: 10.1186/s12864-022-08601-w (URL: -#> https://doi.org/10.1186/s12864-022-08601-w), https://doi.org/10.1186/s12864-022-08601-w>. +#> Pardo B, Spangler A, Weber LM, Hicks SC, Jaffe AE, Martinowich K, +#> Maynard KR, Collado-Torres L (2022). "spatialLIBD: an R/Bioconductor +#> package to visualize spatially-resolved transcriptomics data." _BMC +#> Genomics_. doi:10.1186/s12864-022-08601-w +#> , +#> . #> #> A BibTeX entry for LaTeX users is #> @@ -264,14 +288,14 @@ print(citation("spatialLIBD"), bibtex = TRUE) #> url = {https://doi.org/10.1186/s12864-022-08601-w}, #> } #> -#> Maynard KR, Collado-Torres L, Weber LM, Uytingco C, Barry BK, Williams -#> SR, II JLC, Tran MN, Besich Z, Tippani M, Chew J, Yin Y, Kleinman JE, -#> Hyde TM, Rao N, Hicks SC, Martinowich K, Jaffe AE (2021). -#> "Transcriptome-scale spatial gene expression in the human dorsolateral -#> prefrontal cortex." _Nature Neuroscience_. doi: -#> 10.1038/s41593-020-00787-0 (URL: -#> https://doi.org/10.1038/s41593-020-00787-0), https://www.nature.com/articles/s41593-020-00787-0>. +#> Maynard KR, Collado-Torres L, Weber LM, Uytingco C, Barry BK, +#> Williams SR, II JLC, Tran MN, Besich Z, Tippani M, Chew J, Yin Y, +#> Kleinman JE, Hyde TM, Rao N, Hicks SC, Martinowich K, Jaffe AE +#> (2021). "Transcriptome-scale spatial gene expression in the human +#> dorsolateral prefrontal cortex." _Nature Neuroscience_. +#> doi:10.1038/s41593-020-00787-0 +#> , +#> . #> #> A BibTeX entry for LaTeX users is #> @@ -283,8 +307,99 @@ print(citation("spatialLIBD"), bibtex = TRUE) #> doi = {10.1038/s41593-020-00787-0}, #> url = {https://www.nature.com/articles/s41593-020-00787-0}, #> } +#> +#> Huuki-Myers LA, Spangler A, Eagles NJ, Montgomergy KD, Kwon SH, Guo +#> B, Grant-Peters M, Divecha HR, Tippani M, Sriworarat C, Nguyen AB, +#> Ravichandran P, Tran MN, Seyedian A, Consortium P, Hyde TM, Kleinman +#> JE, Battle A, Page SC, Ryten M, Hicks SC, Martinowich K, +#> Collado-Torres L, Maynard KR (2024). "A data-driven single-cell and +#> spatial transcriptomic map of the human prefrontal cortex." +#> _Science_. doi:10.1126/science.adh1938 +#> , +#> . +#> +#> A BibTeX entry for LaTeX users is +#> +#> @Article{, +#> title = {A data-driven single-cell and spatial transcriptomic map of the human prefrontal cortex}, +#> author = {Louise A. Huuki-Myers and Abby Spangler and Nicholas J. Eagles and Kelsey D. Montgomergy and Sang Ho Kwon and Boyi Guo and Melissa Grant-Peters and Heena R. Divecha and Madhavi Tippani and Chaichontat Sriworarat and Annie B. Nguyen and Prashanthi Ravichandran and Matthew N. Tran and Arta Seyedian and PsychENCODE Consortium and Thomas M. Hyde and Joel E. Kleinman and Alexis Battle and Stephanie C. Page and Mina Ryten and Stephanie C. Hicks and Keri Martinowich and Leonardo Collado-Torres and Kristen R. Maynard}, +#> year = {2024}, +#> journal = {Science}, +#> doi = {10.1126/science.adh1938}, +#> url = {https://doi.org/10.1126/science.adh1938}, +#> } +#> +#> Kwon SH, Parthiban S, Tippani M, Divecha HR, Eagles NJ, Lobana JS, +#> Williams SR, Mark M, Bharadwaj RA, Kleinman JE, Hyde TM, Page SC, +#> Hicks SC, Martinowich K, Maynard KR, Collado-Torres L (2023). +#> "Influence of Alzheimer’s disease related neuropathology on local +#> microenvironment gene expression in the human inferior temporal +#> cortex." _bioRxiv_. doi:10.1101/2023.04.20.537710 +#> , +#> . +#> +#> A BibTeX entry for LaTeX users is +#> +#> @Article{, +#> title = {Influence of Alzheimer’s disease related neuropathology on local microenvironment gene expression in the human inferior temporal cortex}, +#> author = {Sang Ho Kwon and Sowmya Parthiban and Madhavi Tippani and Heena R. Divecha and Nicholas J. Eagles and Jashandeep S. Lobana and Stephen R. Williams and Michelle Mark and Rahul A. Bharadwaj and Joel E. Kleinman and Thomas M. Hyde and Stephanie C. Page and Stephanie C. Hicks and Keri Martinowich and Kristen R. Maynard and Leonardo Collado-Torres}, +#> year = {2023}, +#> journal = {bioRxiv}, +#> doi = {10.1101/2023.04.20.537710}, +#> url = {https://www.biorxiv.org/content/10.1101/2023.04.20.537710v1}, +#> } ``` Please note that the `spatialLIBD` was only made possible thanks to many other R and bioinformatics software authors, which are cited either in the vignettes and/or the paper(s) describing this package. + +## Code of Conduct + +Please note that the spatialLIBD project is released with a [Contributor +Code of +Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). +By contributing to this project, you agree to abide by its terms. + +## Development tools + +- Continuous code testing is possible thanks to [GitHub + actions](https://www.tidyverse.org/blog/2020/04/usethis-1-6-0/) + through *[usethis](https://CRAN.R-project.org/package=usethis)*, + *[remotes](https://CRAN.R-project.org/package=remotes)*, + *[sysreqs](https://github.com/r-hub/sysreqs)* and + *[rcmdcheck](https://CRAN.R-project.org/package=rcmdcheck)* customized + to use [Bioconductor’s docker + containers](https://www.bioconductor.org/help/docker/) and + *[BiocCheck](https://bioconductor.org/packages/3.19/BiocCheck)*. +- Code coverage assessment is possible thanks to + [codecov](https://codecov.io/gh) and + *[covr](https://CRAN.R-project.org/package=covr)*. +- The [documentation + website](http://lieberinstitute.github.io/spatialLIBD) is + automatically updated thanks to + *[pkgdown](https://CRAN.R-project.org/package=pkgdown)*. +- The code is styled automatically thanks to + *[styler](https://CRAN.R-project.org/package=styler)*. +- The documentation is formatted thanks to + *[devtools](https://CRAN.R-project.org/package=devtools)* and + *[roxygen2](https://CRAN.R-project.org/package=roxygen2)*. + +For more details, check the `dev` directory. + +This package was developed using +*[biocthis](https://bioconductor.org/packages/3.19/biocthis)*. + + + +
+ +
+ + + From f9d7c4b9450f1f272f5202371a89a4d5412a660c Mon Sep 17 00:00:00 2001 From: lcolladotor Date: Fri, 24 May 2024 00:52:02 -0400 Subject: [PATCH 03/28] v1.17.1 --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 59d21beb..b3daacc4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: spatialLIBD Title: spatialLIBD: an R/Bioconductor package to visualize spatially-resolved transcriptomics data -Version: 1.17.0 -Date: 2024-04-19 +Version: 1.17.1 +Date: 2024-05-24 Authors@R: c( person("Leonardo", "Collado-Torres", role = c("aut", "cre"), From cb1591ecd26f529a31b603c029baa82db8171989 Mon Sep 17 00:00:00 2001 From: lcolladotor Date: Fri, 24 May 2024 00:53:41 -0400 Subject: [PATCH 04/28] Check on R 4.4 and bioc 3.19 on GHA --- .github/workflows/check-bioc.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/check-bioc.yml b/.github/workflows/check-bioc.yml index 2b37d332..1ce169dc 100644 --- a/.github/workflows/check-bioc.yml +++ b/.github/workflows/check-bioc.yml @@ -52,9 +52,9 @@ jobs: fail-fast: false matrix: config: - - { os: ubuntu-latest, r: '4.3', bioc: '3.18', cont: "bioconductor/bioconductor_docker:RELEASE_3_18", rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest" } - - { os: macOS-latest, r: '4.3', bioc: '3.18'} - - { os: windows-latest, r: '4.3', bioc: '3.18'} + - { os: ubuntu-latest, r: '4.4', bioc: '3.19', cont: "bioconductor/bioconductor_docker:RELEASE_3_19", rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest" } + - { os: macOS-latest, r: '4.4', bioc: '3.19'} + - { os: windows-latest, r: '4.4', bioc: '3.19'} ## Check https://github.com/r-lib/actions/tree/master/examples ## for examples using the http-user-agent env: @@ -105,16 +105,16 @@ jobs: uses: actions/cache@v3 with: path: ${{ env.R_LIBS_USER }} - key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_18-r-4.3-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_18-r-4.3- + key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_19-r-4.4-${{ hashFiles('.github/depends.Rds') }} + restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_19-r-4.4- - name: Cache R packages on Linux if: "!contains(github.event.head_commit.message, '/nocache') && runner.os == 'Linux' " uses: actions/cache@v3 with: path: /home/runner/work/_temp/Library - key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_18-r-4.3-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_18-r-4.3- + key: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_19-r-4.4-${{ hashFiles('.github/depends.Rds') }} + restore-keys: ${{ env.cache-version }}-${{ runner.os }}-biocversion-RELEASE_3_19-r-4.4- # - name: Install Linux system dependencies # if: runner.os == 'Linux' @@ -221,7 +221,7 @@ jobs: rcmdcheck::rcmdcheck( args = c("--no-manual", "--no-vignettes", "--timings"), build_args = c("--no-manual", "--keep-empty-dirs", "--no-resave-data"), - error_on = "error", + error_on = "warning", check_dir = "check" ) shell: Rscript {0} @@ -253,7 +253,7 @@ jobs: - name: Test coverage if: github.ref == 'refs/heads/devel' && env.run_covr == 'true' && runner.os == 'Linux' run: | - covr::codecov() + covr::codecov(coverage = covr::package_coverage(type = "all")) shell: Rscript {0} - name: Install package @@ -286,7 +286,7 @@ jobs: if: failure() uses: actions/upload-artifact@master with: - name: ${{ runner.os }}-biocversion-RELEASE_3_18-r-4.3-results + name: ${{ runner.os }}-biocversion-RELEASE_3_19-r-4.4-results path: check From 45b22bcf2a9c2b701e4ea7bf296921a36a998dad Mon Sep 17 00:00:00 2001 From: lcolladotor Date: Fri, 24 May 2024 01:59:28 -0400 Subject: [PATCH 05/28] ignore macOS build for now due to upstream issue with SparseArray --- .github/workflows/check-bioc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-bioc.yml b/.github/workflows/check-bioc.yml index 1ce169dc..9f88c52b 100644 --- a/.github/workflows/check-bioc.yml +++ b/.github/workflows/check-bioc.yml @@ -53,7 +53,7 @@ jobs: matrix: config: - { os: ubuntu-latest, r: '4.4', bioc: '3.19', cont: "bioconductor/bioconductor_docker:RELEASE_3_19", rspm: "https://packagemanager.rstudio.com/cran/__linux__/jammy/latest" } - - { os: macOS-latest, r: '4.4', bioc: '3.19'} + # - { os: macOS-latest, r: '4.4', bioc: '3.19'} - { os: windows-latest, r: '4.4', bioc: '3.19'} ## Check https://github.com/r-lib/actions/tree/master/examples ## for examples using the http-user-agent From e9d6e3a4219da2765dbb08d4fd1994dfdca0084e Mon Sep 17 00:00:00 2001 From: lcolladotor Date: Fri, 24 May 2024 13:23:49 -0400 Subject: [PATCH 06/28] Update citation info for Visium_SPG_AD --- README.md | 12 ++++++------ inst/CITATION | 6 +++--- inst/app/www/README.md | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 23a0513e..c4c49cd2 100644 --- a/README.md +++ b/README.md @@ -334,9 +334,9 @@ print(citation("spatialLIBD"), bibtex = TRUE) #> Hicks SC, Martinowich K, Maynard KR, Collado-Torres L (2023). #> "Influence of Alzheimer’s disease related neuropathology on local #> microenvironment gene expression in the human inferior temporal -#> cortex." _bioRxiv_. doi:10.1101/2023.04.20.537710 -#> , -#> . +#> cortex." _GEN Biotechnology_. doi:10.1089/genbio.2023.0019 +#> , +#> . #> #> A BibTeX entry for LaTeX users is #> @@ -344,9 +344,9 @@ print(citation("spatialLIBD"), bibtex = TRUE) #> title = {Influence of Alzheimer’s disease related neuropathology on local microenvironment gene expression in the human inferior temporal cortex}, #> author = {Sang Ho Kwon and Sowmya Parthiban and Madhavi Tippani and Heena R. Divecha and Nicholas J. Eagles and Jashandeep S. Lobana and Stephen R. Williams and Michelle Mark and Rahul A. Bharadwaj and Joel E. Kleinman and Thomas M. Hyde and Stephanie C. Page and Stephanie C. Hicks and Keri Martinowich and Kristen R. Maynard and Leonardo Collado-Torres}, #> year = {2023}, -#> journal = {bioRxiv}, -#> doi = {10.1101/2023.04.20.537710}, -#> url = {https://www.biorxiv.org/content/10.1101/2023.04.20.537710v1}, +#> journal = {GEN Biotechnology}, +#> doi = {10.1089/genbio.2023.0019}, +#> url = {https://doi.org/10.1089/genbio.2023.0019}, #> } ``` diff --git a/inst/CITATION b/inst/CITATION index bc6d454d..e10fdcf2 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -98,8 +98,8 @@ c( as.person("Leonardo Collado-Torres") ), year = 2023, - journal = "bioRxiv", - doi = "10.1101/2023.04.20.537710", - url = "https://www.biorxiv.org/content/10.1101/2023.04.20.537710v1" + journal = "GEN Biotechnology", + doi = "10.1089/genbio.2023.0019", + url = "https://doi.org/10.1089/genbio.2023.0019" ) ) diff --git a/inst/app/www/README.md b/inst/app/www/README.md index adb3c1b8..8c3e846b 100644 --- a/inst/app/www/README.md +++ b/inst/app/www/README.md @@ -344,9 +344,9 @@ print(citation("spatialLIBD"), bibtex = TRUE) #> title = {Influence of Alzheimer’s disease related neuropathology on local microenvironment gene expression in the human inferior temporal cortex}, #> author = {Sang Ho Kwon and Sowmya Parthiban and Madhavi Tippani and Heena R. Divecha and Nicholas J. Eagles and Jashandeep S. Lobana and Stephen R. Williams and Michelle Mark and Rahul A. Bharadwaj and Joel E. Kleinman and Thomas M. Hyde and Stephanie C. Page and Stephanie C. Hicks and Keri Martinowich and Kristen R. Maynard and Leonardo Collado-Torres}, #> year = {2023}, -#> journal = {bioRxiv}, -#> doi = {10.1101/2023.04.20.537710}, -#> url = {https://www.biorxiv.org/content/10.1101/2023.04.20.537710v1}, +#> journal = {GEN Biotechnology}, +#> doi = {10.1089/genbio.2023.0019}, +#> url = {https://doi.org/10.1089/genbio.2023.0019}, #> } ``` From e0947a28ead1828714d037be977fbdd5a48005d5 Mon Sep 17 00:00:00 2001 From: lcolladotor Date: Fri, 24 May 2024 13:36:03 -0400 Subject: [PATCH 07/28] v1.17.2 --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index b3daacc4..a0ebcbcf 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: spatialLIBD Title: spatialLIBD: an R/Bioconductor package to visualize spatially-resolved transcriptomics data -Version: 1.17.1 +Version: 1.17.2 Date: 2024-05-24 Authors@R: c( From 018bde0278aa17fdfe13f4370f71079a0ea4f184 Mon Sep 17 00:00:00 2001 From: Nick-Eagles Date: Thu, 6 Jun 2024 13:55:09 -0400 Subject: [PATCH 08/28] Add a check and test for legitimate spatial coordinates --- R/vis_gene.R | 8 ++++++++ tests/testthat/test-vis_gene.R | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/R/vis_gene.R b/R/vis_gene.R index 594940af..1165cb18 100644 --- a/R/vis_gene.R +++ b/R/vis_gene.R @@ -192,6 +192,14 @@ vis_gene <- stop(sprintf("'%s' is not an assay in 'spe'", assayname), call. = FALSE) } + # Check validity of spatial coordinates + if (!setequal(c("pxl_col_in_fullres", "pxl_row_in_fullres"), colnames(spatialCoords(spe)))) { + stop( + "Abnormal spatial coordinates: should have 'pxl_row_in_fullres' and 'pxl_col_in_fullres' columns.", + call. = FALSE + ) + } + spe_sub <- spe[, spe$sample_id == sampleid] d <- as.data.frame(cbind(colData(spe_sub), SpatialExperiment::spatialCoords(spe_sub)), optional = TRUE) diff --git a/tests/testthat/test-vis_gene.R b/tests/testthat/test-vis_gene.R index 27a8dfdd..dbe850e8 100644 --- a/tests/testthat/test-vis_gene.R +++ b/tests/testthat/test-vis_gene.R @@ -51,5 +51,12 @@ test_that( class(vis_gene(spe, geneid = c("sum_umi", rownames(spe)[1]))), c("gg", "ggplot") ) + + # Bad spatialCoords + colnames(spatialCoords(spe)) = c('a', 'b') + expect_error( + { p <- vis_gene(spe, geneid = "sum_umi") }, + "^Abnormal spatial coordinates" + ) } ) From 397de084ffb9f09492908e38adacfd59a58110b7 Mon Sep 17 00:00:00 2001 From: Nick-Eagles Date: Thu, 6 Jun 2024 14:25:13 -0400 Subject: [PATCH 09/28] Add and document an 'is_stitched' parameter; add checks and tests related to colData columns it will operate on --- R/vis_gene.R | 31 +++++++++++++++++++++++++++++++ man/vis_gene.Rd | 8 ++++++++ tests/testthat/test-vis_gene.R | 18 ++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/R/vis_gene.R b/R/vis_gene.R index 1165cb18..c74b4f7e 100644 --- a/R/vis_gene.R +++ b/R/vis_gene.R @@ -36,6 +36,12 @@ #' the proportion of continuous variables with positive values for each spot is #' computed. For more details, check the multi gene vignette at #' . +#' @param is_stitched A \code{logical(1)} vector: If true, expects a +#' \code{SpatialExperiment} built with \code{visiumStitched::build_spe()} +#' ; in +#' particular, expects a logical colData column \code{exclude_overlapping} +#' specifying which spots to exclude from the plot. Sets \code{auto_crop = FALSE} +#' when TRUE. #' #' @return A [ggplot2][ggplot2::ggplot] object. #' @export @@ -172,6 +178,7 @@ vis_gene <- auto_crop = TRUE, na_color = "#CCCCCC40", multi_gene_method = c("z_score", "pca", "sparsity"), + is_stitched = FALSE, ...) { multi_gene_method <- rlang::arg_match(multi_gene_method) # Verify existence and legitimacy of 'sampleid' @@ -201,6 +208,30 @@ vis_gene <- } spe_sub <- spe[, spe$sample_id == sampleid] + + if (is_stitched) { + # State assumptions about columns expected to be in the colData + expected_cols <- c("array_row", "array_col", "exclude_overlapping") + if (!all(expected_cols %in% colnames(colData(spe)))) { + stop( + sprintf( + 'Missing at least one of the following colData columns: "%s"', + paste(expected_cols, collapse = '", "') + ) + ) + } + + # Drop excluded spots; verify some spots are not excluded + subset_cols = !spe$exclude_overlapping + if (length(which(subset_cols)) == 0) { + stop( + "spe$exclude_overlapping must include some FALSE values to plot", + call. = FALSE + ) + } + spe_sub <- spe_sub[, subset_cols] + } + d <- as.data.frame(cbind(colData(spe_sub), SpatialExperiment::spatialCoords(spe_sub)), optional = TRUE) # Verify legitimacy of names in geneid diff --git a/man/vis_gene.Rd b/man/vis_gene.Rd index 644c8afe..0c46ef8c 100644 --- a/man/vis_gene.Rd +++ b/man/vis_gene.Rd @@ -20,6 +20,7 @@ vis_gene( auto_crop = TRUE, na_color = "#CCCCCC40", multi_gene_method = c("z_score", "pca", "sparsity"), + is_stitched = FALSE, ... ) } @@ -92,6 +93,13 @@ the proportion of continuous variables with positive values for each spot is computed. For more details, check the multi gene vignette at \url{https://research.libd.org/spatialLIBD/articles/multi_gene_plots.html}.} +\item{is_stitched}{A \code{logical(1)} vector: If true, expects a +\code{SpatialExperiment} built with \code{visiumStitched::build_spe()} +\url{http://research.libd.org/visiumStitched/reference/build_spe.html}; in +particular, expects a logical colData column \code{exclude_overlapping} +specifying which spots to exclude from the plot. Sets \code{auto_crop = FALSE} +when TRUE.} + \item{...}{Passed to \link[base:paste]{paste0()} for making the title of the plot following the \code{sampleid}.} } diff --git a/tests/testthat/test-vis_gene.R b/tests/testthat/test-vis_gene.R index dbe850e8..abdefad2 100644 --- a/tests/testthat/test-vis_gene.R +++ b/tests/testthat/test-vis_gene.R @@ -46,12 +46,30 @@ test_that( "Could not find the 'geneid'\\(s\\) aaa" ) + # Missing exclude_overlapping + expect_error( + { + p <- vis_gene(spe, geneid = "sum_umi", is_stitched = TRUE) + }, + "^Missing at least one of the following colData" + ) + + # Can't exclude all spots + spe$exclude_overlapping = TRUE + expect_error( + { + p <- vis_gene(spe, geneid = "sum_umi", is_stitched = TRUE) + }, + "^spe\\$exclude_overlapping must include some FALSE values to plot$" + ) + # Trivially check success with legitimate input expect_equal( class(vis_gene(spe, geneid = c("sum_umi", rownames(spe)[1]))), c("gg", "ggplot") ) + # Bad spatialCoords colnames(spatialCoords(spe)) = c('a', 'b') expect_error( From 15060fb7046938dbb0d363e148fcbfb2b6c8c10b Mon Sep 17 00:00:00 2001 From: Nick-Eagles Date: Thu, 6 Jun 2024 15:15:06 -0400 Subject: [PATCH 10/28] Small fixes from interactively testing --- R/vis_gene.R | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/R/vis_gene.R b/R/vis_gene.R index c74b4f7e..2c241897 100644 --- a/R/vis_gene.R +++ b/R/vis_gene.R @@ -212,7 +212,7 @@ vis_gene <- if (is_stitched) { # State assumptions about columns expected to be in the colData expected_cols <- c("array_row", "array_col", "exclude_overlapping") - if (!all(expected_cols %in% colnames(colData(spe)))) { + if (!all(expected_cols %in% colnames(colData(spe_sub)))) { stop( sprintf( 'Missing at least one of the following colData columns: "%s"', @@ -222,7 +222,7 @@ vis_gene <- } # Drop excluded spots; verify some spots are not excluded - subset_cols = !spe$exclude_overlapping + subset_cols = !spe_sub$exclude_overlapping if (length(which(subset_cols)) == 0) { stop( "spe$exclude_overlapping must include some FALSE values to plot", @@ -230,6 +230,33 @@ vis_gene <- ) } spe_sub <- spe_sub[, subset_cols] + + # Compute an appropriate spot size for this sample + + # Determine some pixel values for the horizontal bounds of the spots + MIN_COL <- min(spatialCoords(spe_sub)[, "pxl_row_in_fullres"]) + MAX_COL <- max(spatialCoords(spe_sub)[, "pxl_row_in_fullres"]) + + # The distance between spots (in pixels) is double the average distance + # between array columns + INTER_SPOT_DIST_PX <- 2 * (MAX_COL - MIN_COL) / + (max(spe_sub$array_col) - min(spe_sub$array_col)) + + # Find the appropriate spot size for this donor. This can vary because + # ggplot downscales a plot to fit desired output dimensions (in this + # case presumably a square region on a PDF), and stitched images can vary + # in aspect ratio. Also, lowres images always have a larger image + # dimension of 1200, no matter how many spots fit in either dimension. + small_image_data <- imgData(spe_sub)[ + imgData(spe_sub)$image_id == image_id, + ] + + # The coefficient of 100 was determined empirically + point_size <- point_size * 100 * INTER_SPOT_DIST_PX * + small_image_data$scaleFactor / max(dim(small_image_data$data[[1]])) + + # Frame limits are poorly defined for stitched data + auto_crop = FALSE } d <- as.data.frame(cbind(colData(spe_sub), SpatialExperiment::spatialCoords(spe_sub)), optional = TRUE) From 1f8a9287d71b81fa23a3dae906ef475260e9a9ab Mon Sep 17 00:00:00 2001 From: Nick-Eagles Date: Thu, 6 Jun 2024 15:21:07 -0400 Subject: [PATCH 11/28] Add a check for NAs --- R/vis_gene.R | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/R/vis_gene.R b/R/vis_gene.R index 2c241897..cf2379c4 100644 --- a/R/vis_gene.R +++ b/R/vis_gene.R @@ -217,10 +217,15 @@ vis_gene <- sprintf( 'Missing at least one of the following colData columns: "%s"', paste(expected_cols, collapse = '", "') - ) + ), + call. = FALSE ) } + if(any(is.na(spe_sub$exclude_overlapping))) { + stop("spe$exclude_overlapping must not have NAs", call. = FALSE) + } + # Drop excluded spots; verify some spots are not excluded subset_cols = !spe_sub$exclude_overlapping if (length(which(subset_cols)) == 0) { From b6458a5df8ba926b261d1a2982c5f405f122b288 Mon Sep 17 00:00:00 2001 From: Nick-Eagles Date: Fri, 7 Jun 2024 11:14:01 -0400 Subject: [PATCH 12/28] Export processing of stitched data into its own function, since it will be used by both vis_gene() and vis_clus(), and involves many lines of code --- NAMESPACE | 1 + R/prep_stitched_data.R | 75 +++++++++++++++++++++++++++++++++++++++ R/vis_gene.R | 53 +++------------------------ man/prep_stitched_data.Rd | 37 +++++++++++++++++++ 4 files changed, 117 insertions(+), 49 deletions(-) create mode 100644 R/prep_stitched_data.R create mode 100644 man/prep_stitched_data.Rd diff --git a/NAMESPACE b/NAMESPACE index d18236fa..8b8698aa 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -48,6 +48,7 @@ export(vis_grid_gene) import(ExperimentHub) import(MatrixGenerics) import(SingleCellExperiment) +import(SpatialExperiment) import(ggplot2) import(grid) import(paletteer) diff --git a/R/prep_stitched_data.R b/R/prep_stitched_data.R new file mode 100644 index 00000000..1b46a44f --- /dev/null +++ b/R/prep_stitched_data.R @@ -0,0 +1,75 @@ +#' Prepare stitched data for plotting +#' +#' Given a \code{SpatialExperiment} built with \code{visiumStitched::build_spe()} +#' , drop +#' exluded spots (specified by \code{spe$exclude_overlapping}) and compute an +#' appropriate spot size for plotting with \code{vis_gene()} or +#' \code{vis_clus()}, assuming the plot will be written to a PDF of default +#' dimensions (i.e. \code{width = 7} and \code{height = 7}). +#' +#' @param spe A \code{SpatialExperiment} built with +#' \code{visiumStitched::build_spe()}, containing a logical +#' \code{spe$exclude_overlapping} column specifying which spots to display in +#' plots +#' @inheritParams vis_clus +#' +#' @return A list with names \code{spe} and \code{point_size} containing a +#' filtered, ready-to-plot \code{SpatialExperiment} and an appopriate spot size +#' (passed to \code{vis_gene()} or \code{vis_clus()}), respectively +#' +#' @import SpatialExperiment +#' @author Nicholas J. Eagles +#' @keywords internal +prep_stitched_data = function(spe, point_size, image_id) { + # State assumptions about columns expected to be in the colData + expected_cols <- c("array_row", "array_col", "exclude_overlapping") + if (!all(expected_cols %in% colnames(colData(spe)))) { + stop( + sprintf( + 'Missing at least one of the following colData columns: "%s"', + paste(expected_cols, collapse = '", "') + ), + call. = FALSE + ) + } + + if(any(is.na(spe$exclude_overlapping))) { + stop("spe$exclude_overlapping must not have NAs", call. = FALSE) + } + + # Drop excluded spots; verify some spots are not excluded + subset_cols = !spe$exclude_overlapping + if (length(which(subset_cols)) == 0) { + stop( + "spe$exclude_overlapping must include some FALSE values to plot", + call. = FALSE + ) + } + spe <- spe[, subset_cols] + + # Compute an appropriate spot size for this sample + + # Determine some pixel values for the horizontal bounds of the spots + MIN_COL <- min(spatialCoords(spe)[, "pxl_row_in_fullres"]) + MAX_COL <- max(spatialCoords(spe)[, "pxl_row_in_fullres"]) + + # The distance between spots (in pixels) is double the average distance + # between array columns + INTER_SPOT_DIST_PX <- 2 * (MAX_COL - MIN_COL) / + (max(spe$array_col) - min(spe$array_col)) + + # Find the appropriate spot size for this donor. This can vary because + # ggplot downscales a plot to fit desired output dimensions (in this + # case presumably a square region on a PDF), and stitched images can vary + # in aspect ratio. Also, lowres images always have a larger image + # dimension of 1200, no matter how many spots fit in either dimension. + small_image_data <- imgData(spe)[ + imgData(spe)$image_id == image_id, + ] + + # The coefficient of 100 was determined empirically + point_size <- point_size * 100 * INTER_SPOT_DIST_PX * + small_image_data$scaleFactor / max(dim(small_image_data$data[[1]])) + + return(list(spe = spe, point_size = point_size)) +} diff --git a/R/vis_gene.R b/R/vis_gene.R index cf2379c4..7f6e992d 100644 --- a/R/vis_gene.R +++ b/R/vis_gene.R @@ -210,55 +210,10 @@ vis_gene <- spe_sub <- spe[, spe$sample_id == sampleid] if (is_stitched) { - # State assumptions about columns expected to be in the colData - expected_cols <- c("array_row", "array_col", "exclude_overlapping") - if (!all(expected_cols %in% colnames(colData(spe_sub)))) { - stop( - sprintf( - 'Missing at least one of the following colData columns: "%s"', - paste(expected_cols, collapse = '", "') - ), - call. = FALSE - ) - } - - if(any(is.na(spe_sub$exclude_overlapping))) { - stop("spe$exclude_overlapping must not have NAs", call. = FALSE) - } - - # Drop excluded spots; verify some spots are not excluded - subset_cols = !spe_sub$exclude_overlapping - if (length(which(subset_cols)) == 0) { - stop( - "spe$exclude_overlapping must include some FALSE values to plot", - call. = FALSE - ) - } - spe_sub <- spe_sub[, subset_cols] - - # Compute an appropriate spot size for this sample - - # Determine some pixel values for the horizontal bounds of the spots - MIN_COL <- min(spatialCoords(spe_sub)[, "pxl_row_in_fullres"]) - MAX_COL <- max(spatialCoords(spe_sub)[, "pxl_row_in_fullres"]) - - # The distance between spots (in pixels) is double the average distance - # between array columns - INTER_SPOT_DIST_PX <- 2 * (MAX_COL - MIN_COL) / - (max(spe_sub$array_col) - min(spe_sub$array_col)) - - # Find the appropriate spot size for this donor. This can vary because - # ggplot downscales a plot to fit desired output dimensions (in this - # case presumably a square region on a PDF), and stitched images can vary - # in aspect ratio. Also, lowres images always have a larger image - # dimension of 1200, no matter how many spots fit in either dimension. - small_image_data <- imgData(spe_sub)[ - imgData(spe_sub)$image_id == image_id, - ] - - # The coefficient of 100 was determined empirically - point_size <- point_size * 100 * INTER_SPOT_DIST_PX * - small_image_data$scaleFactor / max(dim(small_image_data$data[[1]])) + # Drop excluded spots and calculate an appropriate point size + temp = prep_stitched_data(spe_sub, point_size, image_id) + spe_sub = temp$spe + point_size = temp$point_size # Frame limits are poorly defined for stitched data auto_crop = FALSE diff --git a/man/prep_stitched_data.Rd b/man/prep_stitched_data.Rd new file mode 100644 index 00000000..3266806f --- /dev/null +++ b/man/prep_stitched_data.Rd @@ -0,0 +1,37 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/prep_stitched_data.R +\name{prep_stitched_data} +\alias{prep_stitched_data} +\title{Prepare stitched data for plotting} +\usage{ +prep_stitched_data(spe, point_size, image_id) +} +\arguments{ +\item{spe}{A \code{SpatialExperiment} built with +\code{visiumStitched::build_spe()}, containing a logical +\code{spe$exclude_overlapping} column specifying which spots to display in +plots} + +\item{point_size}{A \code{numeric(1)} specifying the size of the points. Defaults +to \code{1.25}. Some colors look better if you use \code{2} for instance.} + +\item{image_id}{A \code{character(1)} with the name of the image ID you want to +use in the background.} +} +\value{ +A list with names \code{spe} and \code{point_size} containing a +filtered, ready-to-plot \code{SpatialExperiment} and an appopriate spot size +(passed to \code{vis_gene()} or \code{vis_clus()}), respectively +} +\description{ +Given a \code{SpatialExperiment} built with \code{visiumStitched::build_spe()} +\url{http://research.libd.org/visiumStitched/reference/build_spe.html}, drop +exluded spots (specified by \code{spe$exclude_overlapping}) and compute an +appropriate spot size for plotting with \code{vis_gene()} or +\code{vis_clus()}, assuming the plot will be written to a PDF of default +dimensions (i.e. \code{width = 7} and \code{height = 7}). +} +\author{ +Nicholas J. Eagles +} +\keyword{internal} From d4e826e0c7fbbca2133da56002b46d00c53e7bc2 Mon Sep 17 00:00:00 2001 From: Nick-Eagles Date: Fri, 7 Jun 2024 11:24:54 -0400 Subject: [PATCH 13/28] Move tests originally performed in vis_gene() to the prep_stitched_data() tests, where applicable --- tests/testthat/test-prep_stitched_data.R | 30 ++++++++++++++++++++++++ tests/testthat/test-vis_gene.R | 17 -------------- 2 files changed, 30 insertions(+), 17 deletions(-) create mode 100644 tests/testthat/test-prep_stitched_data.R diff --git a/tests/testthat/test-prep_stitched_data.R b/tests/testthat/test-prep_stitched_data.R new file mode 100644 index 00000000..1c527b78 --- /dev/null +++ b/tests/testthat/test-prep_stitched_data.R @@ -0,0 +1,30 @@ +test_that( + "prep_stitched_data", + { + if (!exists("spe")) spe <- fetch_data("spe") + + # Missing exclude_overlapping + expect_error( + { + temp <- prep_stitched_data( + spe, point_size = 2, image_id = "lowres" + ) + }, + "^Missing at least one of the following colData" + ) + + # Can't exclude all spots + spe$exclude_overlapping = TRUE + expect_error( + { + temp <- prep_stitched_data( + spe, point_size = 2, image_id = "lowres" + ) + }, + "^spe\\$exclude_overlapping must include some FALSE values to plot$" + ) + + # Note bad image_id is not tested, since this function is only used + # internally after checks for legitimate image_id are performed + } +) diff --git a/tests/testthat/test-vis_gene.R b/tests/testthat/test-vis_gene.R index abdefad2..f882f344 100644 --- a/tests/testthat/test-vis_gene.R +++ b/tests/testthat/test-vis_gene.R @@ -46,23 +46,6 @@ test_that( "Could not find the 'geneid'\\(s\\) aaa" ) - # Missing exclude_overlapping - expect_error( - { - p <- vis_gene(spe, geneid = "sum_umi", is_stitched = TRUE) - }, - "^Missing at least one of the following colData" - ) - - # Can't exclude all spots - spe$exclude_overlapping = TRUE - expect_error( - { - p <- vis_gene(spe, geneid = "sum_umi", is_stitched = TRUE) - }, - "^spe\\$exclude_overlapping must include some FALSE values to plot$" - ) - # Trivially check success with legitimate input expect_equal( class(vis_gene(spe, geneid = c("sum_umi", rownames(spe)[1]))), From d23f5b60a126b598f1670c81990294c1ec293af9 Mon Sep 17 00:00:00 2001 From: Nick-Eagles Date: Fri, 7 Jun 2024 11:30:26 -0400 Subject: [PATCH 14/28] Further check legitimacy of prep_stitched_data() output --- tests/testthat/test-prep_stitched_data.R | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/testthat/test-prep_stitched_data.R b/tests/testthat/test-prep_stitched_data.R index 1c527b78..f4206547 100644 --- a/tests/testthat/test-prep_stitched_data.R +++ b/tests/testthat/test-prep_stitched_data.R @@ -24,6 +24,14 @@ test_that( "^spe\\$exclude_overlapping must include some FALSE values to plot$" ) + # Output should be a list with the correct names, and the + # SpatialExperiment should have no excluded spots + spe$exclude_overlapping[1:100] = FALSE + temp <- prep_stitched_data(spe, point_size = 2, image_id = "lowres") + expect_equal(class(temp), 'list') + expect_equal(names(temp), c('spe', 'point_size')) + expect_equal(all(temp$spe$exclude_overlapping), FALSE) + # Note bad image_id is not tested, since this function is only used # internally after checks for legitimate image_id are performed } From 5c5c94ef0dcb2f643d91cfe3602edf200822a75c Mon Sep 17 00:00:00 2001 From: Nick-Eagles Date: Fri, 7 Jun 2024 11:36:38 -0400 Subject: [PATCH 15/28] Add a check for legitimate spatialCoords in vis_clus() --- R/vis_clus.R | 8 ++++++++ tests/testthat/test-vis_clus.R | 13 +++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tests/testthat/test-vis_clus.R diff --git a/R/vis_clus.R b/R/vis_clus.R index 5e1cfc1a..9012263e 100644 --- a/R/vis_clus.R +++ b/R/vis_clus.R @@ -130,6 +130,14 @@ vis_clus <- function(spe, ) } + # Check validity of spatial coordinates + if (!setequal(c("pxl_col_in_fullres", "pxl_row_in_fullres"), colnames(spatialCoords(spe)))) { + stop( + "Abnormal spatial coordinates: should have 'pxl_row_in_fullres' and 'pxl_col_in_fullres' columns.", + call. = FALSE + ) + } + spe_sub <- spe[, spe$sample_id == sampleid] d <- as.data.frame(cbind(colData(spe_sub), SpatialExperiment::spatialCoords(spe_sub)), optional = TRUE) diff --git a/tests/testthat/test-vis_clus.R b/tests/testthat/test-vis_clus.R new file mode 100644 index 00000000..4870342b --- /dev/null +++ b/tests/testthat/test-vis_clus.R @@ -0,0 +1,13 @@ +test_that( + "vis_clus", + { + if (!exists("spe")) spe <- fetch_data("spe") + + # Bad spatialCoords + colnames(spatialCoords(spe)) = c('a', 'b') + expect_error( + { p <- vis_clus(spe, clustervar = "sample_id") }, + "^Abnormal spatial coordinates" + ) + } +) From 813bcac6c67054fae1248c565ec43e65d18456b6 Mon Sep 17 00:00:00 2001 From: Nick-Eagles Date: Fri, 7 Jun 2024 11:44:12 -0400 Subject: [PATCH 16/28] Add support for plotting stitched data with vis_clus() --- R/vis_clus.R | 18 ++++++++++++++++++ R/vis_gene.R | 6 ------ man/vis_clus.Rd | 8 ++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/R/vis_clus.R b/R/vis_clus.R index 9012263e..c7534f34 100644 --- a/R/vis_clus.R +++ b/R/vis_clus.R @@ -29,6 +29,12 @@ #' alpha blending already, which will make non-NA values pop up more and the NA #' values will show with a lighter color. This behavior is lost when `alpha` is #' set to a non-`NA` value. +#' @param is_stitched A \code{logical(1)} vector: If true, expects a +#' \code{SpatialExperiment} built with \code{visiumStitched::build_spe()} +#' ; in +#' particular, expects a logical colData column \code{exclude_overlapping} +#' specifying which spots to exclude from the plot. Sets \code{auto_crop = FALSE} +#' when TRUE. #' @param ... Passed to [paste0()][base::paste] for making the title of the #' plot following the `sampleid`. #' @@ -116,6 +122,7 @@ vis_clus <- function(spe, point_size = 2, auto_crop = TRUE, na_color = "#CCCCCC40", + is_stitched = FALSE, ...) { # Verify existence and legitimacy of 'sampleid' if ( @@ -139,6 +146,17 @@ vis_clus <- function(spe, } spe_sub <- spe[, spe$sample_id == sampleid] + + if (is_stitched) { + # Drop excluded spots and calculate an appropriate point size + temp = prep_stitched_data(spe_sub, point_size, image_id) + spe_sub = temp$spe + point_size = temp$point_size + + # Frame limits are poorly defined for stitched data + auto_crop = FALSE + } + d <- as.data.frame(cbind(colData(spe_sub), SpatialExperiment::spatialCoords(spe_sub)), optional = TRUE) vis_clus_p( diff --git a/R/vis_gene.R b/R/vis_gene.R index 7f6e992d..510932ec 100644 --- a/R/vis_gene.R +++ b/R/vis_gene.R @@ -36,12 +36,6 @@ #' the proportion of continuous variables with positive values for each spot is #' computed. For more details, check the multi gene vignette at #' . -#' @param is_stitched A \code{logical(1)} vector: If true, expects a -#' \code{SpatialExperiment} built with \code{visiumStitched::build_spe()} -#' ; in -#' particular, expects a logical colData column \code{exclude_overlapping} -#' specifying which spots to exclude from the plot. Sets \code{auto_crop = FALSE} -#' when TRUE. #' #' @return A [ggplot2][ggplot2::ggplot] object. #' @export diff --git a/man/vis_clus.Rd b/man/vis_clus.Rd index 3354bfb4..6ad8c28c 100644 --- a/man/vis_clus.Rd +++ b/man/vis_clus.Rd @@ -16,6 +16,7 @@ vis_clus( point_size = 2, auto_crop = TRUE, na_color = "#CCCCCC40", + is_stitched = FALSE, ... ) } @@ -59,6 +60,13 @@ alpha blending already, which will make non-NA values pop up more and the NA values will show with a lighter color. This behavior is lost when \code{alpha} is set to a non-\code{NA} value.} +\item{is_stitched}{A \code{logical(1)} vector: If true, expects a +\code{SpatialExperiment} built with \code{visiumStitched::build_spe()} +\url{http://research.libd.org/visiumStitched/reference/build_spe.html}; in +particular, expects a logical colData column \code{exclude_overlapping} +specifying which spots to exclude from the plot. Sets \code{auto_crop = FALSE} +when TRUE.} + \item{...}{Passed to \link[base:paste]{paste0()} for making the title of the plot following the \code{sampleid}.} } From 3b6fbc587b5019a1a703d7cb0b5aed429ee373c0 Mon Sep 17 00:00:00 2001 From: Nick-Eagles Date: Tue, 11 Jun 2024 10:10:03 -0400 Subject: [PATCH 17/28] Add metadata and a script to generate it for the Visium LS data --- inst/extdata/metadata_Visium_LS.csv | 3 + inst/scripts/make-metadata_Visium_LS.R | 184 +++++++++++++++++++++++++ 2 files changed, 187 insertions(+) create mode 100644 inst/extdata/metadata_Visium_LS.csv create mode 100644 inst/scripts/make-metadata_Visium_LS.R diff --git a/inst/extdata/metadata_Visium_LS.csv b/inst/extdata/metadata_Visium_LS.csv new file mode 100644 index 00000000..b8a150ea --- /dev/null +++ b/inst/extdata/metadata_Visium_LS.csv @@ -0,0 +1,3 @@ +Title,Description,BiocVersion,Genome,SourceType,SourceUrl,SourceVersion,Species,TaxonomyId,Coordinate_1_based,DataProvider,Maintainer,RDataClass,DispatchClass,RDataPath,Tags +Visium_LS_spe,SpatialExperiment object at the spot-level for the spatially stitched lateral septum human brain (LS) spatial transcriptomics data (n = 3) from the Visium platform from 10x Genomics generated by the Lieber Institute for Brain Development (LIBD) and available through the spatialLIBD Bioconductor package.,3.19,GRCh38,GTF,https://bioconductor.org/packages/spatialLIBD,June 11 2024,Homo sapiens,9606,TRUE,LIBD,Leonardo Collado-Torres ,SpatialExperiment,Rds,spatialLIBD/spatialLIBD_files/Visium_LS_spe.rds,VisiumLS_Visium_stitched_spatialLIBD +Visium_LS_spaceranger,Spaceranger outputs for the spatially stitched lateral septum human brain (LS) spatial transcriptomics data (n = 3) from the Visium platform from 10x Genomics generated by the Lieber Institute for Brain Development (LIBD) and available through the spatialLIBD Bioconductor package. Can be used with visiumStitched::build_spe() to construct a SpatialExperiment.,3.19,GRCh38,Zip,https://bioconductor.org/packages/spatialLIBD,June 11 2024,Homo sapiens,9606,TRUE,LIBD,Leonardo Collado-Torres ,list,Zip,spatialLIBD/spatialLIBD_files/Visium_LS_spaceranger.zip,VisiumLS_Visium_stitched_spatialLIBD diff --git a/inst/scripts/make-metadata_Visium_LS.R b/inst/scripts/make-metadata_Visium_LS.R new file mode 100644 index 00000000..29a06420 --- /dev/null +++ b/inst/scripts/make-metadata_Visium_LS.R @@ -0,0 +1,184 @@ +library(here) +library(sessioninfo) +library(tidyverse) + +outdir <- "spatialLIBD_files" +pkgname <- "spatialLIBD" + +meta = tibble( + Title = c("Visium_LS_spe", "Visium_LS_spaceranger"), + Description = c( + "SpatialExperiment object at the spot-level for the spatially stitched lateral septum human brain (LS) spatial transcriptomics data (n = 3) from the Visium platform from 10x Genomics generated by the Lieber Institute for Brain Development (LIBD) and available through the spatialLIBD Bioconductor package.", + "Spaceranger outputs for the spatially stitched lateral septum human brain (LS) spatial transcriptomics data (n = 3) from the Visium platform from 10x Genomics generated by the Lieber Institute for Brain Development (LIBD) and available through the spatialLIBD Bioconductor package. Can be used with visiumStitched::build_spe() to construct a SpatialExperiment." + ), + BiocVersion = "3.19", + Genome = "GRCh38", + SourceType = c("GTF", "Zip"), + SourceUrl = "https://bioconductor.org/packages/spatialLIBD", + SourceVersion = "June 11 2024", + Species = "Homo sapiens", + TaxonomyId = 9606, + Coordinate_1_based = TRUE, + DataProvider = "LIBD", + Maintainer = "Leonardo Collado-Torres ", + RDataClass = c("SpatialExperiment", "list"), + DispatchClass = c("Rds", "Zip"), + RDataPath = file.path( + pkgname, + outdir, + c("Visium_LS_spe.rds", "Visium_LS_spaceranger.zip") + ), + Tags = "VisiumLS_Visium_stitched_spatialLIBD" +) + +write_csv(meta, here("inst", "extdata", "metadata_Visium_LS.csv")) + +## Check interactively +if (FALSE) { + AnnotationHubData::makeAnnotationHubMetadata( + here(), fileName = "metadata_Visium_LS.csv" + ) +} + +## Reproducibility information +print("Reproducibility information:") +Sys.time() +proc.time() +options(width = 120) +session_info() + +# ─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +# setting value +# version R version 4.4.0 Patched (2024-05-22 r86590) +# os Rocky Linux 9.2 (Blue Onyx) +# system x86_64, linux-gnu +# ui X11 +# language (EN) +# collate en_US.UTF-8 +# ctype en_US.UTF-8 +# tz US/Eastern +# date 2024-06-11 +# pandoc 3.1.13 @ /jhpce/shared/community/core/conda_R/4.4/bin/pandoc + +# ─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── +# package * version date (UTC) lib source +# abind 1.4-5 2016-07-21 [2] CRAN (R 4.4.0) +# AnnotationDbi 1.66.0 2024-05-01 [2] Bioconductor 3.19 (R 4.4.0) +# AnnotationForge 1.46.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# AnnotationHub 3.12.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# AnnotationHubData 1.34.0 2024-04-30 [1] Bioconductor 3.19 (R 4.4.0) +# Biobase 2.64.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# BiocBaseUtils 1.6.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# BiocCheck 1.40.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# BiocFileCache 2.12.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# BiocGenerics 0.50.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# BiocIO 1.14.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# BiocManager 1.30.23 2024-05-04 [2] CRAN (R 4.4.0) +# BiocParallel 1.38.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# BiocVersion 3.19.1 2024-04-17 [2] Bioconductor 3.19 (R 4.4.0) +# biocViews 1.72.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# biomaRt 2.60.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# Biostrings 2.72.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# bit 4.0.5 2022-11-15 [2] CRAN (R 4.4.0) +# bit64 4.0.5 2020-08-30 [2] CRAN (R 4.4.0) +# bitops 1.0-7 2021-04-24 [2] CRAN (R 4.4.0) +# blob 1.2.4 2023-03-17 [2] CRAN (R 4.4.0) +# cachem 1.1.0 2024-05-16 [2] CRAN (R 4.4.0) +# cli 3.6.2 2023-12-11 [2] CRAN (R 4.4.0) +# codetools 0.2-20 2024-03-31 [3] CRAN (R 4.4.0) +# colorspace 2.1-0 2023-01-23 [2] CRAN (R 4.4.0) +# crayon 1.5.2 2022-09-29 [2] CRAN (R 4.4.0) +# curl 5.2.1 2024-03-01 [2] CRAN (R 4.4.0) +# DBI 1.2.2 2024-02-16 [2] CRAN (R 4.4.0) +# dbplyr 2.5.0 2024-03-19 [2] CRAN (R 4.4.0) +# DelayedArray 0.30.1 2024-05-07 [2] Bioconductor 3.19 (R 4.4.0) +# digest 0.6.35 2024-03-11 [2] CRAN (R 4.4.0) +# dplyr * 1.1.4 2023-11-17 [2] CRAN (R 4.4.0) +# fansi 1.0.6 2023-12-08 [2] CRAN (R 4.4.0) +# fastmap 1.2.0 2024-05-15 [2] CRAN (R 4.4.0) +# filelock 1.0.3 2023-12-11 [2] CRAN (R 4.4.0) +# forcats * 1.0.0 2023-01-29 [2] CRAN (R 4.4.0) +# formatR 1.14 2023-01-17 [2] CRAN (R 4.4.0) +# futile.logger * 1.4.3 2016-07-10 [2] CRAN (R 4.4.0) +# futile.options 1.0.1 2018-04-20 [2] CRAN (R 4.4.0) +# generics 0.1.3 2022-07-05 [2] CRAN (R 4.4.0) +# GenomeInfoDb 1.40.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# GenomeInfoDbData 1.2.12 2024-05-23 [2] Bioconductor +# GenomicAlignments 1.40.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# GenomicFeatures 1.56.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# GenomicRanges 1.56.0 2024-05-01 [2] Bioconductor 3.19 (R 4.4.0) +# ggplot2 * 3.5.1 2024-04-23 [2] CRAN (R 4.4.0) +# glue 1.7.0 2024-01-09 [2] CRAN (R 4.4.0) +# graph 1.82.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# gtable 0.3.5 2024-04-22 [2] CRAN (R 4.4.0) +# here * 1.0.1 2020-12-13 [2] CRAN (R 4.4.0) +# hms 1.1.3 2023-03-21 [2] CRAN (R 4.4.0) +# httr 1.4.7 2023-08-15 [2] CRAN (R 4.4.0) +# httr2 1.0.1 2024-04-01 [2] CRAN (R 4.4.0) +# IRanges 2.38.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# jsonlite 1.8.8 2023-12-04 [2] CRAN (R 4.4.0) +# KEGGREST 1.44.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# knitr 1.46 2024-04-06 [2] CRAN (R 4.4.0) +# lambda.r 1.2.4 2019-09-18 [2] CRAN (R 4.4.0) +# lattice 0.22-6 2024-03-20 [3] CRAN (R 4.4.0) +# lifecycle 1.0.4 2023-11-07 [2] CRAN (R 4.4.0) +# lubridate * 1.9.3 2023-09-27 [2] CRAN (R 4.4.0) +# magrittr 2.0.3 2022-03-30 [2] CRAN (R 4.4.0) +# Matrix 1.7-0 2024-04-26 [3] CRAN (R 4.4.0) +# MatrixGenerics 1.16.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# matrixStats 1.3.0 2024-04-11 [2] CRAN (R 4.4.0) +# memoise 2.0.1 2021-11-26 [2] CRAN (R 4.4.0) +# munsell 0.5.1 2024-04-01 [2] CRAN (R 4.4.0) +# OrganismDbi 1.46.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# pillar 1.9.0 2023-03-22 [2] CRAN (R 4.4.0) +# pkgconfig 2.0.3 2019-09-22 [2] CRAN (R 4.4.0) +# png 0.1-8 2022-11-29 [2] CRAN (R 4.4.0) +# prettyunits 1.2.0 2023-09-24 [2] CRAN (R 4.4.0) +# progress 1.2.3 2023-12-06 [2] CRAN (R 4.4.0) +# purrr * 1.0.2 2023-08-10 [2] CRAN (R 4.4.0) +# R6 2.5.1 2021-08-19 [2] CRAN (R 4.4.0) +# rappdirs 0.3.3 2021-01-31 [2] CRAN (R 4.4.0) +# RBGL 1.80.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# RCurl 1.98-1.14 2024-01-09 [2] CRAN (R 4.4.0) +# readr * 2.1.5 2024-01-10 [2] CRAN (R 4.4.0) +# restfulr 0.0.15 2022-06-16 [2] CRAN (R 4.4.0) +# rjson 0.2.21 2022-01-09 [2] CRAN (R 4.4.0) +# rlang 1.1.3 2024-01-10 [2] CRAN (R 4.4.0) +# rprojroot 2.0.4 2023-11-05 [2] CRAN (R 4.4.0) +# Rsamtools 2.20.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# RSQLite 2.3.6 2024-03-31 [2] CRAN (R 4.4.0) +# rtracklayer 1.64.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# RUnit 0.4.33 2024-02-22 [2] CRAN (R 4.4.0) +# S4Arrays 1.4.1 2024-05-20 [2] Bioconductor 3.19 (R 4.4.0) +# S4Vectors 0.42.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# scales 1.3.0 2023-11-28 [2] CRAN (R 4.4.0) +# sessioninfo * 1.2.2 2021-12-06 [2] CRAN (R 4.4.0) +# SparseArray 1.4.5 2024-05-20 [2] Bioconductor 3.19 (R 4.4.0) +# stringdist 0.9.12 2023-11-28 [2] CRAN (R 4.4.0) +# stringi 1.8.4 2024-05-06 [2] CRAN (R 4.4.0) +# stringr * 1.5.1 2023-11-14 [2] CRAN (R 4.4.0) +# SummarizedExperiment 1.34.0 2024-05-01 [2] Bioconductor 3.19 (R 4.4.0) +# tibble * 3.2.1 2023-03-20 [2] CRAN (R 4.4.0) +# tidyr * 1.3.1 2024-01-24 [2] CRAN (R 4.4.0) +# tidyselect 1.2.1 2024-03-11 [2] CRAN (R 4.4.0) +# tidyverse * 2.0.0 2023-02-22 [2] CRAN (R 4.4.0) +# timechange 0.3.0 2024-01-18 [2] CRAN (R 4.4.0) +# txdbmaker 1.0.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# tzdb 0.4.0 2023-05-12 [2] CRAN (R 4.4.0) +# UCSC.utils 1.0.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# utf8 1.2.4 2023-10-22 [2] CRAN (R 4.4.0) +# vctrs 0.6.5 2023-12-01 [2] CRAN (R 4.4.0) +# vroom 1.6.5 2023-12-05 [2] CRAN (R 4.4.0) +# withr 3.0.0 2024-01-16 [2] CRAN (R 4.4.0) +# xfun 0.44 2024-05-15 [2] CRAN (R 4.4.0) +# XML 3.99-0.16.1 2024-01-22 [2] CRAN (R 4.4.0) +# xml2 1.3.6 2023-12-04 [2] CRAN (R 4.4.0) +# XVector 0.44.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) +# yaml 2.3.8 2023-12-11 [2] CRAN (R 4.4.0) +# zlibbioc 1.50.0 2024-04-30 [2] Bioconductor 3.19 (R 4.4.0) + +# [1] /users/neagles/R/4.4 +# [2] /jhpce/shared/community/core/conda_R/4.4/R/lib64/R/site-library +# [3] /jhpce/shared/community/core/conda_R/4.4/R/lib64/R/library + +# ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── From 0b68372ee92da99a88ba6780db4ca16b119354d3 Mon Sep 17 00:00:00 2001 From: Nick-Eagles Date: Thu, 20 Jun 2024 11:34:04 -0400 Subject: [PATCH 18/28] Add ImageJ outputs to the ExperimentHub metadata for the Visium LS data --- inst/extdata/metadata_Visium_LS.csv | 1 + inst/scripts/make-metadata_Visium_LS.R | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/inst/extdata/metadata_Visium_LS.csv b/inst/extdata/metadata_Visium_LS.csv index b8a150ea..5b868cf7 100644 --- a/inst/extdata/metadata_Visium_LS.csv +++ b/inst/extdata/metadata_Visium_LS.csv @@ -1,3 +1,4 @@ Title,Description,BiocVersion,Genome,SourceType,SourceUrl,SourceVersion,Species,TaxonomyId,Coordinate_1_based,DataProvider,Maintainer,RDataClass,DispatchClass,RDataPath,Tags Visium_LS_spe,SpatialExperiment object at the spot-level for the spatially stitched lateral septum human brain (LS) spatial transcriptomics data (n = 3) from the Visium platform from 10x Genomics generated by the Lieber Institute for Brain Development (LIBD) and available through the spatialLIBD Bioconductor package.,3.19,GRCh38,GTF,https://bioconductor.org/packages/spatialLIBD,June 11 2024,Homo sapiens,9606,TRUE,LIBD,Leonardo Collado-Torres ,SpatialExperiment,Rds,spatialLIBD/spatialLIBD_files/Visium_LS_spe.rds,VisiumLS_Visium_stitched_spatialLIBD Visium_LS_spaceranger,Spaceranger outputs for the spatially stitched lateral septum human brain (LS) spatial transcriptomics data (n = 3) from the Visium platform from 10x Genomics generated by the Lieber Institute for Brain Development (LIBD) and available through the spatialLIBD Bioconductor package. Can be used with visiumStitched::build_spe() to construct a SpatialExperiment.,3.19,GRCh38,Zip,https://bioconductor.org/packages/spatialLIBD,June 11 2024,Homo sapiens,9606,TRUE,LIBD,Leonardo Collado-Torres ,list,Zip,spatialLIBD/spatialLIBD_files/Visium_LS_spaceranger.zip,VisiumLS_Visium_stitched_spatialLIBD +Visium_LS_ImageJ_out,Stitched PNG image and XML file from aligning lateral septum human brain (LS) spatial transcriptomics data (n = 3) in ImageJ. Data to align was from the Visium platform from 10x Genomics generated by the Lieber Institute for Brain Development (LIBD) and is available through the spatialLIBD Bioconductor package.,3.19,GRCh38,Zip,https://bioconductor.org/packages/spatialLIBD,June 11 2024,Homo sapiens,9606,TRUE,LIBD,Leonardo Collado-Torres ,list,Zip,spatialLIBD/spatialLIBD_files/Visium_LS_imagej_out.zip,VisiumLS_Visium_stitched_spatialLIBD diff --git a/inst/scripts/make-metadata_Visium_LS.R b/inst/scripts/make-metadata_Visium_LS.R index 29a06420..8771569e 100644 --- a/inst/scripts/make-metadata_Visium_LS.R +++ b/inst/scripts/make-metadata_Visium_LS.R @@ -6,14 +6,15 @@ outdir <- "spatialLIBD_files" pkgname <- "spatialLIBD" meta = tibble( - Title = c("Visium_LS_spe", "Visium_LS_spaceranger"), + Title = c("Visium_LS_spe", "Visium_LS_spaceranger", "Visium_LS_ImageJ_out"), Description = c( "SpatialExperiment object at the spot-level for the spatially stitched lateral septum human brain (LS) spatial transcriptomics data (n = 3) from the Visium platform from 10x Genomics generated by the Lieber Institute for Brain Development (LIBD) and available through the spatialLIBD Bioconductor package.", - "Spaceranger outputs for the spatially stitched lateral septum human brain (LS) spatial transcriptomics data (n = 3) from the Visium platform from 10x Genomics generated by the Lieber Institute for Brain Development (LIBD) and available through the spatialLIBD Bioconductor package. Can be used with visiumStitched::build_spe() to construct a SpatialExperiment." + "Spaceranger outputs for the spatially stitched lateral septum human brain (LS) spatial transcriptomics data (n = 3) from the Visium platform from 10x Genomics generated by the Lieber Institute for Brain Development (LIBD) and available through the spatialLIBD Bioconductor package. Can be used with visiumStitched::build_spe() to construct a SpatialExperiment.", + "Stitched PNG image and XML file from aligning lateral septum human brain (LS) spatial transcriptomics data (n = 3) in ImageJ. Data to align was from the Visium platform from 10x Genomics generated by the Lieber Institute for Brain Development (LIBD) and is available through the spatialLIBD Bioconductor package." ), BiocVersion = "3.19", Genome = "GRCh38", - SourceType = c("GTF", "Zip"), + SourceType = c("GTF", "Zip", "Zip"), SourceUrl = "https://bioconductor.org/packages/spatialLIBD", SourceVersion = "June 11 2024", Species = "Homo sapiens", @@ -21,12 +22,15 @@ meta = tibble( Coordinate_1_based = TRUE, DataProvider = "LIBD", Maintainer = "Leonardo Collado-Torres ", - RDataClass = c("SpatialExperiment", "list"), - DispatchClass = c("Rds", "Zip"), + RDataClass = c("SpatialExperiment", "list", "list"), + DispatchClass = c("Rds", "Zip", "Zip"), RDataPath = file.path( pkgname, outdir, - c("Visium_LS_spe.rds", "Visium_LS_spaceranger.zip") + c( + "Visium_LS_spe.rds", "Visium_LS_spaceranger.zip", + "Visium_LS_imagej_out.zip" + ) ), Tags = "VisiumLS_Visium_stitched_spatialLIBD" ) From 88a7fb2c0567f9456f8819bbaf8aaf614f01f8f4 Mon Sep 17 00:00:00 2001 From: lcolladotor Date: Tue, 2 Jul 2024 11:39:41 -0400 Subject: [PATCH 19/28] Reviewed code from https://github.com/LieberInstitute/spatialLIBD/pull/82 Co-authored-by: Nick Eagles --- R/prep_stitched_data.R | 7 +++---- R/vis_clus.R | 12 ++++++------ tests/testthat/test-vis_clus.R | 6 ++++-- tests/testthat/test-vis_gene.R | 6 ++++-- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/R/prep_stitched_data.R b/R/prep_stitched_data.R index 1b46a44f..2de6c7b2 100644 --- a/R/prep_stitched_data.R +++ b/R/prep_stitched_data.R @@ -2,7 +2,7 @@ #' #' Given a \code{SpatialExperiment} built with \code{visiumStitched::build_spe()} #' , drop -#' exluded spots (specified by \code{spe$exclude_overlapping}) and compute an +#' excluded spots (specified by \code{spe$exclude_overlapping}) and compute an #' appropriate spot size for plotting with \code{vis_gene()} or #' \code{vis_clus()}, assuming the plot will be written to a PDF of default #' dimensions (i.e. \code{width = 7} and \code{height = 7}). @@ -14,10 +14,9 @@ #' @inheritParams vis_clus #' #' @return A list with names \code{spe} and \code{point_size} containing a -#' filtered, ready-to-plot \code{SpatialExperiment} and an appopriate spot size +#' filtered, ready-to-plot \code{SpatialExperiment} and an appropriate spot size #' (passed to \code{vis_gene()} or \code{vis_clus()}), respectively #' -#' @import SpatialExperiment #' @author Nicholas J. Eagles #' @keywords internal prep_stitched_data = function(spe, point_size, image_id) { @@ -70,6 +69,6 @@ prep_stitched_data = function(spe, point_size, image_id) { # The coefficient of 100 was determined empirically point_size <- point_size * 100 * INTER_SPOT_DIST_PX * small_image_data$scaleFactor / max(dim(small_image_data$data[[1]])) - + return(list(spe = spe, point_size = point_size)) } diff --git a/R/vis_clus.R b/R/vis_clus.R index c7534f34..239605b5 100644 --- a/R/vis_clus.R +++ b/R/vis_clus.R @@ -29,12 +29,12 @@ #' alpha blending already, which will make non-NA values pop up more and the NA #' values will show with a lighter color. This behavior is lost when `alpha` is #' set to a non-`NA` value. -#' @param is_stitched A \code{logical(1)} vector: If true, expects a -#' \code{SpatialExperiment} built with \code{visiumStitched::build_spe()} +#' @param is_stitched A \code{logical(1)} vector: If `TRUE`, expects a +#' [SpatialExperiment-class][SpatialExperiment::SpatialExperiment-class] built +#' with `visiumStitched::build_spe()`. #' ; in -#' particular, expects a logical colData column \code{exclude_overlapping} -#' specifying which spots to exclude from the plot. Sets \code{auto_crop = FALSE} -#' when TRUE. +#' particular, expects a logical colData column `exclude_overlapping` +#' specifying which spots to exclude from the plot. Sets `auto_crop = FALSE`. #' @param ... Passed to [paste0()][base::paste] for making the title of the #' plot following the `sampleid`. #' @@ -152,7 +152,7 @@ vis_clus <- function(spe, temp = prep_stitched_data(spe_sub, point_size, image_id) spe_sub = temp$spe point_size = temp$point_size - + # Frame limits are poorly defined for stitched data auto_crop = FALSE } diff --git a/tests/testthat/test-vis_clus.R b/tests/testthat/test-vis_clus.R index 4870342b..a1d67525 100644 --- a/tests/testthat/test-vis_clus.R +++ b/tests/testthat/test-vis_clus.R @@ -4,10 +4,12 @@ test_that( if (!exists("spe")) spe <- fetch_data("spe") # Bad spatialCoords - colnames(spatialCoords(spe)) = c('a', 'b') + spe_temp <- spe + colnames(spatialCoords(spe_temp)) = c('a', 'b') expect_error( - { p <- vis_clus(spe, clustervar = "sample_id") }, + { p <- vis_clus(spe_temp, clustervar = "sample_id") }, "^Abnormal spatial coordinates" ) + rm(spe_temp) } ) diff --git a/tests/testthat/test-vis_gene.R b/tests/testthat/test-vis_gene.R index f882f344..352bfe1b 100644 --- a/tests/testthat/test-vis_gene.R +++ b/tests/testthat/test-vis_gene.R @@ -54,10 +54,12 @@ test_that( # Bad spatialCoords - colnames(spatialCoords(spe)) = c('a', 'b') + spe_temp <- spe + colnames(spatialCoords(spe_temp)) = c('a', 'b') expect_error( - { p <- vis_gene(spe, geneid = "sum_umi") }, + { p <- vis_gene(spe_temp, geneid = "sum_umi") }, "^Abnormal spatial coordinates" ) + rm(spe_temp) } ) From 5926a32c37f6dbd200a81ee0cbe71a2241e69abc Mon Sep 17 00:00:00 2001 From: lcolladotor Date: Tue, 2 Jul 2024 11:40:24 -0400 Subject: [PATCH 20/28] Re-run devtools::document() Co-authored-by: Nick Eagles --- NAMESPACE | 1 - man/prep_stitched_data.Rd | 4 ++-- man/vis_clus.Rd | 8 ++++---- man/vis_gene.Rd | 8 ++++---- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 8b8698aa..d18236fa 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -48,7 +48,6 @@ export(vis_grid_gene) import(ExperimentHub) import(MatrixGenerics) import(SingleCellExperiment) -import(SpatialExperiment) import(ggplot2) import(grid) import(paletteer) diff --git a/man/prep_stitched_data.Rd b/man/prep_stitched_data.Rd index 3266806f..e87c0140 100644 --- a/man/prep_stitched_data.Rd +++ b/man/prep_stitched_data.Rd @@ -20,13 +20,13 @@ use in the background.} } \value{ A list with names \code{spe} and \code{point_size} containing a -filtered, ready-to-plot \code{SpatialExperiment} and an appopriate spot size +filtered, ready-to-plot \code{SpatialExperiment} and an appropriate spot size (passed to \code{vis_gene()} or \code{vis_clus()}), respectively } \description{ Given a \code{SpatialExperiment} built with \code{visiumStitched::build_spe()} \url{http://research.libd.org/visiumStitched/reference/build_spe.html}, drop -exluded spots (specified by \code{spe$exclude_overlapping}) and compute an +excluded spots (specified by \code{spe$exclude_overlapping}) and compute an appropriate spot size for plotting with \code{vis_gene()} or \code{vis_clus()}, assuming the plot will be written to a PDF of default dimensions (i.e. \code{width = 7} and \code{height = 7}). diff --git a/man/vis_clus.Rd b/man/vis_clus.Rd index 6ad8c28c..10729e46 100644 --- a/man/vis_clus.Rd +++ b/man/vis_clus.Rd @@ -60,12 +60,12 @@ alpha blending already, which will make non-NA values pop up more and the NA values will show with a lighter color. This behavior is lost when \code{alpha} is set to a non-\code{NA} value.} -\item{is_stitched}{A \code{logical(1)} vector: If true, expects a -\code{SpatialExperiment} built with \code{visiumStitched::build_spe()} +\item{is_stitched}{A \code{logical(1)} vector: If \code{TRUE}, expects a +\link[SpatialExperiment:SpatialExperiment]{SpatialExperiment-class} built +with \code{visiumStitched::build_spe()}. \url{http://research.libd.org/visiumStitched/reference/build_spe.html}; in particular, expects a logical colData column \code{exclude_overlapping} -specifying which spots to exclude from the plot. Sets \code{auto_crop = FALSE} -when TRUE.} +specifying which spots to exclude from the plot. Sets \code{auto_crop = FALSE}.} \item{...}{Passed to \link[base:paste]{paste0()} for making the title of the plot following the \code{sampleid}.} diff --git a/man/vis_gene.Rd b/man/vis_gene.Rd index 0c46ef8c..2a6f94e6 100644 --- a/man/vis_gene.Rd +++ b/man/vis_gene.Rd @@ -93,12 +93,12 @@ the proportion of continuous variables with positive values for each spot is computed. For more details, check the multi gene vignette at \url{https://research.libd.org/spatialLIBD/articles/multi_gene_plots.html}.} -\item{is_stitched}{A \code{logical(1)} vector: If true, expects a -\code{SpatialExperiment} built with \code{visiumStitched::build_spe()} +\item{is_stitched}{A \code{logical(1)} vector: If \code{TRUE}, expects a +\link[SpatialExperiment:SpatialExperiment]{SpatialExperiment-class} built +with \code{visiumStitched::build_spe()}. \url{http://research.libd.org/visiumStitched/reference/build_spe.html}; in particular, expects a logical colData column \code{exclude_overlapping} -specifying which spots to exclude from the plot. Sets \code{auto_crop = FALSE} -when TRUE.} +specifying which spots to exclude from the plot. Sets \code{auto_crop = FALSE}.} \item{...}{Passed to \link[base:paste]{paste0()} for making the title of the plot following the \code{sampleid}.} From 3b8794d977709ba2ce9a37b0c5f3d3f84da1219b Mon Sep 17 00:00:00 2001 From: lcolladotor Date: Tue, 2 Jul 2024 11:41:28 -0400 Subject: [PATCH 21/28] Auto-styled --- R/add10xVisiumAnalysis.R | 5 +- R/add_images.R | 13 ++-- R/annotate_registered_clusters.R | 16 ++-- R/check_sce.R | 69 +++++++++-------- R/check_spe.R | 15 ++-- R/fetch_data.R | 41 +++++----- R/frame_limits.R | 21 +++-- R/gene_set_enrichment.R | 11 ++- R/gene_set_enrichment_plot.R | 23 +++--- R/geom_spatial.R | 17 ++--- R/img_edit.R | 37 +++++---- R/img_update.R | 13 ++-- R/img_update_all.R | 11 ++- R/layer_boxplot.R | 27 ++++--- R/layer_matrix_plot.R | 27 ++++--- R/layer_stat_cor.R | 11 ++- R/layer_stat_cor_plot.R | 11 ++- R/prep_stitched_data.R | 6 +- R/read10xVisiumAnalysis.R | 5 +- R/read10xVisiumWrapper.R | 21 +++-- R/registration_model.R | 7 +- R/registration_pseudobulk.R | 13 ++-- R/registration_stats_anova.R | 17 ++--- R/registration_stats_enrichment.R | 15 ++-- R/registration_stats_pairwise.R | 15 ++-- R/registration_wrapper.R | 19 ++--- R/run_app.R | 97 ++++++++++++------------ R/sig_genes_extract.R | 11 +-- R/sig_genes_extract_all.R | 7 +- R/vis_clus.R | 59 +++++++------- R/vis_clus_p.R | 25 +++--- R/vis_gene.R | 45 +++++------ R/vis_gene_p.R | 35 +++++---- R/vis_grid_clus.R | 33 ++++---- R/vis_grid_gene.R | 37 +++++---- inst/scripts/make-metadata_Visium_LS.R | 5 +- tests/testthat/test-prep_stitched_data.R | 14 ++-- tests/testthat/test-vis_clus.R | 6 +- tests/testthat/test-vis_gene.R | 6 +- 39 files changed, 429 insertions(+), 437 deletions(-) diff --git a/R/add10xVisiumAnalysis.R b/R/add10xVisiumAnalysis.R index dbe49f86..de4f5fee 100644 --- a/R/add10xVisiumAnalysis.R +++ b/R/add10xVisiumAnalysis.R @@ -29,9 +29,8 @@ #' #' ## Note that ?SpatialExperiment::read10xVisium doesn't include all the files #' ## we need to illustrate read10xVisiumWrapper(). -add10xVisiumAnalysis <- function( - spe, - visium_analysis) { +add10xVisiumAnalysis <- function(spe, + visium_analysis) { col_info <- colData(spe) barcode_present <- "barcode" %in% colnames(col_info) if (!barcode_present) { diff --git a/R/add_images.R b/R/add_images.R index e7b09e5c..bfdddbe5 100644 --- a/R/add_images.R +++ b/R/add_images.R @@ -43,13 +43,12 @@ #' )) #' } add_images <- - function( - spe, - image_dir, - image_pattern, - image_id_current = "lowres", - image_id = image_pattern, - image_paths = locate_images(spe, image_dir, image_pattern)) { + function(spe, + image_dir, + image_pattern, + image_id_current = "lowres", + image_id = image_pattern, + image_paths = locate_images(spe, image_dir, image_pattern)) { stopifnot(length(names(image_paths)) > 0) stopifnot(all(names(image_paths) %in% unique(spe$sample_id))) stopifnot(!any(duplicated(names(image_paths)))) diff --git a/R/annotate_registered_clusters.R b/R/annotate_registered_clusters.R index 13e1d5ab..c2a9ec43 100644 --- a/R/annotate_registered_clusters.R +++ b/R/annotate_registered_clusters.R @@ -48,10 +48,9 @@ #' ## More relaxed merging threshold #' annotate_registered_clusters(cor_stats_layer, cutoff_merge_ratio = 1) annotate_registered_clusters <- - function( - cor_stats_layer, - confidence_threshold = 0.25, - cutoff_merge_ratio = 0.25) { + function(cor_stats_layer, + confidence_threshold = 0.25, + cutoff_merge_ratio = 0.25) { annotated <- apply(cor_stats_layer, 1, @@ -87,11 +86,10 @@ annotate_registered_clusters <- } annotate_registered_cluster <- - function( - remaining, - label = "", - current = NULL, - cutoff_merge_ratio = 0.25) { + function(remaining, + label = "", + current = NULL, + cutoff_merge_ratio = 0.25) { ## Filter negative correlations remaining <- remaining[remaining > 0] diff --git a/R/check_sce.R b/R/check_sce.R index 1d625342..0d17423b 100644 --- a/R/check_sce.R +++ b/R/check_sce.R @@ -24,41 +24,40 @@ #' ## Check the object #' check_sce(sce_example) #' } -check_sce <- function( - sce, - variables = c( - "GraphBased", - "ManualAnnotation", - "Maynard", - "Martinowich", - paste0("SNN_k50_k", 4:28), - "spatialLIBD", - "cell_count", - "sum_umi", - "sum_gene", - "expr_chrM", - "expr_chrM_ratio", - "SpatialDE_PCA", - "SpatialDE_pool_PCA", - "HVG_PCA", - "pseudobulk_PCA", - "markers_PCA", - "SpatialDE_UMAP", - "SpatialDE_pool_UMAP", - "HVG_UMAP", - "pseudobulk_UMAP", - "markers_UMAP", - "SpatialDE_PCA_spatial", - "SpatialDE_pool_PCA_spatial", - "HVG_PCA_spatial", - "pseudobulk_PCA_spatial", - "markers_PCA_spatial", - "SpatialDE_UMAP_spatial", - "SpatialDE_pool_UMAP_spatial", - "HVG_UMAP_spatial", - "pseudobulk_UMAP_spatial", - "markers_UMAP_spatial" - )) { +check_sce <- function(sce, + variables = c( + "GraphBased", + "ManualAnnotation", + "Maynard", + "Martinowich", + paste0("SNN_k50_k", 4:28), + "spatialLIBD", + "cell_count", + "sum_umi", + "sum_gene", + "expr_chrM", + "expr_chrM_ratio", + "SpatialDE_PCA", + "SpatialDE_pool_PCA", + "HVG_PCA", + "pseudobulk_PCA", + "markers_PCA", + "SpatialDE_UMAP", + "SpatialDE_pool_UMAP", + "HVG_UMAP", + "pseudobulk_UMAP", + "markers_UMAP", + "SpatialDE_PCA_spatial", + "SpatialDE_pool_PCA_spatial", + "HVG_PCA_spatial", + "pseudobulk_PCA_spatial", + "markers_PCA_spatial", + "SpatialDE_UMAP_spatial", + "SpatialDE_pool_UMAP_spatial", + "HVG_UMAP_spatial", + "pseudobulk_UMAP_spatial", + "markers_UMAP_spatial" + )) { ## Should be a SingleCellExperiment object stopifnot(is(sce, "SingleCellExperiment")) diff --git a/R/check_spe.R b/R/check_spe.R index d0344daa..47de3c0a 100644 --- a/R/check_spe.R +++ b/R/check_spe.R @@ -25,14 +25,13 @@ #' ## Check the object #' check_spe(spe) #' } -check_spe <- function( - spe, - variables = c( - "sum_umi", - "sum_gene", - "expr_chrM", - "expr_chrM_ratio" - )) { +check_spe <- function(spe, + variables = c( + "sum_umi", + "sum_gene", + "expr_chrM", + "expr_chrM_ratio" + )) { ## Should be a SpatialExperiment object stopifnot(is(spe, "SpatialExperiment")) diff --git a/R/fetch_data.R b/R/fetch_data.R index 3426ae6d..cc715e4a 100644 --- a/R/fetch_data.R +++ b/R/fetch_data.R @@ -84,26 +84,27 @@ #' #> 172.28 MB #' } fetch_data <- - function(type = c( - "sce", - "sce_layer", - "modeling_results", - "sce_example", - "spe", - "spatialDLPFC_Visium", - "spatialDLPFC_Visium_example_subset", - "spatialDLPFC_Visium_pseudobulk", - "spatialDLPFC_Visium_modeling_results", - "spatialDLPFC_Visium_SPG", - "spatialDLPFC_snRNAseq", - "Visium_SPG_AD_Visium_wholegenome_spe", - "Visium_SPG_AD_Visium_targeted_spe", - "Visium_SPG_AD_Visium_wholegenome_pseudobulk_spe", - "Visium_SPG_AD_Visium_wholegenome_modeling_results" - ), - destdir = tempdir(), - eh = ExperimentHub::ExperimentHub(), - bfc = BiocFileCache::BiocFileCache()) { + function( + type = c( + "sce", + "sce_layer", + "modeling_results", + "sce_example", + "spe", + "spatialDLPFC_Visium", + "spatialDLPFC_Visium_example_subset", + "spatialDLPFC_Visium_pseudobulk", + "spatialDLPFC_Visium_modeling_results", + "spatialDLPFC_Visium_SPG", + "spatialDLPFC_snRNAseq", + "Visium_SPG_AD_Visium_wholegenome_spe", + "Visium_SPG_AD_Visium_targeted_spe", + "Visium_SPG_AD_Visium_wholegenome_pseudobulk_spe", + "Visium_SPG_AD_Visium_wholegenome_modeling_results" + ), + destdir = tempdir(), + eh = ExperimentHub::ExperimentHub(), + bfc = BiocFileCache::BiocFileCache()) { ## Some variables sce <- sce_layer <- modeling_results <- sce_sub <- spe <- NULL diff --git a/R/frame_limits.R b/R/frame_limits.R index 320cc643..b22b5c8a 100644 --- a/R/frame_limits.R +++ b/R/frame_limits.R @@ -37,17 +37,16 @@ #' } #' frame_limits <- - function( - spe, - sampleid, - image_id = "lowres", - visium_grid = list( - row_min = 0, - row_max = 77, - col_min = 0, - col_max = 127, - fiducial_vs_capture_edge = (8 - 6.5) * 1000 / 2 / 100 - )) { + function(spe, + sampleid, + image_id = "lowres", + visium_grid = list( + row_min = 0, + row_max = 77, + col_min = 0, + col_max = 127, + fiducial_vs_capture_edge = (8 - 6.5) * 1000 / 2 / 100 + )) { ## Subset the info we need for the particular sample d <- as.data.frame(cbind(colData(spe), SpatialExperiment::spatialCoords(spe))[spe$sample_id == sampleid, ], diff --git a/R/gene_set_enrichment.R b/R/gene_set_enrichment.R index e6b6a63d..1accea28 100644 --- a/R/gene_set_enrichment.R +++ b/R/gene_set_enrichment.R @@ -58,12 +58,11 @@ #' ## Explore the results #' asd_sfari_enrichment gene_set_enrichment <- - function( - gene_list, - fdr_cut = 0.1, - modeling_results = fetch_data(type = "modeling_results"), - model_type = names(modeling_results)[1], - reverse = FALSE) { + function(gene_list, + fdr_cut = 0.1, + modeling_results = fetch_data(type = "modeling_results"), + model_type = names(modeling_results)[1], + reverse = FALSE) { model_results <- modeling_results[[model_type]] ## Keep only the genes present diff --git a/R/gene_set_enrichment_plot.R b/R/gene_set_enrichment_plot.R index c155e672..4ccbfcbc 100644 --- a/R/gene_set_enrichment_plot.R +++ b/R/gene_set_enrichment_plot.R @@ -84,18 +84,17 @@ #' layerHeights = c(0, 40, 55, 75, 85, 110, 120, 135), #' ) gene_set_enrichment_plot <- - function( - enrichment, - xlabs = unique(enrichment$ID), - PThresh = 12, - ORcut = 3, - enrichOnly = FALSE, - layerHeights = c(0, seq_len(length(unique(enrichment$test)))) * 15, - mypal = c( - "white", - grDevices::colorRampPalette(RColorBrewer::brewer.pal(9, "YlOrRd"))(50) - ), - cex = 1.2) { + function(enrichment, + xlabs = unique(enrichment$ID), + PThresh = 12, + ORcut = 3, + enrichOnly = FALSE, + layerHeights = c(0, seq_len(length(unique(enrichment$test)))) * 15, + mypal = c( + "white", + grDevices::colorRampPalette(RColorBrewer::brewer.pal(9, "YlOrRd"))(50) + ), + cex = 1.2) { ## Re-order and shorten names if they match our data if (all(unique(enrichment$test) %in% c("WM", paste0("Layer", seq_len(6))))) { enrichment$test <- diff --git a/R/geom_spatial.R b/R/geom_spatial.R index 965db758..64f00cc3 100644 --- a/R/geom_spatial.R +++ b/R/geom_spatial.R @@ -58,15 +58,14 @@ #' ## Clean up #' rm(spe_sub) #' } -geom_spatial <- function( - mapping = NULL, - data = NULL, - stat = "identity", - position = "identity", - na.rm = FALSE, - show.legend = NA, - inherit.aes = FALSE, - ...) { +geom_spatial <- function(mapping = NULL, + data = NULL, + stat = "identity", + position = "identity", + na.rm = FALSE, + show.legend = NA, + inherit.aes = FALSE, + ...) { ## To avoid a NOTE on R CMD check ggname <- function(prefix, grob) { grob$name <- grid::grobName(grob, prefix) diff --git a/R/img_edit.R b/R/img_edit.R index 93aceee3..ec6fae90 100644 --- a/R/img_edit.R +++ b/R/img_edit.R @@ -58,25 +58,24 @@ #' plot(x) #' } img_edit <- - function( - spe, - sampleid, - image_id = "lowres", - channel = NA, - brightness = 100, - saturation = 100, - hue = 100, - enhance = FALSE, - contrast_sharpen = NA, - quantize_max = NA, - quantize_dither = TRUE, - equalize = FALSE, - normalize = FALSE, - transparent_color = NA, - transparent_fuzz = 0, - background_color = NA, - median_radius = NA, - negate = FALSE) { + function(spe, + sampleid, + image_id = "lowres", + channel = NA, + brightness = 100, + saturation = 100, + hue = 100, + enhance = FALSE, + contrast_sharpen = NA, + quantize_max = NA, + quantize_dither = TRUE, + equalize = FALSE, + normalize = FALSE, + transparent_color = NA, + transparent_fuzz = 0, + background_color = NA, + median_radius = NA, + negate = FALSE) { img <- magick::image_read(SpatialExperiment::imgRaster(spe, sample_id = sampleid, image_id = image_id)) diff --git a/R/img_update.R b/R/img_update.R index fdfe5b83..db6dfcb1 100644 --- a/R/img_update.R +++ b/R/img_update.R @@ -41,13 +41,12 @@ #' imgData(img_update(spe, sampleid = "151507", brightness = 25)) #' } img_update <- - function( - spe, - sampleid, - image_id = "lowres", - new_image_id = paste0("edited_", image_id), - overwrite = FALSE, - ...) { + function(spe, + sampleid, + image_id = "lowres", + new_image_id = paste0("edited_", image_id), + overwrite = FALSE, + ...) { img_data <- SpatialExperiment::imgData(spe) ## Skip this sample if there's no existing image to update diff --git a/R/img_update_all.R b/R/img_update_all.R index 314b9b0d..31c368c9 100644 --- a/R/img_update_all.R +++ b/R/img_update_all.R @@ -22,12 +22,11 @@ #' imgData(img_update_all(spe, brightness = 25)) #' } img_update_all <- - function( - spe, - image_id = "lowres", - new_image_id = paste0("edited_", image_id), - overwrite = FALSE, - ...) { + function(spe, + image_id = "lowres", + new_image_id = paste0("edited_", image_id), + overwrite = FALSE, + ...) { for (sampleid in unique(spe$sample_id)) { spe <- img_update( diff --git a/R/layer_boxplot.R b/R/layer_boxplot.R index 6a671a5e..345d5499 100644 --- a/R/layer_boxplot.R +++ b/R/layer_boxplot.R @@ -114,20 +114,19 @@ #' col_high_point = "firebrick4", #' cex = 3 #' ) -layer_boxplot <- function( - i = 1, - sig_genes = sig_genes_extract(), - short_title = TRUE, - sce_layer = fetch_data(type = "sce_layer"), - col_bkg_box = "grey80", - col_bkg_point = "grey40", - col_low_box = "violet", - col_low_point = "darkviolet", - col_high_box = "skyblue", - col_high_point = "dodgerblue4", - cex = 2, - group_var = "layer_guess_reordered_short", - assayname = "logcounts") { +layer_boxplot <- function(i = 1, + sig_genes = sig_genes_extract(), + short_title = TRUE, + sce_layer = fetch_data(type = "sce_layer"), + col_bkg_box = "grey80", + col_bkg_point = "grey40", + col_low_box = "violet", + col_low_point = "darkviolet", + col_high_box = "skyblue", + col_high_point = "dodgerblue4", + cex = 2, + group_var = "layer_guess_reordered_short", + assayname = "logcounts") { ## Extract the logcounts (default) mat <- assay(sce_layer, assayname) diff --git a/R/layer_matrix_plot.R b/R/layer_matrix_plot.R index 4a44fd18..f1530fb1 100644 --- a/R/layer_matrix_plot.R +++ b/R/layer_matrix_plot.R @@ -55,20 +55,19 @@ #' cex = 2 #' ) layer_matrix_plot <- - function( - matrix_values, - matrix_labels = NULL, - xlabs = NULL, - layerHeights = NULL, - mypal = c( - "white", - grDevices::colorRampPalette(RColorBrewer::brewer.pal(9, "YlOrRd"))(50) - ), - breaks = NULL, - axis.args = NULL, - srt = 45, - mar = c(8, 4 + (max(nchar(rownames(matrix_values))) %/% 3) * 0.5, 4, 2) + 0.1, - cex = 1.2) { + function(matrix_values, + matrix_labels = NULL, + xlabs = NULL, + layerHeights = NULL, + mypal = c( + "white", + grDevices::colorRampPalette(RColorBrewer::brewer.pal(9, "YlOrRd"))(50) + ), + breaks = NULL, + axis.args = NULL, + srt = 45, + mar = c(8, 4 + (max(nchar(rownames(matrix_values))) %/% 3) * 0.5, 4, 2) + 0.1, + cex = 1.2) { ## Create some default values in case the user didn't specify them if (is.null(xlabs)) { if (is.null(colnames(matrix_values))) { diff --git a/R/layer_stat_cor.R b/R/layer_stat_cor.R index f484c912..0ccf0bf2 100644 --- a/R/layer_stat_cor.R +++ b/R/layer_stat_cor.R @@ -49,12 +49,11 @@ #' top_n = 10 #' )) layer_stat_cor <- - function( - stats, - modeling_results = fetch_data(type = "modeling_results"), - model_type = names(modeling_results)[1], - reverse = FALSE, - top_n = NULL) { + function(stats, + modeling_results = fetch_data(type = "modeling_results"), + model_type = names(modeling_results)[1], + reverse = FALSE, + top_n = NULL) { model_results <- modeling_results[[model_type]] tstats <- diff --git a/R/layer_stat_cor_plot.R b/R/layer_stat_cor_plot.R index 0d2653b8..c0f4e924 100644 --- a/R/layer_stat_cor_plot.R +++ b/R/layer_stat_cor_plot.R @@ -72,12 +72,11 @@ #' top_n = 10 #' ), max = 0.25) layer_stat_cor_plot <- - function( - cor_stats_layer, - max = 0.81, - min = -max, - layerHeights = NULL, - cex = 1.2) { + function(cor_stats_layer, + max = 0.81, + min = -max, + layerHeights = NULL, + cex = 1.2) { ## From https://github.com/LieberInstitute/HumanPilot/blob/master/Analysis/Layer_Guesses/dlpfc_snRNAseq_annotation.R theSeq <- seq(min, max, by = 0.01) my.col <- grDevices::colorRampPalette(RColorBrewer::brewer.pal(7, "PRGn"))(length(theSeq)) diff --git a/R/prep_stitched_data.R b/R/prep_stitched_data.R index 2de6c7b2..1485d924 100644 --- a/R/prep_stitched_data.R +++ b/R/prep_stitched_data.R @@ -19,7 +19,7 @@ #' #' @author Nicholas J. Eagles #' @keywords internal -prep_stitched_data = function(spe, point_size, image_id) { +prep_stitched_data <- function(spe, point_size, image_id) { # State assumptions about columns expected to be in the colData expected_cols <- c("array_row", "array_col", "exclude_overlapping") if (!all(expected_cols %in% colnames(colData(spe)))) { @@ -32,12 +32,12 @@ prep_stitched_data = function(spe, point_size, image_id) { ) } - if(any(is.na(spe$exclude_overlapping))) { + if (any(is.na(spe$exclude_overlapping))) { stop("spe$exclude_overlapping must not have NAs", call. = FALSE) } # Drop excluded spots; verify some spots are not excluded - subset_cols = !spe$exclude_overlapping + subset_cols <- !spe$exclude_overlapping if (length(which(subset_cols)) == 0) { stop( "spe$exclude_overlapping must include some FALSE values to plot", diff --git a/R/read10xVisiumAnalysis.R b/R/read10xVisiumAnalysis.R index 70bc49ac..ef76f1d0 100644 --- a/R/read10xVisiumAnalysis.R +++ b/R/read10xVisiumAnalysis.R @@ -24,8 +24,9 @@ #' #' ## Note that ?SpatialExperiment::read10xVisium doesn't include all the files #' ## we need to illustrate read10xVisiumWrapper(). -read10xVisiumAnalysis <- function(samples = "", - sample_id = paste0("sample", sprintf("%02d", seq_along(samples)))) { +read10xVisiumAnalysis <- function( + samples = "", + sample_id = paste0("sample", sprintf("%02d", seq_along(samples)))) { # check sample identifiers if (is.null(sids <- names(samples))) { if (is.null(sids <- sample_id)) { diff --git a/R/read10xVisiumWrapper.R b/R/read10xVisiumWrapper.R index d9f31fc2..501a744d 100644 --- a/R/read10xVisiumWrapper.R +++ b/R/read10xVisiumWrapper.R @@ -44,17 +44,16 @@ #' #' ## Note that ?SpatialExperiment::read10xVisium doesn't include all the files #' ## we need to illustrate read10xVisiumWrapper(). -read10xVisiumWrapper <- function( - samples = "", - sample_id = paste0("sample", sprintf("%02d", seq_along(samples))), - type = c("HDF5", "sparse"), - data = c("filtered", "raw"), - images = c("lowres", "hires", "detected", "aligned"), - load = TRUE, - reference_gtf = NULL, - chrM = "chrM", - gtf_cols = c("source", "type", "gene_id", "gene_version", "gene_name", "gene_type"), - verbose = TRUE) { +read10xVisiumWrapper <- function(samples = "", + sample_id = paste0("sample", sprintf("%02d", seq_along(samples))), + type = c("HDF5", "sparse"), + data = c("filtered", "raw"), + images = c("lowres", "hires", "detected", "aligned"), + load = TRUE, + reference_gtf = NULL, + chrM = "chrM", + gtf_cols = c("source", "type", "gene_id", "gene_version", "gene_name", "gene_type"), + verbose = TRUE) { stopifnot(all(c("gene_name", "gene_id") %in% gtf_cols)) if (missing(reference_gtf)) { diff --git a/R/registration_model.R b/R/registration_model.R index 6921dbb9..3f36260c 100644 --- a/R/registration_model.R +++ b/R/registration_model.R @@ -24,10 +24,9 @@ #' head(registration_mod) #' registration_model <- - function( - sce_pseudo, - covars = NULL, - var_registration = "registration_variable") { + function(sce_pseudo, + covars = NULL, + var_registration = "registration_variable") { ## Specify a formula without an intercept if (is.null(covars)) { mat_formula <- diff --git a/R/registration_pseudobulk.R b/R/registration_pseudobulk.R index 2d859e4e..5f3c5dd2 100644 --- a/R/registration_pseudobulk.R +++ b/R/registration_pseudobulk.R @@ -51,12 +51,13 @@ #' sce_pseudo <- registration_pseudobulk(sce, "Cell_Cycle", "sample_id", c("age"), min_ncells = NULL) #' colData(sce_pseudo) registration_pseudobulk <- - function(sce, - var_registration, - var_sample_id, - covars = NULL, - min_ncells = 10, - pseudobulk_rds_file = NULL) { + function( + sce, + var_registration, + var_sample_id, + covars = NULL, + min_ncells = 10, + pseudobulk_rds_file = NULL) { ## Check that inputs are correct stopifnot(is(sce, "SingleCellExperiment")) stopifnot(var_registration %in% colnames(colData(sce))) diff --git a/R/registration_stats_anova.R b/R/registration_stats_anova.R index d1d0b135..c899459d 100644 --- a/R/registration_stats_anova.R +++ b/R/registration_stats_anova.R @@ -50,15 +50,14 @@ #' results_anova_merged <- merge(results_anova, results_anova_nocovar) #' head(results_anova_merged) registration_stats_anova <- - function( - sce_pseudo, - block_cor, - covars = NULL, - var_registration = "registration_variable", - var_sample_id = "registration_sample_id", - gene_ensembl = NULL, - gene_name = NULL, - suffix = "") { + function(sce_pseudo, + block_cor, + covars = NULL, + var_registration = "registration_variable", + var_sample_id = "registration_sample_id", + gene_ensembl = NULL, + gene_name = NULL, + suffix = "") { if (is.null(covars)) { mat_formula <- eval(str2expression(paste("~", var_registration))) } else { diff --git a/R/registration_stats_enrichment.R b/R/registration_stats_enrichment.R index cd3ee182..d186547e 100644 --- a/R/registration_stats_enrichment.R +++ b/R/registration_stats_enrichment.R @@ -34,13 +34,14 @@ #' ) #' head(results_enrichment_nan) registration_stats_enrichment <- - function(sce_pseudo, - block_cor, - covars = NULL, - var_registration = "registration_variable", - var_sample_id = "registration_sample_id", - gene_ensembl = NULL, - gene_name = NULL) { + function( + sce_pseudo, + block_cor, + covars = NULL, + var_registration = "registration_variable", + var_sample_id = "registration_sample_id", + gene_ensembl = NULL, + gene_name = NULL) { ## For each cluster, test it against the rest cluster_idx <- split(seq(along = sce_pseudo[[var_registration]]), sce_pseudo[[var_registration]]) diff --git a/R/registration_stats_pairwise.R b/R/registration_stats_pairwise.R index 09bb3ff9..afb9771a 100644 --- a/R/registration_stats_pairwise.R +++ b/R/registration_stats_pairwise.R @@ -32,13 +32,14 @@ #' ) #' head(results_pairwise_nan) registration_stats_pairwise <- - function(sce_pseudo, - registration_model, - block_cor, - var_registration = "registration_variable", - var_sample_id = "registration_sample_id", - gene_ensembl = NULL, - gene_name = NULL) { + function( + sce_pseudo, + registration_model, + block_cor, + var_registration = "registration_variable", + var_sample_id = "registration_sample_id", + gene_ensembl = NULL, + gene_name = NULL) { ## Identify which are the pairwise columns of interest (aka, don't use ## the sample-level covariates we are adjusting for) and then ## shorten the names diff --git a/R/registration_wrapper.R b/R/registration_wrapper.R index 38a1c297..49896d78 100644 --- a/R/registration_wrapper.R +++ b/R/registration_wrapper.R @@ -50,15 +50,16 @@ #' "Cell_Cycle", "sample_id", c("age"), "ensembl", "gene_name", "wrapper" #' ) registration_wrapper <- - function(sce, - var_registration, - var_sample_id, - covars = NULL, - gene_ensembl = NULL, - gene_name = NULL, - suffix = "", - min_ncells = 10, - pseudobulk_rds_file = NULL) { + function( + sce, + var_registration, + var_sample_id, + covars = NULL, + gene_ensembl = NULL, + gene_name = NULL, + suffix = "", + min_ncells = 10, + pseudobulk_rds_file = NULL) { ## Change the rownames to ENSEMBL IDs rownames(sce) <- rowData(sce)[, gene_ensembl] diff --git a/R/run_app.R b/R/run_app.R index 93701444..b7beae48 100644 --- a/R/run_app.R +++ b/R/run_app.R @@ -186,55 +186,54 @@ #' ## * https://github.com/LieberInstitute/spatialDLPFC/tree/main/code/deploy_app_k16 #' ## * https://github.com/LieberInstitute/spatialDLPFC/tree/main/code/analysis_IF/03_spatialLIBD_app #' } -run_app <- function( - spe = fetch_data(type = "spe"), - sce_layer = fetch_data(type = "sce_layer"), - modeling_results = fetch_data(type = "modeling_results"), - sig_genes = sig_genes_extract_all( - n = nrow(sce_layer), - modeling_results = modeling_results, - sce_layer = sce_layer - ), - docs_path = system.file("app", "www", package = "spatialLIBD"), - title = "spatialLIBD", - spe_discrete_vars = c( - "spatialLIBD", - "GraphBased", - "ManualAnnotation", - "Maynard", - "Martinowich", - paste0("SNN_k50_k", 4:28), - "SpatialDE_PCA", - "SpatialDE_pool_PCA", - "HVG_PCA", - "pseudobulk_PCA", - "markers_PCA", - "SpatialDE_UMAP", - "SpatialDE_pool_UMAP", - "HVG_UMAP", - "pseudobulk_UMAP", - "markers_UMAP", - "SpatialDE_PCA_spatial", - "SpatialDE_pool_PCA_spatial", - "HVG_PCA_spatial", - "pseudobulk_PCA_spatial", - "markers_PCA_spatial", - "SpatialDE_UMAP_spatial", - "SpatialDE_pool_UMAP_spatial", - "HVG_UMAP_spatial", - "pseudobulk_UMAP_spatial", - "markers_UMAP_spatial" - ), - spe_continuous_vars = c( - "cell_count", - "sum_umi", - "sum_gene", - "expr_chrM", - "expr_chrM_ratio" - ), - default_cluster = "spatialLIBD", - auto_crop_default = TRUE, - ...) { +run_app <- function(spe = fetch_data(type = "spe"), + sce_layer = fetch_data(type = "sce_layer"), + modeling_results = fetch_data(type = "modeling_results"), + sig_genes = sig_genes_extract_all( + n = nrow(sce_layer), + modeling_results = modeling_results, + sce_layer = sce_layer + ), + docs_path = system.file("app", "www", package = "spatialLIBD"), + title = "spatialLIBD", + spe_discrete_vars = c( + "spatialLIBD", + "GraphBased", + "ManualAnnotation", + "Maynard", + "Martinowich", + paste0("SNN_k50_k", 4:28), + "SpatialDE_PCA", + "SpatialDE_pool_PCA", + "HVG_PCA", + "pseudobulk_PCA", + "markers_PCA", + "SpatialDE_UMAP", + "SpatialDE_pool_UMAP", + "HVG_UMAP", + "pseudobulk_UMAP", + "markers_UMAP", + "SpatialDE_PCA_spatial", + "SpatialDE_pool_PCA_spatial", + "HVG_PCA_spatial", + "pseudobulk_PCA_spatial", + "markers_PCA_spatial", + "SpatialDE_UMAP_spatial", + "SpatialDE_pool_UMAP_spatial", + "HVG_UMAP_spatial", + "pseudobulk_UMAP_spatial", + "markers_UMAP_spatial" + ), + spe_continuous_vars = c( + "cell_count", + "sum_umi", + "sum_gene", + "expr_chrM", + "expr_chrM_ratio" + ), + default_cluster = "spatialLIBD", + auto_crop_default = TRUE, + ...) { ## Run the checks in the relevant order stopifnot(length(default_cluster) == 1) stopifnot(default_cluster %in% spe_discrete_vars) diff --git a/R/sig_genes_extract.R b/R/sig_genes_extract.R index fac5f65b..b21902c1 100644 --- a/R/sig_genes_extract.R +++ b/R/sig_genes_extract.R @@ -59,11 +59,12 @@ #' sce_layer = sce_layer, #' n = nrow(sce_layer) #' ) -sig_genes_extract <- function(n = 10, - modeling_results = fetch_data(type = "modeling_results"), - model_type = names(modeling_results)[1], - reverse = FALSE, - sce_layer = fetch_data(type = "sce_layer")) { +sig_genes_extract <- function( + n = 10, + modeling_results = fetch_data(type = "modeling_results"), + model_type = names(modeling_results)[1], + reverse = FALSE, + sce_layer = fetch_data(type = "sce_layer")) { model_results <- modeling_results[[model_type]] tstats <- diff --git a/R/sig_genes_extract_all.R b/R/sig_genes_extract_all.R index 0d68b880..d2c3c01f 100644 --- a/R/sig_genes_extract_all.R +++ b/R/sig_genes_extract_all.R @@ -27,9 +27,10 @@ #' modeling_results = modeling_results, #' sce_layer = sce_layer #' ) -sig_genes_extract_all <- function(n = 10, - modeling_results = fetch_data(type = "modeling_results"), - sce_layer = fetch_data(type = "sce_layer")) { +sig_genes_extract_all <- function( + n = 10, + modeling_results = fetch_data(type = "modeling_results"), + sce_layer = fetch_data(type = "sce_layer")) { ## Run checks since this function is run by default by run_app() ## before the checks have been run elsewhere sce_layer <- check_sce_layer(sce_layer) diff --git a/R/vis_clus.R b/R/vis_clus.R index 239605b5..2dae1971 100644 --- a/R/vis_clus.R +++ b/R/vis_clus.R @@ -99,31 +99,32 @@ #' ) #' print(p4) #' } -vis_clus <- function(spe, - sampleid = unique(spe$sample_id)[1], - clustervar, - colors = c( - "#b2df8a", - "#e41a1c", - "#377eb8", - "#4daf4a", - "#ff7f00", - "gold", - "#a65628", - "#999999", - "black", - "grey", - "white", - "purple" - ), - spatial = TRUE, - image_id = "lowres", - alpha = NA, - point_size = 2, - auto_crop = TRUE, - na_color = "#CCCCCC40", - is_stitched = FALSE, - ...) { +vis_clus <- function( + spe, + sampleid = unique(spe$sample_id)[1], + clustervar, + colors = c( + "#b2df8a", + "#e41a1c", + "#377eb8", + "#4daf4a", + "#ff7f00", + "gold", + "#a65628", + "#999999", + "black", + "grey", + "white", + "purple" + ), + spatial = TRUE, + image_id = "lowres", + alpha = NA, + point_size = 2, + auto_crop = TRUE, + na_color = "#CCCCCC40", + is_stitched = FALSE, + ...) { # Verify existence and legitimacy of 'sampleid' if ( !("sample_id" %in% colnames(colData(spe))) || @@ -149,12 +150,12 @@ vis_clus <- function(spe, if (is_stitched) { # Drop excluded spots and calculate an appropriate point size - temp = prep_stitched_data(spe_sub, point_size, image_id) - spe_sub = temp$spe - point_size = temp$point_size + temp <- prep_stitched_data(spe_sub, point_size, image_id) + spe_sub <- temp$spe + point_size <- temp$point_size # Frame limits are poorly defined for stitched data - auto_crop = FALSE + auto_crop <- FALSE } d <- as.data.frame(cbind(colData(spe_sub), SpatialExperiment::spatialCoords(spe_sub)), optional = TRUE) diff --git a/R/vis_clus_p.R b/R/vis_clus_p.R index d2b37cec..a91ce369 100644 --- a/R/vis_clus_p.R +++ b/R/vis_clus_p.R @@ -42,19 +42,18 @@ #' rm(spe_sub) #' } vis_clus_p <- - function( - spe, - d, - clustervar, - sampleid = unique(spe$sample_id)[1], - colors, - spatial, - title, - image_id = "lowres", - alpha = NA, - point_size = 2, - auto_crop = TRUE, - na_color = "#CCCCCC40") { + function(spe, + d, + clustervar, + sampleid = unique(spe$sample_id)[1], + colors, + spatial, + title, + image_id = "lowres", + alpha = NA, + point_size = 2, + auto_crop = TRUE, + na_color = "#CCCCCC40") { ## Some variables pxl_row_in_fullres <- pxl_col_in_fullres <- key <- NULL # stopifnot(all(c("pxl_col_in_fullres", "pxl_row_in_fullres", "key") %in% colnames(d))) diff --git a/R/vis_gene.R b/R/vis_gene.R index 510932ec..6a28af3f 100644 --- a/R/vis_gene.R +++ b/R/vis_gene.R @@ -158,22 +158,23 @@ #' print(p8) #' } vis_gene <- - function(spe, - sampleid = unique(spe$sample_id)[1], - geneid = rowData(spe)$gene_search[1], - spatial = TRUE, - assayname = "logcounts", - minCount = 0, - viridis = TRUE, - image_id = "lowres", - alpha = NA, - cont_colors = if (viridis) viridisLite::viridis(21) else c("aquamarine4", "springgreen", "goldenrod", "red"), - point_size = 2, - auto_crop = TRUE, - na_color = "#CCCCCC40", - multi_gene_method = c("z_score", "pca", "sparsity"), - is_stitched = FALSE, - ...) { + function( + spe, + sampleid = unique(spe$sample_id)[1], + geneid = rowData(spe)$gene_search[1], + spatial = TRUE, + assayname = "logcounts", + minCount = 0, + viridis = TRUE, + image_id = "lowres", + alpha = NA, + cont_colors = if (viridis) viridisLite::viridis(21) else c("aquamarine4", "springgreen", "goldenrod", "red"), + point_size = 2, + auto_crop = TRUE, + na_color = "#CCCCCC40", + multi_gene_method = c("z_score", "pca", "sparsity"), + is_stitched = FALSE, + ...) { multi_gene_method <- rlang::arg_match(multi_gene_method) # Verify existence and legitimacy of 'sampleid' if ( @@ -205,14 +206,14 @@ vis_gene <- if (is_stitched) { # Drop excluded spots and calculate an appropriate point size - temp = prep_stitched_data(spe_sub, point_size, image_id) - spe_sub = temp$spe - point_size = temp$point_size - + temp <- prep_stitched_data(spe_sub, point_size, image_id) + spe_sub <- temp$spe + point_size <- temp$point_size + # Frame limits are poorly defined for stitched data - auto_crop = FALSE + auto_crop <- FALSE } - + d <- as.data.frame(cbind(colData(spe_sub), SpatialExperiment::spatialCoords(spe_sub)), optional = TRUE) # Verify legitimacy of names in geneid diff --git a/R/vis_gene_p.R b/R/vis_gene_p.R index 9bc3dc0a..e659d477 100644 --- a/R/vis_gene_p.R +++ b/R/vis_gene_p.R @@ -48,24 +48,23 @@ #' rm(spe_sub) #' } vis_gene_p <- - function( - spe, - d, - sampleid = unique(spe$sample_id)[1], - spatial, - title, - viridis = TRUE, - image_id = "lowres", - alpha = NA, - cont_colors = if (viridis) { - viridisLite::viridis(21) - } else { - c("aquamarine4", "springgreen", "goldenrod", "red") - }, - point_size = 2, - auto_crop = TRUE, - na_color = "#CCCCCC40", - legend_title = "") { + function(spe, + d, + sampleid = unique(spe$sample_id)[1], + spatial, + title, + viridis = TRUE, + image_id = "lowres", + alpha = NA, + cont_colors = if (viridis) { + viridisLite::viridis(21) + } else { + c("aquamarine4", "springgreen", "goldenrod", "red") + }, + point_size = 2, + auto_crop = TRUE, + na_color = "#CCCCCC40", + legend_title = "") { ## Some variables pxl_row_in_fullres <- pxl_col_in_fullres <- key <- COUNT <- NULL diff --git a/R/vis_grid_clus.R b/R/vis_grid_clus.R index 74b4d3ce..6c61cece 100644 --- a/R/vis_grid_clus.R +++ b/R/vis_grid_clus.R @@ -47,23 +47,22 @@ #' cowplot::plot_grid(plotlist = p_list, ncol = 2) #' } vis_grid_clus <- - function( - spe, - clustervar, - pdf_file, - sort_clust = TRUE, - colors = NULL, - return_plots = FALSE, - spatial = TRUE, - height = 24, - width = 36, - image_id = "lowres", - alpha = NA, - sample_order = unique(spe$sample_id), - point_size = 2, - auto_crop = TRUE, - na_color = "#CCCCCC40", - ...) { + function(spe, + clustervar, + pdf_file, + sort_clust = TRUE, + colors = NULL, + return_plots = FALSE, + spatial = TRUE, + height = 24, + width = 36, + image_id = "lowres", + alpha = NA, + sample_order = unique(spe$sample_id), + point_size = 2, + auto_crop = TRUE, + na_color = "#CCCCCC40", + ...) { stopifnot(all(sample_order %in% unique(spe$sample_id))) if (sort_clust) { diff --git a/R/vis_grid_gene.R b/R/vis_grid_gene.R index 2504cce5..e21b5bf1 100644 --- a/R/vis_grid_gene.R +++ b/R/vis_grid_gene.R @@ -35,25 +35,24 @@ #' cowplot::plot_grid(plotlist = p_list, ncol = 2) #' } vis_grid_gene <- - function( - spe, - geneid = rowData(spe)$gene_search[1], - pdf_file, - assayname = "logcounts", - minCount = 0, - return_plots = FALSE, - spatial = TRUE, - viridis = TRUE, - height = 24, - width = 36, - image_id = "lowres", - alpha = NA, - cont_colors = if (viridis) viridisLite::viridis(21) else c("aquamarine4", "springgreen", "goldenrod", "red"), - sample_order = unique(spe$sample_id), - point_size = 2, - auto_crop = TRUE, - na_color = "#CCCCCC40", - ...) { + function(spe, + geneid = rowData(spe)$gene_search[1], + pdf_file, + assayname = "logcounts", + minCount = 0, + return_plots = FALSE, + spatial = TRUE, + viridis = TRUE, + height = 24, + width = 36, + image_id = "lowres", + alpha = NA, + cont_colors = if (viridis) viridisLite::viridis(21) else c("aquamarine4", "springgreen", "goldenrod", "red"), + sample_order = unique(spe$sample_id), + point_size = 2, + auto_crop = TRUE, + na_color = "#CCCCCC40", + ...) { stopifnot(all(sample_order %in% unique(spe$sample_id))) plots <- lapply(sample_order, function(sampleid) { diff --git a/inst/scripts/make-metadata_Visium_LS.R b/inst/scripts/make-metadata_Visium_LS.R index 8771569e..9fefe846 100644 --- a/inst/scripts/make-metadata_Visium_LS.R +++ b/inst/scripts/make-metadata_Visium_LS.R @@ -5,7 +5,7 @@ library(tidyverse) outdir <- "spatialLIBD_files" pkgname <- "spatialLIBD" -meta = tibble( +meta <- tibble( Title = c("Visium_LS_spe", "Visium_LS_spaceranger", "Visium_LS_ImageJ_out"), Description = c( "SpatialExperiment object at the spot-level for the spatially stitched lateral septum human brain (LS) spatial transcriptomics data (n = 3) from the Visium platform from 10x Genomics generated by the Lieber Institute for Brain Development (LIBD) and available through the spatialLIBD Bioconductor package.", @@ -40,7 +40,8 @@ write_csv(meta, here("inst", "extdata", "metadata_Visium_LS.csv")) ## Check interactively if (FALSE) { AnnotationHubData::makeAnnotationHubMetadata( - here(), fileName = "metadata_Visium_LS.csv" + here(), + fileName = "metadata_Visium_LS.csv" ) } diff --git a/tests/testthat/test-prep_stitched_data.R b/tests/testthat/test-prep_stitched_data.R index f4206547..3866042d 100644 --- a/tests/testthat/test-prep_stitched_data.R +++ b/tests/testthat/test-prep_stitched_data.R @@ -7,18 +7,20 @@ test_that( expect_error( { temp <- prep_stitched_data( - spe, point_size = 2, image_id = "lowres" + spe, + point_size = 2, image_id = "lowres" ) }, "^Missing at least one of the following colData" ) # Can't exclude all spots - spe$exclude_overlapping = TRUE + spe$exclude_overlapping <- TRUE expect_error( { temp <- prep_stitched_data( - spe, point_size = 2, image_id = "lowres" + spe, + point_size = 2, image_id = "lowres" ) }, "^spe\\$exclude_overlapping must include some FALSE values to plot$" @@ -26,10 +28,10 @@ test_that( # Output should be a list with the correct names, and the # SpatialExperiment should have no excluded spots - spe$exclude_overlapping[1:100] = FALSE + spe$exclude_overlapping[1:100] <- FALSE temp <- prep_stitched_data(spe, point_size = 2, image_id = "lowres") - expect_equal(class(temp), 'list') - expect_equal(names(temp), c('spe', 'point_size')) + expect_equal(class(temp), "list") + expect_equal(names(temp), c("spe", "point_size")) expect_equal(all(temp$spe$exclude_overlapping), FALSE) # Note bad image_id is not tested, since this function is only used diff --git a/tests/testthat/test-vis_clus.R b/tests/testthat/test-vis_clus.R index a1d67525..ab011efb 100644 --- a/tests/testthat/test-vis_clus.R +++ b/tests/testthat/test-vis_clus.R @@ -5,9 +5,11 @@ test_that( # Bad spatialCoords spe_temp <- spe - colnames(spatialCoords(spe_temp)) = c('a', 'b') + colnames(spatialCoords(spe_temp)) <- c("a", "b") expect_error( - { p <- vis_clus(spe_temp, clustervar = "sample_id") }, + { + p <- vis_clus(spe_temp, clustervar = "sample_id") + }, "^Abnormal spatial coordinates" ) rm(spe_temp) diff --git a/tests/testthat/test-vis_gene.R b/tests/testthat/test-vis_gene.R index 352bfe1b..b4a171c1 100644 --- a/tests/testthat/test-vis_gene.R +++ b/tests/testthat/test-vis_gene.R @@ -55,9 +55,11 @@ test_that( # Bad spatialCoords spe_temp <- spe - colnames(spatialCoords(spe_temp)) = c('a', 'b') + colnames(spatialCoords(spe_temp)) <- c("a", "b") expect_error( - { p <- vis_gene(spe_temp, geneid = "sum_umi") }, + { + p <- vis_gene(spe_temp, geneid = "sum_umi") + }, "^Abnormal spatial coordinates" ) rm(spe_temp) From 08061cb779d45586404a58284b4dcfb25f975e12 Mon Sep 17 00:00:00 2001 From: lcolladotor Date: Tue, 2 Jul 2024 12:08:52 -0400 Subject: [PATCH 22/28] Add Visium_LS data prepared by Nick Eagles. Resolve #81 Co-authored-by: Nick Eagles --- R/fetch_data.R | 68 ++++++++++++++++++++++++++++++++--------------- man/fetch_data.Rd | 3 ++- 2 files changed, 49 insertions(+), 22 deletions(-) diff --git a/R/fetch_data.R b/R/fetch_data.R index cc715e4a..8f859e5b 100644 --- a/R/fetch_data.R +++ b/R/fetch_data.R @@ -84,27 +84,29 @@ #' #> 172.28 MB #' } fetch_data <- - function( - type = c( - "sce", - "sce_layer", - "modeling_results", - "sce_example", - "spe", - "spatialDLPFC_Visium", - "spatialDLPFC_Visium_example_subset", - "spatialDLPFC_Visium_pseudobulk", - "spatialDLPFC_Visium_modeling_results", - "spatialDLPFC_Visium_SPG", - "spatialDLPFC_snRNAseq", - "Visium_SPG_AD_Visium_wholegenome_spe", - "Visium_SPG_AD_Visium_targeted_spe", - "Visium_SPG_AD_Visium_wholegenome_pseudobulk_spe", - "Visium_SPG_AD_Visium_wholegenome_modeling_results" - ), - destdir = tempdir(), - eh = ExperimentHub::ExperimentHub(), - bfc = BiocFileCache::BiocFileCache()) { + function(type = c( + "sce", + "sce_layer", + "modeling_results", + "sce_example", + "spe", + "spatialDLPFC_Visium", + "spatialDLPFC_Visium_example_subset", + "spatialDLPFC_Visium_pseudobulk", + "spatialDLPFC_Visium_modeling_results", + "spatialDLPFC_Visium_SPG", + "spatialDLPFC_snRNAseq", + "Visium_SPG_AD_Visium_wholegenome_spe", + "Visium_SPG_AD_Visium_targeted_spe", + "Visium_SPG_AD_Visium_wholegenome_pseudobulk_spe", + "Visium_SPG_AD_Visium_wholegenome_modeling_results", + "Visium_LS_spe", + "Visium_LS_spaceranger", + "Visium_LS_ImageJ_out" + ), + destdir = tempdir(), + eh = ExperimentHub::ExperimentHub(), + bfc = BiocFileCache::BiocFileCache()) { ## Some variables sce <- sce_layer <- modeling_results <- sce_sub <- spe <- NULL @@ -259,6 +261,30 @@ fetch_data <- file_name <- "Visium_IF_AD_modeling_results.Rdata" url <- "https://www.dropbox.com/s/5plupu8bj5m0kfh/Visium_IF_AD_modeling_results.Rdata?dl=1" + } else if (type == "Visium_LS_spe") { + tag <- "VisiumLS_Visium_stitched_spatialLIBD" + hub_title <- type + + ## While EH is not set-up + file_name <- "Visium_LS_spe.rds" + url <- + "https://www.dropbox.com/scl/fi/9re464y6qaojx3r94nq5u/Visium_LS_spe.rds?rlkey=nq6a82u23xuu9hohr86oodwdi&dl=1" + } else if (type == "Visium_LS_spaceranger") { + tag <- "VisiumLS_Visium_stitched_spatialLIBD" + hub_title <- type + + ## While EH is not set-up + file_name <- "Visium_LS_spaceranger.zip" + url <- + "https://www.dropbox.com/scl/fi/5jdoaukvhq3v7lk19228y/Visium_LS_spaceranger.zip?rlkey=bdgjc6mgy1ierdad6h6v5g29c&dl=1" + } else if (type == "Visium_LS_ImageJ_out") { + tag <- "VisiumLS_Visium_stitched_spatialLIBD" + hub_title <- type + + ## While EH is not set-up + file_name <- "Visium_LS_imagej_out.zip" + url <- + "https://www.dropbox.com/scl/fi/bevo52e96f2kdwllf8dkk/Visium_LS_imagej_out.zip?rlkey=ptwal8f5zxakzejwd0oqw0lhj&dl=1" } file_path <- file.path(destdir, file_name) diff --git a/man/fetch_data.Rd b/man/fetch_data.Rd index b77f5aa9..ac411d47 100644 --- a/man/fetch_data.Rd +++ b/man/fetch_data.Rd @@ -11,7 +11,8 @@ fetch_data( "spatialDLPFC_Visium_SPG", "spatialDLPFC_snRNAseq", "Visium_SPG_AD_Visium_wholegenome_spe", "Visium_SPG_AD_Visium_targeted_spe", "Visium_SPG_AD_Visium_wholegenome_pseudobulk_spe", - "Visium_SPG_AD_Visium_wholegenome_modeling_results"), + "Visium_SPG_AD_Visium_wholegenome_modeling_results", "Visium_LS_spe", + "Visium_LS_spaceranger", "Visium_LS_ImageJ_out"), destdir = tempdir(), eh = ExperimentHub::ExperimentHub(), bfc = BiocFileCache::BiocFileCache() From 35aa1193022cd2e30b464f4c956f2b15fec32f13 Mon Sep 17 00:00:00 2001 From: lcolladotor Date: Tue, 2 Jul 2024 13:01:18 -0400 Subject: [PATCH 23/28] Edit run_app() and app_server() to make them compatible with visiumStitched SPE objects Co-authored-by: Nick Eagles --- R/app_server.R | 33 ++++++++++++++++++++++++--------- R/run_app.R | 41 +++++++++++++++++++++++++++++++++++++++++ R/vis_grid_clus.R | 2 ++ R/vis_grid_gene.R | 2 ++ 4 files changed, 69 insertions(+), 9 deletions(-) diff --git a/R/app_server.R b/R/app_server.R index af18dbb7..ca416d98 100644 --- a/R/app_server.R +++ b/R/app_server.R @@ -25,6 +25,7 @@ app_server <- function(input, output, session) { modeling_results <- golem::get_golem_options("modeling_results") sig_genes <- golem::get_golem_options("sig_genes") default_cluster <- golem::get_golem_options("default_cluster") + is_stitched <- golem::get_golem_options("is_stitched") # List the first level callModules here @@ -171,6 +172,7 @@ app_server <- function(input, output, session) { alpha = input$alphalevel, point_size = input$pointsize, auto_crop = input$auto_crop, + is_stitched = is_stitched, ... = paste(" with", input$cluster) ) if (!input$side_by_side_histology) { @@ -211,6 +213,7 @@ app_server <- function(input, output, session) { sample_order = isolate(input$grid_samples), point_size = isolate(input$pointsize), auto_crop = isolate(input$auto_crop), + is_stitched = is_stitched, ... = paste(" with", isolate(input$cluster)) ) cowplot::plot_grid( @@ -232,7 +235,8 @@ app_server <- function(input, output, session) { image_id = input$imageid, alpha = input$alphalevel, point_size = input$pointsize, - auto_crop = input$auto_crop + auto_crop = input$auto_crop, + is_stitched = is_stitched ) if (!input$side_by_side_gene) { return(p) @@ -270,7 +274,8 @@ app_server <- function(input, output, session) { alpha = isolate(input$alphalevel), point_size = isolate(input$pointsize), sample_order = isolate(input$gene_grid_samples), - auto_crop = isolate(input$auto_crop) + auto_crop = isolate(input$auto_crop), + is_stitched = is_stitched ) cowplot::plot_grid( plotlist = plots, @@ -608,8 +613,17 @@ app_server <- function(input, output, session) { ## From vis_gene() in global.R spe_sub <- spe[, spe$sample_id == sampleid] + + point_size <- input$pointsize + if (is_stitched) { + # Drop excluded spots and calculate an appropriate point size + temp <- prep_stitched_data(spe_sub, point_size, input$imageid) + spe_sub <- temp$spe + point_size <- temp$point_size + } + d <- - as.data.frame(cbind(colData(spe), SpatialExperiment::spatialCoords(spe))[spe$sample_id == sampleid, ], + as.data.frame(cbind(colData(spe_sub), SpatialExperiment::spatialCoords(spe_sub)), optional = TRUE ) # Grab any continuous colData columns @@ -692,7 +706,7 @@ app_server <- function(input, output, session) { title = plot_title, image_id = input$imageid, alpha = input$alphalevel, - point_size = input$pointsize, + point_size = point_size, auto_crop = input$auto_crop ) @@ -706,11 +720,11 @@ app_server <- function(input, output, session) { cont_colors = cont_colors(), image_id = input$imageid, alpha = input$alphalevel, - point_size = input$pointsize, + point_size = point_size, auto_crop = input$auto_crop ) + geom_point( shape = 21, - size = input$pointsize, + size = point_size, stroke = 0, alpha = input$alphalevel ) @@ -728,7 +742,7 @@ app_server <- function(input, output, session) { ) + geom_point( shape = 21, - size = input$pointsize, + size = point_size, stroke = 0 ) + scale_fill_manual(values = get_colors(colors, colData(spe)[[clustervar]][spe$sample_id == sampleid])) + @@ -756,7 +770,7 @@ app_server <- function(input, output, session) { ) + geom_point( shape = 21, - size = input$pointsize, + size = point_size, stroke = 0 ) } else { @@ -951,7 +965,8 @@ app_server <- function(input, output, session) { image_id = input$imageid, alpha = input$alphalevel, point_size = input$pointsize, - auto_crop = input$auto_crop + auto_crop = input$auto_crop, + is_stitched = is_stitched ) + geom_point( shape = 21, diff --git a/R/run_app.R b/R/run_app.R index b7beae48..8e7dfaf0 100644 --- a/R/run_app.R +++ b/R/run_app.R @@ -40,6 +40,7 @@ #' automatically cropping the images. Set this to `FALSE` if your images do not #' follow the Visium grid size expectations, which are key for enabling #' auto-cropping. +#' @inheritParams vis_clus #' @param ... Other arguments passed to the list of golem options for running #' the application. #' @@ -185,6 +186,43 @@ #' ## * https://github.com/LieberInstitute/spatialDLPFC/tree/main/code/deploy_app_k09_position_noWM #' ## * https://github.com/LieberInstitute/spatialDLPFC/tree/main/code/deploy_app_k16 #' ## * https://github.com/LieberInstitute/spatialDLPFC/tree/main/code/analysis_IF/03_spatialLIBD_app +#' +#' +#' ## Example for an object with multiple capture areas stitched together with +#' ## . +#' spe_stitched <- fetch_data("Visium_LS_spe") +#' +#' ## Inspect this object +#' spe_stitched +#' +#' ## Notice the use of "exclude_overlapping" +#' table(spe_stitched$exclude_overlapping, useNA = "ifany") +#' +#' ## Drop NAs +#' spe_stitched <- spe_stitched[, !is.na(spe_stitched$exclude_overlapping)] +#' +#' ## Make it compatible with spatialLIBD::run_app() +#' spe_stitched <- add_key(spe_stitched) +#' spe_stitched$sum_umi <- colSums(logcounts(spe_stitched)) +#' spe_stitched$sum_gene <- colSums(logcounts(spe_stitched) > 0) +#' rowData(spe_stitched)$gene_name <- rowData(spe_stitched)$symbol +#' rowData(spe_stitched)$gene_id <- rownames(spe_stitched) +#' rowData(spe_stitched)$gene_search <- paste0(rowData(spe_stitched)$gene_name, "; ", rowData(spe_stitched)$gene_id) +#' is_mito <- seq_len(1000) +#' spe_stitched$expr_chrM <- colSums(logcounts(spe_stitched)[is_mito, , drop = FALSE]) +#' spe_stitched$expr_chrM_ratio <- spe_stitched$expr_chrM / spe_stitched$sum_umi +#' ## Add a variable for saving the manual annotations +#' spe_stitched$ManualAnnotation <- "NA" +#' +#' ## Run the app with this stitched data +#' run_app(spe = spe_stitched, +#' sce_layer = NULL, modeling_results = NULL, sig_genes = NULL, +#' title = "visiumStitched example data", +#' spe_discrete_vars = c("capture_area", "scran_quick_cluster", "ManualAnnotation"), +#' spe_continuous_vars = c("sum_umi", "sum_gene", "expr_chrM", "expr_chrM_ratio"), +#' default_cluster = "scran_quick_cluster", +#' is_stitched = TRUE +#' ) #' } run_app <- function(spe = fetch_data(type = "spe"), sce_layer = fetch_data(type = "sce_layer"), @@ -233,10 +271,12 @@ run_app <- function(spe = fetch_data(type = "spe"), ), default_cluster = "spatialLIBD", auto_crop_default = TRUE, + is_stitched = FALSE, ...) { ## Run the checks in the relevant order stopifnot(length(default_cluster) == 1) stopifnot(default_cluster %in% spe_discrete_vars) + if (is_stitched) auto_crop_default <- FALSE spe <- check_spe(spe, @@ -281,6 +321,7 @@ run_app <- function(spe = fetch_data(type = "spe"), spe_continuous_vars = spe_continuous_vars, default_cluster = default_cluster, auto_crop_default = auto_crop_default, + is_stitched = is_stitched, ... ) ) diff --git a/R/vis_grid_clus.R b/R/vis_grid_clus.R index 6c61cece..b3c5086a 100644 --- a/R/vis_grid_clus.R +++ b/R/vis_grid_clus.R @@ -62,6 +62,7 @@ vis_grid_clus <- point_size = 2, auto_crop = TRUE, na_color = "#CCCCCC40", + is_stitched = FALSE, ...) { stopifnot(all(sample_order %in% unique(spe$sample_id))) @@ -81,6 +82,7 @@ vis_grid_clus <- point_size = point_size, auto_crop = auto_crop, na_color = na_color, + is_stitched = is_stitched, ... ) }) diff --git a/R/vis_grid_gene.R b/R/vis_grid_gene.R index e21b5bf1..8ddddbfb 100644 --- a/R/vis_grid_gene.R +++ b/R/vis_grid_gene.R @@ -52,6 +52,7 @@ vis_grid_gene <- point_size = 2, auto_crop = TRUE, na_color = "#CCCCCC40", + is_stitched = FALSE, ...) { stopifnot(all(sample_order %in% unique(spe$sample_id))) @@ -70,6 +71,7 @@ vis_grid_gene <- point_size = point_size, auto_crop = auto_crop, na_color = na_color, + is_stitched = is_stitched, ... ) }) From 8c25a4ca9dfe2eae84dcc0644dd95685d003ba7e Mon Sep 17 00:00:00 2001 From: lcolladotor Date: Tue, 2 Jul 2024 13:04:18 -0400 Subject: [PATCH 24/28] Update News file announcing the recent updates related to visiumStitched Co-authored-by: Nick Eagles --- NEWS.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/NEWS.md b/NEWS.md index 2da9df7f..eac9b512 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,12 @@ +# spatialLIBD 1.17.3 + +NEW FEATURES + +* Added support for `SpatialExperiment` objects created with +`visiumStitched::build_spe()` + that +stitch together multiple Visium capture areas. Developed by @Nick-Eagles. + # spatialLIBD 1.15.2 SIGNIFICANT USER-VISIBLE CHANGES From d6b6809ba58e3103bdb340eb8de24227d6892f82 Mon Sep 17 00:00:00 2001 From: lcolladotor Date: Tue, 2 Jul 2024 13:04:51 -0400 Subject: [PATCH 25/28] Auto-style + re-render docs --- R/fetch_data.R | 47 ++++++++++---------- R/run_app.R | 102 ++++++++++++++++++++++--------------------- R/vis_grid_clus.R | 35 +++++++-------- R/vis_grid_gene.R | 39 +++++++++-------- man/run_app.Rd | 46 +++++++++++++++++++ man/vis_grid_clus.Rd | 8 ++++ man/vis_grid_gene.Rd | 8 ++++ 7 files changed, 176 insertions(+), 109 deletions(-) diff --git a/R/fetch_data.R b/R/fetch_data.R index 8f859e5b..94b4bea8 100644 --- a/R/fetch_data.R +++ b/R/fetch_data.R @@ -84,29 +84,30 @@ #' #> 172.28 MB #' } fetch_data <- - function(type = c( - "sce", - "sce_layer", - "modeling_results", - "sce_example", - "spe", - "spatialDLPFC_Visium", - "spatialDLPFC_Visium_example_subset", - "spatialDLPFC_Visium_pseudobulk", - "spatialDLPFC_Visium_modeling_results", - "spatialDLPFC_Visium_SPG", - "spatialDLPFC_snRNAseq", - "Visium_SPG_AD_Visium_wholegenome_spe", - "Visium_SPG_AD_Visium_targeted_spe", - "Visium_SPG_AD_Visium_wholegenome_pseudobulk_spe", - "Visium_SPG_AD_Visium_wholegenome_modeling_results", - "Visium_LS_spe", - "Visium_LS_spaceranger", - "Visium_LS_ImageJ_out" - ), - destdir = tempdir(), - eh = ExperimentHub::ExperimentHub(), - bfc = BiocFileCache::BiocFileCache()) { + function( + type = c( + "sce", + "sce_layer", + "modeling_results", + "sce_example", + "spe", + "spatialDLPFC_Visium", + "spatialDLPFC_Visium_example_subset", + "spatialDLPFC_Visium_pseudobulk", + "spatialDLPFC_Visium_modeling_results", + "spatialDLPFC_Visium_SPG", + "spatialDLPFC_snRNAseq", + "Visium_SPG_AD_Visium_wholegenome_spe", + "Visium_SPG_AD_Visium_targeted_spe", + "Visium_SPG_AD_Visium_wholegenome_pseudobulk_spe", + "Visium_SPG_AD_Visium_wholegenome_modeling_results", + "Visium_LS_spe", + "Visium_LS_spaceranger", + "Visium_LS_ImageJ_out" + ), + destdir = tempdir(), + eh = ExperimentHub::ExperimentHub(), + bfc = BiocFileCache::BiocFileCache()) { ## Some variables sce <- sce_layer <- modeling_results <- sce_sub <- spe <- NULL diff --git a/R/run_app.R b/R/run_app.R index 8e7dfaf0..4352ce03 100644 --- a/R/run_app.R +++ b/R/run_app.R @@ -215,7 +215,8 @@ #' spe_stitched$ManualAnnotation <- "NA" #' #' ## Run the app with this stitched data -#' run_app(spe = spe_stitched, +#' run_app( +#' spe = spe_stitched, #' sce_layer = NULL, modeling_results = NULL, sig_genes = NULL, #' title = "visiumStitched example data", #' spe_discrete_vars = c("capture_area", "scran_quick_cluster", "ManualAnnotation"), @@ -224,55 +225,56 @@ #' is_stitched = TRUE #' ) #' } -run_app <- function(spe = fetch_data(type = "spe"), - sce_layer = fetch_data(type = "sce_layer"), - modeling_results = fetch_data(type = "modeling_results"), - sig_genes = sig_genes_extract_all( - n = nrow(sce_layer), - modeling_results = modeling_results, - sce_layer = sce_layer - ), - docs_path = system.file("app", "www", package = "spatialLIBD"), - title = "spatialLIBD", - spe_discrete_vars = c( - "spatialLIBD", - "GraphBased", - "ManualAnnotation", - "Maynard", - "Martinowich", - paste0("SNN_k50_k", 4:28), - "SpatialDE_PCA", - "SpatialDE_pool_PCA", - "HVG_PCA", - "pseudobulk_PCA", - "markers_PCA", - "SpatialDE_UMAP", - "SpatialDE_pool_UMAP", - "HVG_UMAP", - "pseudobulk_UMAP", - "markers_UMAP", - "SpatialDE_PCA_spatial", - "SpatialDE_pool_PCA_spatial", - "HVG_PCA_spatial", - "pseudobulk_PCA_spatial", - "markers_PCA_spatial", - "SpatialDE_UMAP_spatial", - "SpatialDE_pool_UMAP_spatial", - "HVG_UMAP_spatial", - "pseudobulk_UMAP_spatial", - "markers_UMAP_spatial" - ), - spe_continuous_vars = c( - "cell_count", - "sum_umi", - "sum_gene", - "expr_chrM", - "expr_chrM_ratio" - ), - default_cluster = "spatialLIBD", - auto_crop_default = TRUE, - is_stitched = FALSE, - ...) { +run_app <- function( + spe = fetch_data(type = "spe"), + sce_layer = fetch_data(type = "sce_layer"), + modeling_results = fetch_data(type = "modeling_results"), + sig_genes = sig_genes_extract_all( + n = nrow(sce_layer), + modeling_results = modeling_results, + sce_layer = sce_layer + ), + docs_path = system.file("app", "www", package = "spatialLIBD"), + title = "spatialLIBD", + spe_discrete_vars = c( + "spatialLIBD", + "GraphBased", + "ManualAnnotation", + "Maynard", + "Martinowich", + paste0("SNN_k50_k", 4:28), + "SpatialDE_PCA", + "SpatialDE_pool_PCA", + "HVG_PCA", + "pseudobulk_PCA", + "markers_PCA", + "SpatialDE_UMAP", + "SpatialDE_pool_UMAP", + "HVG_UMAP", + "pseudobulk_UMAP", + "markers_UMAP", + "SpatialDE_PCA_spatial", + "SpatialDE_pool_PCA_spatial", + "HVG_PCA_spatial", + "pseudobulk_PCA_spatial", + "markers_PCA_spatial", + "SpatialDE_UMAP_spatial", + "SpatialDE_pool_UMAP_spatial", + "HVG_UMAP_spatial", + "pseudobulk_UMAP_spatial", + "markers_UMAP_spatial" + ), + spe_continuous_vars = c( + "cell_count", + "sum_umi", + "sum_gene", + "expr_chrM", + "expr_chrM_ratio" + ), + default_cluster = "spatialLIBD", + auto_crop_default = TRUE, + is_stitched = FALSE, + ...) { ## Run the checks in the relevant order stopifnot(length(default_cluster) == 1) stopifnot(default_cluster %in% spe_discrete_vars) diff --git a/R/vis_grid_clus.R b/R/vis_grid_clus.R index b3c5086a..c84dbac4 100644 --- a/R/vis_grid_clus.R +++ b/R/vis_grid_clus.R @@ -47,23 +47,24 @@ #' cowplot::plot_grid(plotlist = p_list, ncol = 2) #' } vis_grid_clus <- - function(spe, - clustervar, - pdf_file, - sort_clust = TRUE, - colors = NULL, - return_plots = FALSE, - spatial = TRUE, - height = 24, - width = 36, - image_id = "lowres", - alpha = NA, - sample_order = unique(spe$sample_id), - point_size = 2, - auto_crop = TRUE, - na_color = "#CCCCCC40", - is_stitched = FALSE, - ...) { + function( + spe, + clustervar, + pdf_file, + sort_clust = TRUE, + colors = NULL, + return_plots = FALSE, + spatial = TRUE, + height = 24, + width = 36, + image_id = "lowres", + alpha = NA, + sample_order = unique(spe$sample_id), + point_size = 2, + auto_crop = TRUE, + na_color = "#CCCCCC40", + is_stitched = FALSE, + ...) { stopifnot(all(sample_order %in% unique(spe$sample_id))) if (sort_clust) { diff --git a/R/vis_grid_gene.R b/R/vis_grid_gene.R index 8ddddbfb..bf32dd7a 100644 --- a/R/vis_grid_gene.R +++ b/R/vis_grid_gene.R @@ -35,25 +35,26 @@ #' cowplot::plot_grid(plotlist = p_list, ncol = 2) #' } vis_grid_gene <- - function(spe, - geneid = rowData(spe)$gene_search[1], - pdf_file, - assayname = "logcounts", - minCount = 0, - return_plots = FALSE, - spatial = TRUE, - viridis = TRUE, - height = 24, - width = 36, - image_id = "lowres", - alpha = NA, - cont_colors = if (viridis) viridisLite::viridis(21) else c("aquamarine4", "springgreen", "goldenrod", "red"), - sample_order = unique(spe$sample_id), - point_size = 2, - auto_crop = TRUE, - na_color = "#CCCCCC40", - is_stitched = FALSE, - ...) { + function( + spe, + geneid = rowData(spe)$gene_search[1], + pdf_file, + assayname = "logcounts", + minCount = 0, + return_plots = FALSE, + spatial = TRUE, + viridis = TRUE, + height = 24, + width = 36, + image_id = "lowres", + alpha = NA, + cont_colors = if (viridis) viridisLite::viridis(21) else c("aquamarine4", "springgreen", "goldenrod", "red"), + sample_order = unique(spe$sample_id), + point_size = 2, + auto_crop = TRUE, + na_color = "#CCCCCC40", + is_stitched = FALSE, + ...) { stopifnot(all(sample_order %in% unique(spe$sample_id))) plots <- lapply(sample_order, function(sampleid) { diff --git a/man/run_app.Rd b/man/run_app.Rd index 5b1d6c6a..5c8f19f0 100644 --- a/man/run_app.Rd +++ b/man/run_app.Rd @@ -24,6 +24,7 @@ run_app( "expr_chrM_ratio"), default_cluster = "spatialLIBD", auto_crop_default = TRUE, + is_stitched = FALSE, ... ) } @@ -75,6 +76,13 @@ automatically cropping the images. Set this to \code{FALSE} if your images do no follow the Visium grid size expectations, which are key for enabling auto-cropping.} +\item{is_stitched}{A \code{logical(1)} vector: If \code{TRUE}, expects a +\link[SpatialExperiment:SpatialExperiment]{SpatialExperiment-class} built +with \code{visiumStitched::build_spe()}. +\url{http://research.libd.org/visiumStitched/reference/build_spe.html}; in +particular, expects a logical colData column \code{exclude_overlapping} +specifying which spots to exclude from the plot. Sets \code{auto_crop = FALSE}.} + \item{...}{Other arguments passed to the list of golem options for running the application.} } @@ -233,5 +241,43 @@ if (enough_ram(9e9)) { ## * https://github.com/LieberInstitute/spatialDLPFC/tree/main/code/deploy_app_k09_position_noWM ## * https://github.com/LieberInstitute/spatialDLPFC/tree/main/code/deploy_app_k16 ## * https://github.com/LieberInstitute/spatialDLPFC/tree/main/code/analysis_IF/03_spatialLIBD_app + + +## Example for an object with multiple capture areas stitched together with +## . +spe_stitched <- fetch_data("Visium_LS_spe") + +## Inspect this object +spe_stitched + +## Notice the use of "exclude_overlapping" +table(spe_stitched$exclude_overlapping, useNA = "ifany") + +## Drop NAs +spe_stitched <- spe_stitched[, !is.na(spe_stitched$exclude_overlapping)] + +## Make it compatible with spatialLIBD::run_app() +spe_stitched <- add_key(spe_stitched) +spe_stitched$sum_umi <- colSums(logcounts(spe_stitched)) +spe_stitched$sum_gene <- colSums(logcounts(spe_stitched) > 0) +rowData(spe_stitched)$gene_name <- rowData(spe_stitched)$symbol +rowData(spe_stitched)$gene_id <- rownames(spe_stitched) +rowData(spe_stitched)$gene_search <- paste0(rowData(spe_stitched)$gene_name, "; ", rowData(spe_stitched)$gene_id) +is_mito <- seq_len(1000) +spe_stitched$expr_chrM <- colSums(logcounts(spe_stitched)[is_mito, , drop = FALSE]) +spe_stitched$expr_chrM_ratio <- spe_stitched$expr_chrM / spe_stitched$sum_umi +## Add a variable for saving the manual annotations +spe_stitched$ManualAnnotation <- "NA" + +## Run the app with this stitched data +run_app( + spe = spe_stitched, + sce_layer = NULL, modeling_results = NULL, sig_genes = NULL, + title = "visiumStitched example data", + spe_discrete_vars = c("capture_area", "scran_quick_cluster", "ManualAnnotation"), + spe_continuous_vars = c("sum_umi", "sum_gene", "expr_chrM", "expr_chrM_ratio"), + default_cluster = "scran_quick_cluster", + is_stitched = TRUE +) } } diff --git a/man/vis_grid_clus.Rd b/man/vis_grid_clus.Rd index c9410866..19dd2c3a 100644 --- a/man/vis_grid_clus.Rd +++ b/man/vis_grid_clus.Rd @@ -20,6 +20,7 @@ vis_grid_clus( point_size = 2, auto_crop = TRUE, na_color = "#CCCCCC40", + is_stitched = FALSE, ... ) } @@ -76,6 +77,13 @@ alpha blending already, which will make non-NA values pop up more and the NA values will show with a lighter color. This behavior is lost when \code{alpha} is set to a non-\code{NA} value.} +\item{is_stitched}{A \code{logical(1)} vector: If \code{TRUE}, expects a +\link[SpatialExperiment:SpatialExperiment]{SpatialExperiment-class} built +with \code{visiumStitched::build_spe()}. +\url{http://research.libd.org/visiumStitched/reference/build_spe.html}; in +particular, expects a logical colData column \code{exclude_overlapping} +specifying which spots to exclude from the plot. Sets \code{auto_crop = FALSE}.} + \item{...}{Passed to \link[base:paste]{paste0()} for making the title of the plot following the \code{sampleid}.} } diff --git a/man/vis_grid_gene.Rd b/man/vis_grid_gene.Rd index 0ed8c520..a102cbbe 100644 --- a/man/vis_grid_gene.Rd +++ b/man/vis_grid_gene.Rd @@ -23,6 +23,7 @@ vis_grid_gene( point_size = 2, auto_crop = TRUE, na_color = "#CCCCCC40", + is_stitched = FALSE, ... ) } @@ -93,6 +94,13 @@ alpha blending already, which will make non-NA values pop up more and the NA values will show with a lighter color. This behavior is lost when \code{alpha} is set to a non-\code{NA} value.} +\item{is_stitched}{A \code{logical(1)} vector: If \code{TRUE}, expects a +\link[SpatialExperiment:SpatialExperiment]{SpatialExperiment-class} built +with \code{visiumStitched::build_spe()}. +\url{http://research.libd.org/visiumStitched/reference/build_spe.html}; in +particular, expects a logical colData column \code{exclude_overlapping} +specifying which spots to exclude from the plot. Sets \code{auto_crop = FALSE}.} + \item{...}{Passed to \link[base:paste]{paste0()} for making the title of the plot following the \code{sampleid}.} } From a40956fc489a7e5afb4fc7eda0de81e36773d367 Mon Sep 17 00:00:00 2001 From: lcolladotor Date: Tue, 2 Jul 2024 13:07:05 -0400 Subject: [PATCH 26/28] v1.17.3 -- add initial support for visiumStitched::build_spe() objects. TODO: * Re-make example data with read10xVisiumWrapper() * Add post-stitched reduced dims + spatial clusters * Clean up example code at run_app() * Change default cluster to the spatial clusters, instead of the scran_quick_clusters. Co-authored-by: Nick Eagles --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index a0ebcbcf..c8db0a99 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: spatialLIBD Title: spatialLIBD: an R/Bioconductor package to visualize spatially-resolved transcriptomics data -Version: 1.17.2 -Date: 2024-05-24 +Version: 1.17.3 +Date: 2024-07-02 Authors@R: c( person("Leonardo", "Collado-Torres", role = c("aut", "cre"), From 3b78be48940b3a58791d2c07684a331607b25d3f Mon Sep 17 00:00:00 2001 From: lcolladotor Date: Wed, 3 Jul 2024 16:45:45 -0400 Subject: [PATCH 27/28] Update docs after having updated the LS data on Dropbox. Aka, the stitched LS object is now compatible out of the box with spatialLIBD::run_app() --- DESCRIPTION | 2 +- R/run_app.R | 16 ---------------- man/run_app.Rd | 16 ---------------- 3 files changed, 1 insertion(+), 33 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index c8db0a99..55eed6e3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -79,7 +79,7 @@ Imports: statmod, MatrixGenerics, rlang -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Roxygen: list(markdown = TRUE) URL: https://github.com/LieberInstitute/spatialLIBD BugReports: https://support.bioconductor.org/tag/spatialLIBD diff --git a/R/run_app.R b/R/run_app.R index 4352ce03..851045a3 100644 --- a/R/run_app.R +++ b/R/run_app.R @@ -198,22 +198,6 @@ #' ## Notice the use of "exclude_overlapping" #' table(spe_stitched$exclude_overlapping, useNA = "ifany") #' -#' ## Drop NAs -#' spe_stitched <- spe_stitched[, !is.na(spe_stitched$exclude_overlapping)] -#' -#' ## Make it compatible with spatialLIBD::run_app() -#' spe_stitched <- add_key(spe_stitched) -#' spe_stitched$sum_umi <- colSums(logcounts(spe_stitched)) -#' spe_stitched$sum_gene <- colSums(logcounts(spe_stitched) > 0) -#' rowData(spe_stitched)$gene_name <- rowData(spe_stitched)$symbol -#' rowData(spe_stitched)$gene_id <- rownames(spe_stitched) -#' rowData(spe_stitched)$gene_search <- paste0(rowData(spe_stitched)$gene_name, "; ", rowData(spe_stitched)$gene_id) -#' is_mito <- seq_len(1000) -#' spe_stitched$expr_chrM <- colSums(logcounts(spe_stitched)[is_mito, , drop = FALSE]) -#' spe_stitched$expr_chrM_ratio <- spe_stitched$expr_chrM / spe_stitched$sum_umi -#' ## Add a variable for saving the manual annotations -#' spe_stitched$ManualAnnotation <- "NA" -#' #' ## Run the app with this stitched data #' run_app( #' spe = spe_stitched, diff --git a/man/run_app.Rd b/man/run_app.Rd index 5c8f19f0..0eb0295d 100644 --- a/man/run_app.Rd +++ b/man/run_app.Rd @@ -253,22 +253,6 @@ spe_stitched ## Notice the use of "exclude_overlapping" table(spe_stitched$exclude_overlapping, useNA = "ifany") -## Drop NAs -spe_stitched <- spe_stitched[, !is.na(spe_stitched$exclude_overlapping)] - -## Make it compatible with spatialLIBD::run_app() -spe_stitched <- add_key(spe_stitched) -spe_stitched$sum_umi <- colSums(logcounts(spe_stitched)) -spe_stitched$sum_gene <- colSums(logcounts(spe_stitched) > 0) -rowData(spe_stitched)$gene_name <- rowData(spe_stitched)$symbol -rowData(spe_stitched)$gene_id <- rownames(spe_stitched) -rowData(spe_stitched)$gene_search <- paste0(rowData(spe_stitched)$gene_name, "; ", rowData(spe_stitched)$gene_id) -is_mito <- seq_len(1000) -spe_stitched$expr_chrM <- colSums(logcounts(spe_stitched)[is_mito, , drop = FALSE]) -spe_stitched$expr_chrM_ratio <- spe_stitched$expr_chrM / spe_stitched$sum_umi -## Add a variable for saving the manual annotations -spe_stitched$ManualAnnotation <- "NA" - ## Run the app with this stitched data run_app( spe = spe_stitched, From 30a8b3a02ec90b95746b2ee4734377d9bec5c159 Mon Sep 17 00:00:00 2001 From: lcolladotor Date: Wed, 3 Jul 2024 16:46:22 -0400 Subject: [PATCH 28/28] v1.17.4 -- bump version now that LS stitched data is compatible with run_app() --- DESCRIPTION | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 55eed6e3..f372bd07 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: spatialLIBD Title: spatialLIBD: an R/Bioconductor package to visualize spatially-resolved transcriptomics data -Version: 1.17.3 -Date: 2024-07-02 +Version: 1.17.4 +Date: 2024-07-03 Authors@R: c( person("Leonardo", "Collado-Torres", role = c("aut", "cre"),