if ( ! exists ( "spe" ) ) {
spe <- spatialLIBD :: fetch_data ( type = "visiumStitched_brain_spe" )
}
-#> 2024-10-18 14:28:52.408461 loading file /github/home/.cache/R/BiocFileCache/25739445980_visiumStitched_brain_spe.rds%3Frlkey%3Dnq6a82u23xuu9hohr86oodwdi%26dl%3D1
+#> 2024-10-24 20:16:27.531784 loading file /github/home/.cache/R/BiocFileCache/760d7e2c6_visiumStitched_brain_spe.rds%3Frlkey%3Dnq6a82u23xuu9hohr86oodwdi%26dl%3D1
# Group colData by group and array coordinates
grouped_coldata = colData ( spe ) |>
diff --git a/reference/prep_fiji.html b/reference/prep_fiji.html
index e18aef4..fa74bb9 100644
--- a/reference/prep_fiji.html
+++ b/reference/prep_fiji.html
@@ -123,38 +123,33 @@ Author <
Examples
-
On this page
diff --git a/search.json b/search.json
index 95e8fe7..4922a00 100644
--- a/search.json
+++ b/search.json
@@ -1 +1 @@
-[{"path":"/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to visiumStitched","title":"Contributing to visiumStitched","text":"outlines propose change visiumStitched. detailed discussion contributing tidyverse packages, please see development contributing guide code review principles.","code":""},{"path":"/CONTRIBUTING.html","id":"fixing-typos","dir":"","previous_headings":"","what":"Fixing typos","title":"Contributing to visiumStitched","text":"can fix typos, spelling mistakes, grammatical errors documentation directly using GitHub web interface, long changes made source file. generally means ’ll need edit roxygen2 comments .R, .Rd file. can find .R file generates .Rd reading comment first line.","code":""},{"path":"/CONTRIBUTING.html","id":"bigger-changes","dir":"","previous_headings":"","what":"Bigger changes","title":"Contributing to visiumStitched","text":"want make bigger change, ’s good idea first file issue make sure someone team agrees ’s needed. ’ve found bug, please file issue illustrates bug minimal reprex (also help write unit test, needed). See guide create great issue advice.","code":""},{"path":"/CONTRIBUTING.html","id":"pull-request-process","dir":"","previous_headings":"Bigger changes","what":"Pull request process","title":"Contributing to visiumStitched","text":"Fork package clone onto computer. haven’t done , recommend using usethis::create_from_github(\"LieberInstitute/visiumStitched\", fork = TRUE). Install development dependencies devtools::install_dev_deps(), make sure package passes R CMD check running devtools::check(). R CMD check doesn’t pass cleanly, ’s good idea ask help continuing. Create Git branch pull request (PR). recommend using usethis::pr_init(\"brief-description--change\"). Make changes, commit git, create PR running usethis::pr_push(), following prompts browser. title PR briefly describe change. body PR contain Fixes #issue-number. user-facing changes, add bullet top NEWS.md (.e. just first header). Follow style described https://style.tidyverse.org/news.html.","code":""},{"path":"/CONTRIBUTING.html","id":"code-style","dir":"","previous_headings":"Bigger changes","what":"Code style","title":"Contributing to visiumStitched","text":"New code follow tidyverse style guide. can use styler package apply styles, please don’t restyle code nothing PR. use roxygen2, Markdown syntax, documentation. use testthat unit tests. Contributions test cases included easier accept.","code":""},{"path":"/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Contributing to visiumStitched","text":"Please note visiumStitched project released Contributor Code Conduct. contributing project agree abide terms.","code":""},{"path":"/SUPPORT.html","id":null,"dir":"","previous_headings":"","what":"Getting help with visiumStitched","title":"Getting help with visiumStitched","text":"Thank using visiumStitched! filing issue, things know make process smooth possible parties.","code":""},{"path":"/SUPPORT.html","id":"make-a-reprex","dir":"","previous_headings":"","what":"Make a reprex","title":"Getting help with visiumStitched","text":"Start making minimally reproducible example, also known ‘reprex’. may use reprex R package create one, though necessary help. make R-question-asking endeavors easier. Learning use takes 5 10 minutes. tips make minimally reproducible example, see StackOverflow link.","code":""},{"path":"/SUPPORT.html","id":"where-to-post-it","dir":"","previous_headings":"","what":"Where to post it?","title":"Getting help with visiumStitched","text":"Bioconductor help web page gives overview places may help answer question. Bioconductor software related questions, bug reports feature requests, addressed appropriate Bioconductor/visiumStitched GitHub repository. Follow bug report feature request templates GitHub. package GitHub repository, see next bullet point. Bioconductor software usage questions addressed Bioconductor Support Website. Make sure use appropriate package tag, otherwise package authors get notification. General R questions can posed StackOverflow RStudio Community website especially pertain tidyverse RStudio GUI related products.","code":""},{"path":"/SUPPORT.html","id":"issues-or-feature-requests","dir":"","previous_headings":"","what":"Issues or Feature Requests","title":"Getting help with visiumStitched","text":"opening new issue feature request, sure search issues pull requests ensure one already exist implemented development version. Note. can remove :open search term issues page search open closed issues. See link learn modifying search.","code":""},{"path":"/SUPPORT.html","id":"what-happens-next","dir":"","previous_headings":"","what":"What happens next?","title":"Getting help with visiumStitched","text":"Bioconductor maintainers limited resources strive responsive possible. Please forget tag appropriate maintainer issue GitHub username (e.g., @username). order make easy possible Bioconductor core developers remediate issue. Provide accurate, brief, reproducible report outlined issue templates. Thank trusting Bioconductor.","code":""},{"path":"/articles/misc.html","id":"load-data","dir":"Articles","previous_headings":"","what":"Load data","title":"Miscellaneous notes","text":"Let’s load spatialLIBD package ’ll use vignette. Now can download example visiumStitched_brain data includes normalized logcounts. ’ll define example white matter marker genes.","code":"library(\"spatialLIBD\") ## Grab SpatialExperiment with normalized counts spe <- fetch_data(type = \"visiumStitched_brain_spe\") #> 2024-10-18 14:29:29.554226 loading file /github/home/.cache/R/BiocFileCache/25739445980_visiumStitched_brain_spe.rds%3Frlkey%3Dnq6a82u23xuu9hohr86oodwdi%26dl%3D1 ## Check that spe does contain the \"logcounts\" assay assayNames(spe) #> [1] \"counts\" \"logcounts\" ## Define white matter marker genes wm_genes <- rownames(spe)[ match(c(\"MBP\", \"GFAP\", \"PLP1\", \"AQP4\"), rowData(spe)$gene_name) ]"},{"path":"/articles/misc.html","id":"geometric-transformations-notes","dir":"Articles","previous_headings":"","what":"Geometric transformations notes","title":"Miscellaneous notes","text":"SpatialExperiment, stitched data constructed visiumStitched::build_SpatialExperiment() may need rotated mirrored group. can done using SpatialExperiment::rotateObject() SpatialExperiment::mirrorObject() functions. functions useful case image needs transformed reach preferred tissue orientation. might want re-make plots spatial = TRUE can see histology image gets rotated /mirrored. file size purposes vignette, use spatial = FALSE.","code":"## Rotate image and gene-expression data by 180 degrees, plotting a combination ## of white-matter genes vis_gene( rotateObject(spe, sample_id = \"Br2719\", degrees = 180), geneid = wm_genes, assayname = \"counts\", is_stitched = TRUE, spatial = FALSE ) ## Mirror image and gene-expression data across a vertical axis, plotting a ## combination of white-matter genes vis_gene( mirrorObject(spe, sample_id = \"Br2719\", axis = \"v\"), geneid = wm_genes, assayname = \"counts\", is_stitched = TRUE, spatial = FALSE )"},{"path":"/articles/misc.html","id":"a-note-on-normalization","dir":"Articles","previous_headings":"Geometric transformations notes","what":"A note on normalization","title":"Miscellaneous notes","text":"noted main vignette, library-size variation across spots can bias apparent spatial distribution genes raw counts used. effect often dramatic enough spatial trends easily seen across stitched data data log-normalized. Instead performing normalization , ’ll fetch object normalized counts spatialLIBD, plot white matter genes : Recall unnormalized version plot, nearly clean: actual normalization code example data available .","code":"## Plot combination of normalized counts for some white-matter genes vis_gene( spe, geneid = wm_genes, assayname = \"logcounts\", is_stitched = TRUE, spatial = FALSE ) ## Plot raw counts, which are noisier ## Same plot we made before, but this time with no histology images vis_gene( spe, geneid = wm_genes, assayname = \"counts\", is_stitched = TRUE, spatial = FALSE )"},{"path":"/articles/misc.html","id":"merging-overlapping-spots","dir":"Articles","previous_headings":"","what":"Merging overlapping spots","title":"Miscellaneous notes","text":"general, recommend retaining spots downstream analysis, even means including multiple spots per array coordinate. show many software tools, BayesSpace PRECAST, can smoothly handle data format. However, given multiple spots array coordinates atypical Visium experiments, caution ’s possible software may break perform intended stitched data. provide merge_overlapping() function address case. particular, merge_overlapping() sums raw counts across spots overlap, ultimately producing SpatialExperiment one spot per array coordinate. colData() information, discrete continuous, taken spots exclude_overlapping FALSE. Note function can quite memory-intensive time-consuming.","code":"spe_merged = merge_overlapping(spe)"},{"path":[]},{"path":"/articles/visiumStitched.html","id":"install-visiumstitched","dir":"Articles","previous_headings":"Basics","what":"Install visiumStitched","title":"Introduction to visiumStitched","text":"visiumStitched Bioconductor R package can installed following commands R session:","code":"if (!requireNamespace(\"BiocManager\", quietly = TRUE)) { install.packages(\"BiocManager\") } BiocManager::install(\"visiumStitched\")"},{"path":"/articles/visiumStitched.html","id":"citing-visiumstitched","dir":"Articles","previous_headings":"Basics","what":"Citing visiumStitched","title":"Introduction to visiumStitched","text":"hope visiumStitched useful research. Please use following information cite package overall approach. Thank !","code":"## Citation info citation(\"visiumStitched\") #> To cite package 'visiumStitched' in publications use: #> #> Eagles NJ, Collado-Torres L (2024). _Enable downstream analysis of #> Visium capture areas stitched together with Fiji_. #> doi:10.18129/B9.bioc.visiumStitched #> , #> https://github.com/LieberInstitute/visiumStitched/visiumStitched - R #> package version 0.99.12, #> . #> #> Eagles NJ, Bach S, Tippani M, Ravichandran P, Du Y, Miller RA, Hyde #> TM, Page SC, Martinowich K, Collado-Torres L (2024). #> \"visiumStitched.\" _bioRxiv_. doi:10.1101/TODO #> , #> . #> #> To see these entries in BibTeX format, use 'print(, #> bibtex=TRUE)', 'toBibtex(.)', or set #> 'options(citation.bibtex.max=999)'."},{"path":"/articles/visiumStitched.html","id":"packages-used-in-this-vignette","dir":"Articles","previous_headings":"Basics","what":"Packages used in this vignette","title":"Introduction to visiumStitched","text":"Let’s load packages ’ll use vignette.","code":"library(\"SpatialExperiment\") library(\"visiumStitched\") library(\"dplyr\") library(\"spatialLIBD\") library(\"BiocFileCache\") library(\"ggplot2\")"},{"path":"/articles/visiumStitched.html","id":"preparing-experiment-information","dir":"Articles","previous_headings":"","what":"Preparing Experiment Information","title":"Introduction to visiumStitched","text":"Much visiumStitched package uses tibble (data.frame) defining information experiment. fundamentally, group column allows line capture areas, capture_area column, stitched together later. case, just one unique group, consisting three capture areas. Note multiple groups supported. end demo, SpatialExperiment consist just one sample composed three capture areas; general, one sample per group. Next, ’ll need Spaceranger outputs capture area, can retrieved spatialLIBD::fetch_data().","code":"## Create initial sample_info sample_info <- data.frame( group = \"Br2719\", capture_area = c(\"V13B23-283_A1\", \"V13B23-283_C1\", \"V13B23-283_D1\") ) ## Initial sample_info sample_info #> group capture_area #> 1 Br2719 V13B23-283_A1 #> 2 Br2719 V13B23-283_C1 #> 3 Br2719 V13B23-283_D1 ## Download example SpaceRanger output files sr_dir <- tempdir() temp <- unzip(spatialLIBD::fetch_data(\"visiumStitched_brain_spaceranger\"), exdir = sr_dir ) #> 2024-10-18 14:29:56.102909 loading file /github/home/.cache/R/BiocFileCache/2573560f3ca_visiumStitched_brain_spaceranger.zip%3Frlkey%3Dbdgjc6mgy1ierdad6h6v5g29c%26dl%3D1 sample_info$spaceranger_dir <- file.path( sr_dir, sample_info$capture_area, \"outs\", \"spatial\" ) ## Sample_info with paths to SpaceRanger output directories sample_info #> group capture_area spaceranger_dir #> 1 Br2719 V13B23-283_A1 /tmp/RtmpUiBP6j/V13B23-283_A1/outs/spatial #> 2 Br2719 V13B23-283_C1 /tmp/RtmpUiBP6j/V13B23-283_C1/outs/spatial #> 3 Br2719 V13B23-283_D1 /tmp/RtmpUiBP6j/V13B23-283_D1/outs/spatial"},{"path":"/articles/visiumStitched.html","id":"preparing-inputs-to-fiji","dir":"Articles","previous_headings":"","what":"Preparing Inputs to Fiji","title":"Introduction to visiumStitched","text":"visiumStitched workflow makes use Fiji, distribution ImageJ image-processing software, includes interface aligning images shared coordinate system. aligning anything Fiji, need ensure images align capture areas scale– , pixel image represents distance. typically approximately true, guaranteed exactly true, especially capture areas align come different Visium slides. rescale_fiji_inputs() reads high-resolution tissue images capture area, uses info spot diameters pixels scale factors rescale images appropriately (even different Visium slides). demonstration purposes, ’ll set out_dir temporary location. Typically, really suitable directory place rescaled images later input Fiji.","code":"# Generate rescaled approximately high-resolution images sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir()) ## Sample_info with output directories sample_info #> # A tibble: 3 × 5 #> group capture_area spaceranger_dir intra_group_scalar group_hires_scalef #> #> 1 Br2719 V13B23-283_A1 /tmp/RtmpUiBP6j/V1… 1.00 0.0825 #> 2 Br2719 V13B23-283_C1 /tmp/RtmpUiBP6j/V1… 1.00 0.0825 #> 3 Br2719 V13B23-283_D1 /tmp/RtmpUiBP6j/V1… 1 0.0825"},{"path":[]},{"path":"/articles/visiumStitched.html","id":"stitching-images-with-fiji","dir":"Articles","previous_headings":"Building a SpatialExperiment","what":"Stitching Images with Fiji","title":"Introduction to visiumStitched","text":"building SpatialExperiment stitched dataset, must align images group Fiji. Check video guide process example data.","code":""},{"path":"/articles/visiumStitched.html","id":"creating-group-level-samples","dir":"Articles","previous_headings":"Building a SpatialExperiment","what":"Creating Group-Level Samples","title":"Introduction to visiumStitched","text":"Fiji alignment, two output files produced: XML file specifying rigid affine transformations capture area, stitched approximately high-resolution image. files dataset available spatialLIBD::fetch_data(). ’ll need add paths XML PNG files fiji_xml_path fiji_image_path columns sample_info, respectively. now every column present sample_info necessary visiumStitched function. building SpatialExperiment, idea create directory structure similar Spaceranger’s spatial outputs group, opposed capture-area-level directories already . ’ll place directory temporary location later read produce final SpatialExperiment. First, prep_fiji_coords() apply rigid affine transformations specified Fiji’s output XML file spatial coordinates, ultimately producing group-level tissue_positions.csv file. Next, prep_fiji_image() rescale stitched image default 1,200 pixels longest dimension. idea experiment multiple groups, images stored SpatialExperiment group similarly scaled occupy similar memory footprints.","code":"fiji_dir <- tempdir() temp <- unzip(fetch_data(\"visiumStitched_brain_Fiji_out\"), exdir = fiji_dir) #> 2024-10-18 14:30:09.710556 loading file /github/home/.cache/R/BiocFileCache/257305c881d_visiumStitched_brain_fiji_out.zip%3Frlkey%3Dptwal8f5zxakzejwd0oqw0lhj%26dl%3D1 sample_info$fiji_xml_path <- temp[grep(\"xml$\", temp)] sample_info$fiji_image_path <- temp[grep(\"png$\", temp)] ## Complete sample_info sample_info #> # A tibble: 3 × 7 #> group capture_area spaceranger_dir intra_group_scalar group_hires_scalef #> #> 1 Br2719 V13B23-283_A1 /tmp/RtmpUiBP6j/V1… 1.00 0.0825 #> 2 Br2719 V13B23-283_C1 /tmp/RtmpUiBP6j/V1… 1.00 0.0825 #> 3 Br2719 V13B23-283_D1 /tmp/RtmpUiBP6j/V1… 1 0.0825 #> # ℹ 2 more variables: fiji_xml_path , fiji_image_path ## Prepare the Fiji coordinates and images. ## These functions return the file paths to the newly-created files that follow ## the standard directory structure from SpaceRanger (10x Genomics) spe_input_dir <- tempdir() prep_fiji_coords(sample_info, out_dir = spe_input_dir) #> [1] \"/tmp/RtmpUiBP6j/Br2719/tissue_positions.csv\" prep_fiji_image(sample_info, out_dir = spe_input_dir) #> [1] \"/tmp/RtmpUiBP6j/Br2719/tissue_lowres_image.png\" #> [2] \"/tmp/RtmpUiBP6j/Br2719/scalefactors_json.json\""},{"path":"/articles/visiumStitched.html","id":"constructing-the-object","dir":"Articles","previous_headings":"Building a SpatialExperiment","what":"Constructing the Object","title":"Introduction to visiumStitched","text":"now pieces create SpatialExperiment object. constructing base object, information related spots may overlap capture areas group added. sum_umi metric default determine spots overlapping regions exclude plots. particular, regions overlap, spots capture areas higher average UMI (unique molecular identifier) counts plotted, spots shown using spatialLIBD::vis_clus(), spatialLIBD::vis_gene(), related visualization functions. ’ll also mirror image gene-expression data match orientation specified wet bench. info performing geometric transformations . colData(spe)$exclude_overlapping column controls spots drop visualization purposes. Note also overlap_key column added, gives comma-separated string spot keys overlapping given spot, empty string otherwise. spatial clustering, overlap_key information can useful check frequently overlapping spots assigned cluster.","code":"## Download the Gencode v32 GTF file which is the closest one to the one ## that was used with SpaceRanger. Note that SpaceRanger GTFs are available at ## https://cf.10xgenomics.com/supp/cell-exp/refdata-gex-GRCh38-2024-A.tar.gz ## but is too large for us to download here since it includes many other files ## we don't need right now. ## However, ideally you would adapt this code and use the actual GTF file you ## used when running SpaceRanger. bfc <- BiocFileCache::BiocFileCache() gtf_cache <- bfcrpath( bfc, paste0( \"ftp://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/\", \"release_32/gencode.v32.annotation.gtf.gz\" ) ) ## Now we can build the SpatialExperiment object. We'll later explore error ## metrics related to computing new array coordinates, and thus specify ## 'calc_error_metrics = TRUE'. spe <- build_SpatialExperiment( sample_info, coords_dir = spe_input_dir, reference_gtf = gtf_cache, calc_error_metrics = TRUE ) #> Building SpatialExperiment using capture area as sample ID #> 2024-10-18 14:30:12.935657 SpatialExperiment::read10xVisium: reading basic data from SpaceRanger #> 2024-10-18 14:30:20.043195 read10xVisiumAnalysis: reading analysis output from SpaceRanger #> 2024-10-18 14:30:20.517176 add10xVisiumAnalysis: adding analysis output from SpaceRanger #> 2024-10-18 14:30:20.913173 rtracklayer::import: reading the reference GTF file #> 2024-10-18 14:30:52.528338 adding gene information to the SPE object #> Warning: Gene IDs did not match. This typically happens when you are not using #> the same GTF file as the one that was used by SpaceRanger. For example, one #> file uses GENCODE IDs and the other one ENSEMBL IDs. read10xVisiumWrapper() #> will try to convert them to ENSEMBL IDs. #> Warning: Dropping 2226 out of 38606 genes for which we don't have information #> on the reference GTF file. This typically happens when you are not using the #> same GTF file as the one that was used by SpaceRanger. #> 2024-10-18 14:30:52.762759 adding information used by spatialLIBD #> Overwriting imgData(spe) with merged images (one per group) #> Adding array coordinates with error metrics and adding overlap info ## The images in this example data have to be mirrored across the horizontal axis. spe <- SpatialExperiment::mirrorObject(spe, axis = \"h\") ## Explore stitched spe object spe #> class: SpatialExperiment #> dim: 36380 14976 #> metadata(0): #> assays(1): counts #> rownames(36380): ENSG00000243485.5 ENSG00000237613.2 ... #> ENSG00000198695.2 ENSG00000198727.2 #> rowData names(6): source type ... gene_type gene_search #> colnames(14976): AAACAACGAATAGTTC-1_V13B23-283_A1 #> AAACAAGTATCTCCCA-1_V13B23-283_A1 ... TTGTTTGTATTACACG-1_V13B23-283_D1 #> TTGTTTGTGTAAATTC-1_V13B23-283_D1 #> colData names(33): sample_id in_tissue ... overlap_key #> exclude_overlapping #> reducedDimNames(0): #> mainExpName: NULL #> altExpNames(0): #> spatialCoords names(2) : pxl_col_in_fullres pxl_row_in_fullres #> imgData names(4): sample_id image_id data scaleFactor ## Examine spots to exclude for plotting table(spe$exclude_overlapping) #> #> FALSE TRUE #> 13426 1550"},{"path":[]},{"path":"/articles/visiumStitched.html","id":"stitched-plotting","dir":"Articles","previous_headings":"Examining the stitched data","what":"Stitched plotting","title":"Introduction to visiumStitched","text":"demonstrate ’ve stitched gene expression image data successfully, ’ll use spatialLIBD::vis_gene(is_stitched = TRUE) (version 1.17.8 newer) plot distribution white matter spatially. context human brain white matter spatial marker genes, check previous work subject. Note ’re plotting raw counts; prior normalization, library-size variation across spots can bias apparent distribution. Later, ’ll show normalization critical producing visually seamless transition overlapping capture areas.","code":"## Show combined raw expression of white-matter marker genes wm_genes <- rownames(spe)[ match(c(\"MBP\", \"GFAP\", \"PLP1\", \"AQP4\"), rowData(spe)$gene_name) ] vis_gene(spe, geneid = wm_genes, assayname = \"counts\", is_stitched = TRUE)"},{"path":"/articles/visiumStitched.html","id":"defining-array-coordinates","dir":"Articles","previous_headings":"Examining the stitched data","what":"Defining Array Coordinates","title":"Introduction to visiumStitched","text":"Given stitched data larger default Visium capture area, add_array_coords() (used internally build_SpatialExperiment()) recomputed array coordinates (.e. spe$array_row spe$array_col) sensibly index stitched data. Let’s explain detail. definition, array coordinates (see documentation 10X) integer indices spot Visium capture area, numbering typically 78 128 rows columns, respectively, 6.5mm capture area. build_SpatialExperiment() function retains capture area’s original array coordinates, spe$array_row_original spe$array_col_original, typically useful represent group-level, stitched data. fact, stitched capture area exact array coordinates, despite different spatial positions stitching. ’ll take -tissue spots use transparency emphasize overlap among capture areas: Let’s contrast array coordinates recomputed visiumStitched. Briefly, visiumStitched forms new hexagonal, Visium-like grid spanning space occupied capture areas stitching. , true spot positions fit nearest new spot positions, terms Euclidean distance. Finally, array coordinates re-indexed according new spot assignments, resulting spatially meaningful values apply group level stitched data. important downstream application array coordinates, enables methods rely hexagonal grid structure Visium find original six neighboring spots. enables clustering BayesSpace PRECAST, treat group spatially continuous sample. can see BayesSpace:::.find_neighbors() version 1.11.0 uses hexagonal Visium grid properties find spot neighbors. See also BayesSpace Figure 1b illustration process. Yet, doesn’t matter actually two spots six neighbor positions. visiumStitched takes advantage property enable BayesSpace spatially-aware clustering methods use data overlapping spots performing spatial clustering. can use colData(spe)$overlap_key inspect whether overlapping spots assigned spatial cluster.","code":"## Plot positions of default array coordinates, before overwriting with more ## meaningful values. Use custom colors for each capture area ca_colors <- c(\"#A33B20\", \"#e7bb41\", \"#3d3b8e\") names(ca_colors) <- c(\"V13B23-283_C1\", \"V13B23-283_D1\", \"V13B23-283_A1\") colData(spe) |> as_tibble() |> filter(in_tissue) |> ggplot( mapping = aes( x = array_row_original, y = array_col_original, color = capture_area ) ) + geom_point(alpha = 0.3) + scale_color_manual(values = ca_colors) ## Plot positions of redefined array coordinates colData(spe) |> as_tibble() |> filter(in_tissue) |> ggplot( mapping = aes( x = array_row, y = array_col, color = capture_area ) ) + geom_point(alpha = 0.3) + scale_color_manual(values = ca_colors)"},{"path":"/articles/visiumStitched.html","id":"error-metrics","dir":"Articles","previous_headings":"Examining the stitched data > Defining Array Coordinates","what":"Error metrics","title":"Introduction to visiumStitched","text":"algorithm can fit set capture areas’ spots onto single hexagonal grid without error. , define spot’s error assigned new array coordinates two independent metrics, stored spe$euclidean_error spe$shared_neighbors user opts compute build_SpatialExperiment(calc_error_metrics = TRUE). latter metric can take couple minutes compute, thus default metrics computed. first metric Euclidean distance, multiples 100 microns (distance spots Visium capture area), spot’s original position position assigned array coordinates. metric, spe$shared_neighbors, measures fraction original neighbors (capture area) retained mapping new array coordinates. Thus, value 1 ideal. theory, error measured metrics slight impact quality clustering results downstream. envision interested users checking metrics interpreting specific spots’ cluster assignments downstream.","code":"# Explore the distribution of Euclidean error colData(spe) |> as_tibble() |> ggplot(mapping = aes(x = 0, y = euclidean_error)) + geom_boxplot() # Explore the distribution of Euclidean error colData(spe) |> as_tibble() |> ggplot(mapping = aes(x = 0, y = shared_neighbors)) + geom_boxplot()"},{"path":"/articles/visiumStitched.html","id":"downstream-applications","dir":"Articles","previous_headings":"","what":"Downstream applications","title":"Introduction to visiumStitched","text":"One common area analysis spatial transcriptomics involves clustering– particular, spatially-aware clustering. Many spatially-aware clustering algorithms check array coordinates determine neighboring spots ultimately produce spatially smooth clusters. previously explained, visiumStitched re-computes array coordinates meaningful way, software like BayesSpace PRECAST work ---box stitched data, treating group single continuous sample. ’ve already run PRECAST, can visualize results , see fairly seamless transition cluster assignments across capture-area boundaries. First, let’s examine k = 2: can see two spatial clusters differentiating white vs gray matter based white matter marker genes previously visualized. example data, k = 4 k = 8 also computed. Let’s visualize k = 4 results. biological interpretation spatial clusters need work, using methods : spatial registration reference sc/snRNA-seq spatial data, visualization known marker genes tissue interest, identification data driven marker genes using spatialLIBD::registration_wrapper(), DeconvoBuddies::findMarkers_1vAll(), DeconvoBuiddies::get_mean_ratio() tools. See Pullin McCarthy, Genome Biol., 2024 list marker gene selection methods.","code":"## Grab SpatialExperiment with normalized counts spe_norm <- fetch_data(type = \"visiumStitched_brain_spe\") #> 2024-10-18 14:32:09.120713 loading file /github/home/.cache/R/BiocFileCache/25739445980_visiumStitched_brain_spe.rds%3Frlkey%3Dnq6a82u23xuu9hohr86oodwdi%26dl%3D1 assayNames(spe_norm) #> [1] \"counts\" \"logcounts\" ## PRECAST k = 2 clusters with our manually chosen colors vis_clus( spe_norm, clustervar = \"precast_k2_stitched\", is_stitched = TRUE, colors = c( \"1\" = \"gold\", \"2\" = \"darkblue\", \"NA\" = \"white\" ), spatial = FALSE ) ## PRECAST results already available in this example data vars <- colnames(colData(spe_norm)) vars[grep(\"precast\", vars)] #> [1] \"precast_k2_stitched\" \"precast_k4_stitched\" \"precast_k8_stitched\" #> [4] \"precast_k16_stitched\" \"precast_k24_stitched\" \"precast_k2_unstitched\" #> [7] \"precast_k4_unstitched\" \"precast_k8_unstitched\" \"precast_k16_unstitched\" #> [10] \"precast_k24_unstitched\" ## PRECAST k = 4 clusters with default cluster colors vis_clus( spe_norm, clustervar = \"precast_k4_stitched\", is_stitched = TRUE, spatial = FALSE )"},{"path":"/articles/visiumStitched.html","id":"conclusion","dir":"Articles","previous_headings":"","what":"Conclusion","title":"Introduction to visiumStitched","text":"visiumStitched provides set helper functions, conjunction ImageJ/Fiji, intended simplify stitching Visium data spatially integrated SpatialExperiment object ready analysis. hope find useful research!","code":""},{"path":"/articles/visiumStitched.html","id":"reproducibility","dir":"Articles","previous_headings":"","what":"Reproducibility","title":"Introduction to visiumStitched","text":"visiumStitched package (Eagles Collado-Torres, 2024) made possible thanks : R (R Core Team, 2024) BiocFileCache (Shepherd Morgan, 2024) BiocStyle (Oleś, 2024) dplyr (Wickham, François, Henry, Müller, Vaughan, 2023) DropletUtils (Lun, Riesenfeld, Andrews, Dao, Gomes, participants 1st Human Cell Atlas Jamboree, Marioni, 2019) ggplot2 (Wickham, 2016) imager (Barthelme, 2024) knitr (Xie, 2024) pkgcond (Redd R Documentation Task Force, 2021) RefManageR (McLean, 2017) rjson (Couture-Beil, 2024) rmarkdown (Allaire, Xie, Dervieux, McPherson, Luraschi, Ushey, Atkins, Wickham, Cheng, Chang, Iannone, 2024) S4Vectors (Pagès, Lawrence, Aboyoun, 2024) sessioninfo (Wickham, Chang, Flight, Müller, Hester, 2021) Seurat (Hao, Stuart, Kowalski, Choudhary, Hoffman, Hartman, Srivastava, Molla, Madad, Fernandez-Granda, Satija, 2023) SpatialExperiment (Righelli, Weber, Crowell, Pardo, Collado-Torres, Ghazanfar, Lun, Hicks, Risso, 2022) spatialLIBD (Pardo, Spangler, Weber, Hicks, Jaffe, Martinowich, Maynard, Collado-Torres, 2022) stringr (Wickham, 2023) SummarizedExperiment (Morgan, Obenchain, Hester, Pagès, 2024) testthat (Wickham, 2011) xml2 (Wickham, Hester, Ooms, 2023) package developed using biocthis. Code creating vignette R session information.","code":"## Create the vignette library(\"rmarkdown\") system.time(render(\"visiumStitched.Rmd\", \"BiocStyle::html_document\")) ## Extract the R code library(\"knitr\") knit(\"visiumStitched.Rmd\", tangle = TRUE) #> ─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────── #> setting value #> version R version 4.4.1 (2024-06-14) #> os Ubuntu 22.04.5 LTS #> system x86_64, linux-gnu #> ui X11 #> language en #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz UTC #> date 2024-10-18 #> pandoc 3.4 @ /usr/bin/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> abind 1.4-8 2024-09-12 [1] RSPM (R 4.4.0) #> AnnotationDbi 1.67.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> AnnotationHub 3.13.3 2024-08-19 [1] Bioconductor 3.20 (R 4.4.1) #> attempt 0.3.1 2020-05-03 [1] RSPM (R 4.4.0) #> backports 1.5.0 2024-05-23 [1] RSPM (R 4.4.0) #> beachmat 2.21.6 2024-09-05 [1] Bioconductor 3.20 (R 4.4.1) #> beeswarm 0.4.0 2021-06-01 [1] RSPM (R 4.4.0) #> benchmarkme 1.0.8 2022-06-12 [1] RSPM (R 4.4.0) #> benchmarkmeData 1.0.4 2020-04-23 [1] RSPM (R 4.4.0) #> bibtex 0.5.1 2023-01-26 [1] RSPM (R 4.4.0) #> Biobase * 2.65.1 2024-08-28 [1] Bioconductor 3.20 (R 4.4.1) #> BiocBaseUtils 1.7.3 2024-08-29 [1] Bioconductor 3.20 (R 4.4.1) #> BiocFileCache * 2.13.2 2024-10-11 [1] Bioconductor 3.20 (R 4.4.1) #> BiocGenerics * 0.51.3 2024-10-02 [1] Bioconductor 3.20 (R 4.4.1) #> BiocIO 1.15.2 2024-08-23 [1] Bioconductor 3.20 (R 4.4.1) #> BiocManager 1.30.25 2024-08-28 [2] CRAN (R 4.4.1) #> BiocNeighbors 1.99.2 2024-10-07 [1] Bioconductor 3.20 (R 4.4.1) #> BiocParallel 1.39.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> BiocSingular 1.21.4 2024-09-22 [1] Bioconductor 3.20 (R 4.4.1) #> BiocStyle * 2.33.1 2024-06-12 [1] Bioconductor 3.20 (R 4.4.0) #> BiocVersion 3.20.0 2024-05-01 [2] Bioconductor 3.20 (R 4.4.1) #> Biostrings 2.73.2 2024-09-26 [1] Bioconductor 3.20 (R 4.4.1) #> bit 4.5.0 2024-09-20 [1] RSPM (R 4.4.0) #> bit64 4.5.2 2024-09-22 [1] RSPM (R 4.4.0) #> bitops 1.0-9 2024-10-03 [1] RSPM (R 4.4.0) #> blob 1.2.4 2023-03-17 [1] RSPM (R 4.4.0) #> bmp 0.3 2017-09-11 [1] RSPM (R 4.4.0) #> bookdown 0.41 2024-10-16 [1] RSPM (R 4.4.0) #> bslib 0.8.0 2024-07-29 [2] RSPM (R 4.4.0) #> cachem 1.1.0 2024-05-16 [2] RSPM (R 4.4.0) #> cli 3.6.3 2024-06-21 [2] RSPM (R 4.4.0) #> codetools 0.2-20 2024-03-31 [3] CRAN (R 4.4.1) #> colorspace 2.1-1 2024-07-26 [1] RSPM (R 4.4.0) #> config 0.3.2 2023-08-30 [1] RSPM (R 4.4.0) #> cowplot 1.1.3 2024-01-22 [1] RSPM (R 4.4.0) #> crayon 1.5.3 2024-06-20 [2] RSPM (R 4.4.0) #> curl 5.2.3 2024-09-20 [2] RSPM (R 4.4.0) #> data.table 1.16.2 2024-10-10 [1] RSPM (R 4.4.0) #> DBI 1.2.3 2024-06-02 [1] RSPM (R 4.4.0) #> dbplyr * 2.5.0 2024-03-19 [1] RSPM (R 4.4.0) #> DelayedArray 0.31.14 2024-10-03 [1] Bioconductor 3.20 (R 4.4.1) #> DelayedMatrixStats 1.27.3 2024-08-08 [1] Bioconductor 3.20 (R 4.4.1) #> desc 1.4.3 2023-12-10 [2] RSPM (R 4.4.0) #> digest 0.6.37 2024-08-19 [2] RSPM (R 4.4.0) #> doParallel 1.0.17 2022-02-07 [1] RSPM (R 4.4.0) #> dotCall64 1.2 2024-10-04 [1] RSPM (R 4.4.0) #> dplyr * 1.1.4 2023-11-17 [1] RSPM (R 4.4.0) #> dqrng 0.4.1 2024-05-28 [1] RSPM (R 4.4.0) #> DropletUtils 1.25.2 2024-07-23 [1] Bioconductor 3.20 (R 4.4.1) #> DT 0.33 2024-04-04 [1] RSPM (R 4.4.0) #> edgeR 4.3.19 2024-10-11 [1] Bioconductor 3.20 (R 4.4.1) #> evaluate 1.0.1 2024-10-10 [2] RSPM (R 4.4.0) #> ExperimentHub 2.13.1 2024-07-31 [1] Bioconductor 3.20 (R 4.4.1) #> fansi 1.0.6 2023-12-08 [2] RSPM (R 4.4.0) #> farver 2.1.2 2024-05-13 [1] RSPM (R 4.4.0) #> fastmap 1.2.0 2024-05-15 [2] RSPM (R 4.4.0) #> fields 16.3 2024-09-30 [1] RSPM (R 4.4.0) #> filelock 1.0.3 2023-12-11 [1] RSPM (R 4.4.0) #> foreach 1.5.2 2022-02-02 [1] RSPM (R 4.4.0) #> fs 1.6.4 2024-04-25 [2] RSPM (R 4.4.0) #> generics 0.1.3 2022-07-05 [1] RSPM (R 4.4.0) #> GenomeInfoDb * 1.41.2 2024-10-02 [1] Bioconductor 3.20 (R 4.4.1) #> GenomeInfoDbData 1.2.13 2024-10-16 [1] Bioconductor #> GenomicAlignments 1.41.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> GenomicRanges * 1.57.2 2024-10-09 [1] Bioconductor 3.20 (R 4.4.1) #> ggbeeswarm 0.7.2 2023-04-29 [1] RSPM (R 4.4.0) #> ggplot2 * 3.5.1 2024-04-23 [1] RSPM (R 4.4.0) #> ggrepel 0.9.6 2024-09-07 [1] RSPM (R 4.4.0) #> glue 1.8.0 2024-09-30 [2] RSPM (R 4.4.0) #> golem 0.5.1 2024-08-27 [1] RSPM (R 4.4.0) #> gridExtra 2.3 2017-09-09 [1] RSPM (R 4.4.0) #> gtable 0.3.5 2024-04-22 [1] RSPM (R 4.4.0) #> HDF5Array 1.33.8 2024-10-04 [1] Bioconductor 3.20 (R 4.4.1) #> highr 0.11 2024-05-26 [2] RSPM (R 4.4.0) #> hms 1.1.3 2023-03-21 [1] RSPM (R 4.4.0) #> htmltools 0.5.8.1 2024-04-04 [2] RSPM (R 4.4.0) #> htmlwidgets 1.6.4 2023-12-06 [2] RSPM (R 4.4.0) #> httpuv 1.6.15 2024-03-26 [2] RSPM (R 4.4.0) #> httr 1.4.7 2023-08-15 [1] RSPM (R 4.4.0) #> igraph 2.0.3 2024-03-13 [1] RSPM (R 4.4.0) #> imager 1.0.2 2024-05-13 [1] RSPM (R 4.4.0) #> IRanges * 2.39.2 2024-07-17 [1] Bioconductor 3.20 (R 4.4.1) #> irlba 2.3.5.1 2022-10-03 [1] RSPM (R 4.4.0) #> iterators 1.0.14 2022-02-05 [1] RSPM (R 4.4.0) #> jpeg 0.1-10 2022-11-29 [1] RSPM (R 4.4.0) #> jquerylib 0.1.4 2021-04-26 [2] RSPM (R 4.4.0) #> jsonlite 1.8.9 2024-09-20 [2] RSPM (R 4.4.0) #> KEGGREST 1.45.1 2024-06-17 [1] Bioconductor 3.20 (R 4.4.0) #> knitr 1.48 2024-07-07 [2] RSPM (R 4.4.0) #> labeling 0.4.3 2023-08-29 [1] RSPM (R 4.4.0) #> later 1.3.2 2023-12-06 [2] RSPM (R 4.4.0) #> lattice 0.22-6 2024-03-20 [3] CRAN (R 4.4.1) #> lazyeval 0.2.2 2019-03-15 [1] RSPM (R 4.4.0) #> lifecycle 1.0.4 2023-11-07 [2] RSPM (R 4.4.0) #> limma 3.61.12 2024-09-30 [1] Bioconductor 3.20 (R 4.4.1) #> locfit 1.5-9.10 2024-06-24 [1] RSPM (R 4.4.0) #> lubridate 1.9.3 2023-09-27 [1] RSPM (R 4.4.0) #> magick 2.8.5 2024-09-20 [1] RSPM (R 4.4.0) #> magrittr 2.0.3 2022-03-30 [2] RSPM (R 4.4.0) #> maps 3.4.2 2023-12-15 [1] RSPM (R 4.4.0) #> Matrix 1.7-0 2024-04-26 [3] CRAN (R 4.4.1) #> MatrixGenerics * 1.17.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> matrixStats * 1.4.1 2024-09-08 [1] RSPM (R 4.4.0) #> memoise 2.0.1 2021-11-26 [2] RSPM (R 4.4.0) #> mime 0.12 2021-09-28 [2] RSPM (R 4.4.0) #> munsell 0.5.1 2024-04-01 [1] RSPM (R 4.4.0) #> paletteer 1.6.0 2024-01-21 [1] RSPM (R 4.4.0) #> pillar 1.9.0 2023-03-22 [2] RSPM (R 4.4.0) #> pkgcond 0.1.1 2021-04-28 [1] RSPM (R 4.4.0) #> pkgconfig 2.0.3 2019-09-22 [2] RSPM (R 4.4.0) #> pkgdown 2.1.1.9000 2024-10-18 [1] Github (r-lib/pkgdown@8d9cba1) #> plotly 4.10.4 2024-01-13 [1] RSPM (R 4.4.0) #> plyr 1.8.9 2023-10-02 [1] RSPM (R 4.4.0) #> png 0.1-8 2022-11-29 [1] RSPM (R 4.4.0) #> promises 1.3.0 2024-04-05 [2] RSPM (R 4.4.0) #> purrr 1.0.2 2023-08-10 [2] RSPM (R 4.4.0) #> R.methodsS3 1.8.2 2022-06-13 [1] RSPM (R 4.4.0) #> R.oo 1.26.0 2024-01-24 [1] RSPM (R 4.4.0) #> R.utils 2.12.3 2023-11-18 [1] RSPM (R 4.4.0) #> R6 2.5.1 2021-08-19 [2] RSPM (R 4.4.0) #> ragg 1.3.3 2024-09-11 [2] RSPM (R 4.4.0) #> rappdirs 0.3.3 2021-01-31 [2] RSPM (R 4.4.0) #> RColorBrewer 1.1-3 2022-04-03 [1] RSPM (R 4.4.0) #> Rcpp 1.0.13 2024-07-17 [2] RSPM (R 4.4.0) #> RCurl 1.98-1.16 2024-07-11 [1] RSPM (R 4.4.0) #> readbitmap 0.1.5 2018-06-27 [1] RSPM (R 4.4.0) #> readr 2.1.5 2024-01-10 [1] RSPM (R 4.4.0) #> RefManageR * 1.4.0 2022-09-30 [1] RSPM (R 4.4.0) #> rematch2 2.1.2 2020-05-01 [2] RSPM (R 4.4.0) #> restfulr 0.0.15 2022-06-16 [1] RSPM (R 4.4.0) #> rhdf5 2.49.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> rhdf5filters 1.17.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> Rhdf5lib 1.27.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> rjson 0.2.23 2024-09-16 [1] RSPM (R 4.4.0) #> rlang 1.1.4 2024-06-04 [2] RSPM (R 4.4.0) #> rmarkdown 2.28 2024-08-17 [2] RSPM (R 4.4.0) #> Rsamtools 2.21.2 2024-09-26 [1] Bioconductor 3.20 (R 4.4.1) #> RSQLite 2.3.7 2024-05-27 [1] RSPM (R 4.4.0) #> rsvd 1.0.5 2021-04-16 [1] RSPM (R 4.4.0) #> rtracklayer 1.65.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> S4Arrays 1.5.11 2024-10-14 [1] Bioconductor 3.20 (R 4.4.1) #> S4Vectors * 0.43.2 2024-07-17 [1] Bioconductor 3.20 (R 4.4.1) #> sass 0.4.9 2024-03-15 [2] RSPM (R 4.4.0) #> ScaledMatrix 1.13.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> scales 1.3.0 2023-11-28 [1] RSPM (R 4.4.0) #> scater 1.33.4 2024-07-21 [1] Bioconductor 3.20 (R 4.4.1) #> scuttle 1.15.4 2024-08-14 [1] Bioconductor 3.20 (R 4.4.1) #> sessioninfo * 1.2.2 2021-12-06 [2] RSPM (R 4.4.0) #> shiny 1.9.1 2024-08-01 [2] RSPM (R 4.4.0) #> shinyWidgets 0.8.7 2024-09-23 [1] RSPM (R 4.4.0) #> SingleCellExperiment * 1.27.2 2024-05-24 [1] Bioconductor 3.20 (R 4.4.0) #> spam 2.11-0 2024-10-03 [1] RSPM (R 4.4.0) #> SparseArray 1.5.44 2024-10-06 [1] Bioconductor 3.20 (R 4.4.1) #> sparseMatrixStats 1.17.2 2024-06-12 [1] Bioconductor 3.20 (R 4.4.0) #> SpatialExperiment * 1.15.1 2024-06-20 [1] Bioconductor 3.20 (R 4.4.0) #> spatialLIBD * 1.17.8 2024-10-16 [1] Github (LieberInstitute/spatialLIBD@c82c789) #> statmod 1.5.0 2023-01-06 [1] RSPM (R 4.4.0) #> stringi 1.8.4 2024-05-06 [2] RSPM (R 4.4.0) #> stringr 1.5.1 2023-11-14 [2] RSPM (R 4.4.0) #> SummarizedExperiment * 1.35.4 2024-10-09 [1] Bioconductor 3.20 (R 4.4.1) #> systemfonts 1.1.0 2024-05-15 [2] RSPM (R 4.4.0) #> textshaping 0.4.0 2024-05-24 [2] RSPM (R 4.4.0) #> tibble 3.2.1 2023-03-20 [2] RSPM (R 4.4.0) #> tidyr 1.3.1 2024-01-24 [1] RSPM (R 4.4.0) #> tidyselect 1.2.1 2024-03-11 [1] RSPM (R 4.4.0) #> tiff 0.1-12 2023-11-28 [1] RSPM (R 4.4.0) #> timechange 0.3.0 2024-01-18 [1] RSPM (R 4.4.0) #> tzdb 0.4.0 2023-05-12 [1] RSPM (R 4.4.0) #> UCSC.utils 1.1.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> utf8 1.2.4 2023-10-22 [2] RSPM (R 4.4.0) #> vctrs 0.6.5 2023-12-01 [2] RSPM (R 4.4.0) #> vipor 0.4.7 2023-12-18 [1] RSPM (R 4.4.0) #> viridis 0.6.5 2024-01-29 [1] RSPM (R 4.4.0) #> viridisLite 0.4.2 2023-05-02 [1] RSPM (R 4.4.0) #> visiumStitched * 0.99.12 2024-10-18 [1] Bioconductor #> vroom 1.6.5 2023-12-05 [1] RSPM (R 4.4.0) #> withr 3.0.1 2024-07-31 [2] RSPM (R 4.4.0) #> xfun 0.48 2024-10-03 [2] RSPM (R 4.4.0) #> XML 3.99-0.17 2024-06-25 [1] RSPM (R 4.4.0) #> xml2 1.3.6 2023-12-04 [2] RSPM (R 4.4.0) #> xtable 1.8-4 2019-04-21 [2] RSPM (R 4.4.0) #> XVector 0.45.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> yaml 2.3.10 2024-07-26 [2] RSPM (R 4.4.0) #> zlibbioc 1.51.1 2024-06-05 [1] Bioconductor 3.20 (R 4.4.0) #> #> [1] /__w/_temp/Library #> [2] /usr/local/lib/R/site-library #> [3] /usr/local/lib/R/library #> #> ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────"},{"path":"/articles/visiumStitched.html","id":"bibliography","dir":"Articles","previous_headings":"","what":"Bibliography","title":"Introduction to visiumStitched","text":"vignette generated using BiocStyle (Oleś, 2024) knitr (Xie, 2024) rmarkdown (Allaire, Xie, Dervieux et al., 2024) running behind scenes. Citations made RefManageR (McLean, 2017). [1] J. Allaire, Y. Xie, C. Dervieux, et al. rmarkdown: Dynamic Documents R. R package version 2.28. 2024. URL: https://github.com/rstudio/rmarkdown. [2] S. Barthelme. imager: Image Processing Library Based ‘CImg’. R package version 1.0.2, https://github.com/asgr/imager/. 2024. URL: https://asgr.github.io/imager/. [3] . Couture-Beil. rjson: JSON R. R package version 0.2.23. 2024. URL: https://github.com/alexcb/rjson. [4] N. J. Eagles L. Collado-Torres. Enable downstream analysis Visium capture areas stitched together Fiji. https://github.com/LieberInstitute/visiumStitched/visiumStitched - R package version 0.99.12. 2024. DOI: 10.18129/B9.bioc.visiumStitched. URL: http://www.bioconductor.org/packages/visiumStitched. [5] Y. Hao, T. Stuart, M. H. Kowalski, et al. “Dictionary learning integrative, multimodal scalable single-cell analysis”. : Nature Biotechnology (2023). DOI: 10.1038/s41587-023-01767-y. URL: https://doi.org/10.1038/s41587-023-01767-y. [6] . T. L. Lun, S. Riesenfeld, T. Andrews, et al. “EmptyDrops: distinguishing cells empty droplets droplet-based single-cell RNA sequencing data”. : Genome Biol. 20 (2019), p. 63. DOI: 10.1186/s13059-019-1662-y. [7] M. W. McLean. “RefManageR: Import Manage BibTeX BibLaTeX References R”. : Journal Open Source Software (2017). DOI: 10.21105/joss.00338. [8] M. Morgan, V. Obenchain, J. Hester, et al. SummarizedExperiment: SummarizedExperiment container. R package version 1.35.4. 2024. DOI: 10.18129/B9.bioc.SummarizedExperiment. URL: https://bioconductor.org/packages/SummarizedExperiment. [9] . Oleś. BiocStyle: Standard styles vignettes Bioconductor documents. R package version 2.33.1. 2024. DOI: 10.18129/B9.bioc.BiocStyle. URL: https://bioconductor.org/packages/BiocStyle. [10] H. Pagès, M. Lawrence, P. Aboyoun. S4Vectors: Foundation vector-like list-like containers Bioconductor. R package version 0.43.2. 2024. DOI: 10.18129/B9.bioc.S4Vectors. URL: https://bioconductor.org/packages/S4Vectors. [11] B. Pardo, . Spangler, L. M. Weber, et al. “spatialLIBD: R/Bioconductor package visualize spatially-resolved transcriptomics data”. : BMC Genomics (2022). DOI: 10.1186/s12864-022-08601-w. URL: https://doi.org/10.1186/s12864-022-08601-w. [12] R Core Team. R: Language Environment Statistical Computing. R Foundation Statistical Computing. Vienna, Austria, 2024. URL: https://www.R-project.org/. [13] . Redd R Documentation Task Force. pkgcond: Classed Error Warning Conditions. R package version 0.1.1. 2021. URL: https://github.com/RDocTaskForce/pkgcond. [14] D. Righelli, L. M. Weber, H. L. Crowell, et al. “SpatialExperiment: infrastructure spatially-resolved transcriptomics data R using Bioconductor”. : Bioinformatics 38.11 (2022), pp. -3. DOI: https://doi.org/10.1093/bioinformatics/btac299. [15] L. Shepherd M. Morgan. BiocFileCache: Manage Files Across Sessions. R package version 2.13.2. 2024. DOI: 10.18129/B9.bioc.BiocFileCache. URL: https://bioconductor.org/packages/BiocFileCache. [16] H. Wickham. ggplot2: Elegant Graphics Data Analysis. Springer-Verlag New York, 2016. ISBN: 978-3-319-24277-4. URL: https://ggplot2.tidyverse.org. [17] H. Wickham. stringr: Simple, Consistent Wrappers Common String Operations. R package version 1.5.1, https://github.com/tidyverse/stringr. 2023. URL: https://stringr.tidyverse.org. [18] H. Wickham. “testthat: Get Started Testing”. : R Journal 3 (2011), pp. 5–10. URL: https://journal.r-project.org/archive/2011-1/RJournal_2011-1_Wickham.pdf. [19] H. Wickham, W. Chang, R. Flight, et al. sessioninfo: R Session Information. R package version 1.2.2, https://r-lib.github.io/sessioninfo/. 2021. URL: https://github.com/r-lib/sessioninfo#readme. [20] H. Wickham, R. François, L. Henry, et al. dplyr: Grammar Data Manipulation. R package version 1.1.4, https://github.com/tidyverse/dplyr. 2023. URL: https://dplyr.tidyverse.org. [21] H. Wickham, J. Hester, J. Ooms. xml2: Parse XML. R package version 1.3.6, https://github.com/r-lib/xml2. 2023. URL: https://xml2.r-lib.org/. [22] Y. Xie. knitr: General-Purpose Package Dynamic Report Generation R. R package version 1.48. 2024. URL: https://yihui.org/knitr/.","code":""},{"path":"/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Nicholas J. Eagles. Author, maintainer. Leonardo Collado-Torres. Contributor.","code":""},{"path":"/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Eagles NJ, Collado-Torres L (2024). Enable downstream analysis Visium capture areas stitched together Fiji. doi:10.18129/B9.bioc.visiumStitched, https://github.com/LieberInstitute/visiumStitched/visiumStitched - R package version 0.99.12, http://www.bioconductor.org/packages/visiumStitched. Eagles NJ, Bach S, Tippani M, Ravichandran P, Du Y, Miller RA, Hyde TM, Page SC, Martinowich K, Collado-Torres L (2024). “visiumStitched.” bioRxiv. doi:10.1101/TODO, https://www.biorxiv.org/content/10.1101/TODO.","code":"@Manual{, title = {Enable downstream analysis of Visium capture areas stitched together with Fiji}, author = {Nicholas J. Eagles and Leonardo Collado-Torres}, year = {2024}, url = {http://www.bioconductor.org/packages/visiumStitched}, note = {https://github.com/LieberInstitute/visiumStitched/visiumStitched - R package version 0.99.12}, doi = {10.18129/B9.bioc.visiumStitched}, } @Article{, title = {visiumStitched}, author = {Nicholas J. Eagles and Svitlana Bach and Madhavi Tippani and Prashanthi Ravichandran and Yufeng Du and Ryan A. Miller and Thomas M. Hyde and Stephanie C. Page and Keri Martinowich and Leonardo Collado-Torres}, year = {2024}, journal = {bioRxiv}, doi = {10.1101/TODO}, url = {https://www.biorxiv.org/content/10.1101/TODO}, }"},{"path":"/index.html","id":"visiumstitched-","dir":"","previous_headings":"","what":"Enable downstream analysis of Visium capture areas stitched together with Fiji","title":"Enable downstream analysis of Visium capture areas stitched together with Fiji","text":"visiumStitched provides helper functions working multiple Visium capture areas overlap . package developed along companion example use case data available https://github.com/LieberInstitute/visiumStitched_brain. visiumStitched prepares SpaceRanger (10x Genomics) output files can stitch images groups capture areas together Fiji. visiumStitched builds SpatialExperiment object stitched data makes artificial hexagonal grid enabling seamless use spatial clustering methods rely grid identify neighboring spots, PRECAST BayesSpace. SpatialExperiment objects created visiumStitched compatible spatialLIBD, can used build interactive websites stitched SpatialExperiment objects (check example human brain data). visiumStitched also enables casting SpatialExperiment objects Seurat objects. details, check documentation site.","code":""},{"path":"/index.html","id":"example-data-processed-with-visiumstitched","dir":"","previous_headings":"","what":"Example data processed with visiumStitched","title":"Enable downstream analysis of Visium capture areas stitched together with Fiji","text":"example human brain data LieberInstitute/visiumStitched_brain stitched together using visiumStitched. resulting data can accessed visualized spatialLIBD version 1.17.8 newer.","code":"## Check that you have a recent version of spatialLIBD installed stopifnot(packageVersion(\"spatialLIBD\") >= \"1.17.8\") ## Download the spot-level data, which is a SpatialExperiment object spe <- spatialLIBD::fetch_data(type = \"visiumStitched_brain_spe\") #> snapshotDate(): 2024-04-29 #> 2024-10-14 11:39:40.997043 loading file /users/neagles/.cache/R/BiocFileCache/feb652e603a7a_visiumStitched_brain_spe.rds%3Frlkey%3Dnq6a82u23xuu9hohr86oodwdi%26dl%3D1 ## Explore the stitched data spe #> class: SpatialExperiment #> dim: 26369 13965 #> metadata(0): #> assays(2): counts logcounts #> rownames(26369): ENSG00000238009 ENSG00000241860 ... ENSG00000278817 #> ENSG00000277196 #> rowData names(7): source type ... gene_type gene_search #> colnames(13965): AAACAACGAATAGTTC-1_V13B23-283_A1 #> AAACAAGTATCTCCCA-1_V13B23-283_A1 ... TTGTTTGTATTACACG-1_V13B23-283_D1 #> TTGTTTGTGTAAATTC-1_V13B23-283_D1 #> colData names(40): sample_id in_tissue ... precast_k4 precast_k8 #> reducedDimNames(1): PCA #> mainExpName: NULL #> altExpNames(0): #> spatialCoords names(2) : pxl_col_in_fullres pxl_row_in_fullres #> imgData names(4): sample_id image_id data scaleFactor ## Show clustering results from PRECAST at k = 8 spatialLIBD::vis_clus( spe, clustervar = \"precast_k8\", is_stitched = TRUE )"},{"path":"/index.html","id":"installation-instructions","dir":"","previous_headings":"","what":"Installation instructions","title":"Enable downstream analysis of Visium capture areas stitched together with Fiji","text":"Get latest stable R release CRAN. install visiumStitched Bioconductor using following code:","code":"if (!requireNamespace(\"BiocManager\", quietly = TRUE)) { install.packages(\"BiocManager\") } BiocManager::install(\"visiumStitched\")"},{"path":"/index.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Enable downstream analysis of Visium capture areas stitched together with Fiji","text":"citation output using citation('visiumStitched') R. Please run check updates cite visiumStitched. Please note visiumStitched made possible thanks many R bioinformatics software authors, cited either vignettes /paper(s) describing package.","code":"print(citation(\"visiumStitched\"), bibtex = TRUE) #> Warning in packageDescription(pkg = package, lib.loc = dirname(dir)): no #> package 'visiumStitched' was found #> Eagles NJ, Collado-Torres L (2024). _Enable downstream analysis of #> Visium capture areas stitched together with Fiji_. #> doi:10.18129/B9.bioc.visiumStitched #> , #> https://github.com/LieberInstitute/visiumStitched/visiumStitched - R #> package version, . #> #> A BibTeX entry for LaTeX users is #> #> @Manual{, #> title = {Enable downstream analysis of Visium capture areas stitched together with Fiji}, #> author = {Nicholas J. Eagles and Leonardo Collado-Torres}, #> year = {2024}, #> url = {http://www.bioconductor.org/packages/visiumStitched}, #> note = {https://github.com/LieberInstitute/visiumStitched/visiumStitched - R package version}, #> doi = {10.18129/B9.bioc.visiumStitched}, #> } #> #> Eagles NJ, Bach S, Tippani M, Ravichandran P, Du Y, Miller RA, Hyde TM, #> Page SC, Martinowich K, Collado-Torres L (2024). \"visiumStitched.\" #> _bioRxiv_. doi:10.1101/TODO , #> . #> #> A BibTeX entry for LaTeX users is #> #> @Article{, #> title = {visiumStitched}, #> author = {Nicholas J. Eagles and Svitlana Bach and Madhavi Tippani and Prashanthi Ravichandran and Yufeng Du and Ryan A. Miller and Thomas M. Hyde and Stephanie C. Page and Keri Martinowich and Leonardo Collado-Torres}, #> year = {2024}, #> journal = {bioRxiv}, #> doi = {10.1101/TODO}, #> url = {https://www.biorxiv.org/content/10.1101/TODO}, #> }"},{"path":"/index.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Enable downstream analysis of Visium capture areas stitched together with Fiji","text":"Please note visiumStitched project released Contributor Code Conduct. contributing project, agree abide terms.","code":""},{"path":"/index.html","id":"development-tools","dir":"","previous_headings":"","what":"Development tools","title":"Enable downstream analysis of Visium capture areas stitched together with Fiji","text":"Continuous code testing possible thanks GitHub actions usethis, remotes, rcmdcheck customized use Bioconductor’s docker containers BiocCheck. Code coverage assessment possible thanks codecov covr. documentation website automatically updated thanks pkgdown. code styled automatically thanks styler. documentation formatted thanks devtools roxygen2. details, check dev directory. package developed using biocthis.","code":""},{"path":"/reference/add_array_coords.html","id":null,"dir":"Reference","previous_headings":"","what":"Add transformed array and pixel coordinates to a SpatialExperiment — add_array_coords","title":"Add transformed array and pixel coordinates to a SpatialExperiment — add_array_coords","text":"Given SpatialExperiment-class, sample information, coordinates produced refinement workflow, add array pixel coordinates appropriate linearly transformed capture areas making group present SpatialExperiment-class.","code":""},{"path":"/reference/add_array_coords.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add transformed array and pixel coordinates to a SpatialExperiment — add_array_coords","text":"","code":"add_array_coords(spe, sample_info, coords_dir, calc_error_metrics = FALSE)"},{"path":"/reference/add_array_coords.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add transformed array and pixel coordinates to a SpatialExperiment — add_array_coords","text":"spe SpatialExperiment-class object. sample_info data.frame() columns capture_area, group, fiji_xml_path, fiji_image_path, spaceranger_dir, intra_group_scalar, group_hires_scalef. last two made rescale_fiji_inputs(). coords_dir character(1) vector giving directory containing sample directories tissue_positions.csv, scalefactors_json.json, tissue_lowres_image.png files produced refinement prep_fiji_coords() related functions. calc_error_metrics logical(1) vector indicating whether calculate error metrics related mapping spots well-defined array coordinates. TRUE, adds euclidean_error shared_neighbors spot-level metrics colData(). former indicates distance number inter-spot distances \"move\" spot new array position; latter indicates fraction neighbors associated capture area retained mapping, can quite time-consuming compute.","code":""},{"path":"/reference/add_array_coords.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add transformed array and pixel coordinates to a SpatialExperiment — add_array_coords","text":"SpatialExperiment-class object additional colData columns pxl_row_in_fullres_[suffix] pxl_col_in_fullres_[suffix] [suffix] values original rounded; array_row_original array_col_original columns; modified colData() columns array_row array_col spatialCoords() transformed values.","code":""},{"path":"/reference/add_array_coords.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add transformed array and pixel coordinates to a SpatialExperiment — add_array_coords","text":"Array coordinates determined via algorithm fits spot nearest spot new, imaginary, Visium-like capture area. imaginary capture area differs real capture area extent; array coordinates still start 0 may extend arbitrarily beyond normal maximum indices 77 127 fit every capture area group defined SpatialExperiment-class. goal return well-defined array coordinates consistent spatial orientation group, downstream applications, clustering BayesSpace, can process group really one capture area first place. See https://research.libd.org/visiumStitched/articles/visiumStitched.html#defining-array-coordinates details.","code":""},{"path":"/reference/add_array_coords.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Add transformed array and pixel coordinates to a SpatialExperiment — add_array_coords","text":"Nicholas J. Eagles","code":""},{"path":"/reference/add_array_coords.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add transformed array and pixel coordinates to a SpatialExperiment — add_array_coords","text":"","code":"if (!exists(\"spe\")) { spe <- spatialLIBD::fetch_data(type = \"visiumStitched_brain_spe\") } #> 2024-10-18 14:27:36.458561 loading file /github/home/.cache/R/BiocFileCache/25739445980_visiumStitched_brain_spe.rds%3Frlkey%3Dnq6a82u23xuu9hohr86oodwdi%26dl%3D1 ######################################################################## # Prepare sample_info ######################################################################## sample_info_path = file.path(tempdir(), \"sample_info.rds\") if (file.exists(sample_info_path)) { sample_info <- readRDS(sample_info_path) } else { sample_info <- dplyr::tibble( group = \"Br2719\", capture_area = c(\"V13B23-283_A1\", \"V13B23-283_C1\", \"V13B23-283_D1\") ) # Add 'spaceranger_dir' column sr_dir <- tempdir() temp <- unzip( spatialLIBD::fetch_data(\"visiumStitched_brain_spaceranger\"), exdir = sr_dir ) sample_info$spaceranger_dir <- file.path( sr_dir, sample_info$capture_area, \"outs\", \"spatial\" ) # Add Fiji-output-related columns fiji_dir <- tempdir() temp <- unzip( spatialLIBD::fetch_data(\"visiumStitched_brain_Fiji_out\"), exdir = fiji_dir ) sample_info$fiji_xml_path <- temp[grep(\"xml$\", temp)] sample_info$fiji_image_path <- temp[grep(\"png$\", temp)] ## Re-size images and add more information to the sample_info sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir()) saveRDS(sample_info, sample_info_path) } #> 2024-10-18 14:27:41.321195 loading file /github/home/.cache/R/BiocFileCache/2573560f3ca_visiumStitched_brain_spaceranger.zip%3Frlkey%3Dbdgjc6mgy1ierdad6h6v5g29c%26dl%3D1 #> 2024-10-18 14:27:43.621069 loading file /github/home/.cache/R/BiocFileCache/257305c881d_visiumStitched_brain_fiji_out.zip%3Frlkey%3Dptwal8f5zxakzejwd0oqw0lhj%26dl%3D1 ## Preparing Fiji coordinates and images for build_SpatialExperiment() spe_input_dir <- tempdir() prep_fiji_coords(sample_info, out_dir = spe_input_dir) #> [1] \"/tmp/RtmppTuXYz/Br2719/tissue_positions.csv\" prep_fiji_image(sample_info, out_dir = spe_input_dir) #> [1] \"/tmp/RtmppTuXYz/Br2719/tissue_lowres_image.png\" #> [2] \"/tmp/RtmppTuXYz/Br2719/scalefactors_json.json\" ######################################################################## # Add array coordinates ######################################################################## spe_new <- add_array_coords(spe, sample_info, tempdir()) # Several columns related to spatial coordinates were added added_cols_regex <- \"^(array|pxl)_(row|col)(_in_fullres)?_(original|rounded)$\" colnames(SummarizedExperiment::colData(spe_new))[ grep(added_cols_regex, colnames(SummarizedExperiment::colData(spe_new))) ] #> [1] \"array_row_original\" \"array_col_original\" #> [3] \"pxl_col_in_fullres_rounded\" \"pxl_row_in_fullres_rounded\" #> [5] \"pxl_row_in_fullres_original\" \"pxl_col_in_fullres_original\" # 'array_row', 'array_col', and spatialCoords() were overwritten with # their transformed values head(spe$array_row) #> [1] 0 50 3 59 14 43 head(spe$array_col) #> [1] 16 102 43 19 94 9 head(SpatialExperiment::spatialCoords(spe_new)) #> pxl_col_in_fullres pxl_row_in_fullres #> AAACAACGAATAGTTC-1 1874 50718 #> AAACAAGTATCTCCCA-1 13935 38805 #> AAACAATCTACTAGCA-1 2599 46977 #> AAACACCAATAACTGC-1 16101 50308 #> AAACAGAGCGACTCCT-1 5255 39910 #> AAACAGCTTTCAGAAG-1 12242 51692"},{"path":"/reference/add_overlap_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Add info about how spots overlap among capture areas — add_overlap_info","title":"Add info about how spots overlap among capture areas — add_overlap_info","text":"Given SpatialExperiment-class column name colData, return modified copy SpatialExperiment additional colData columns: spe$exclude_overlapping spe$overlap_key.","code":""},{"path":"/reference/add_overlap_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add info about how spots overlap among capture areas — add_overlap_info","text":"","code":"add_overlap_info(spe, metric_name)"},{"path":"/reference/add_overlap_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add info about how spots overlap among capture areas — add_overlap_info","text":"spe SpatialExperiment-class colData(spe) columns array_row, array_col, key, capture_area. metric_name character(1) colnames(colData(spe)), spots belonging capture area highest average value metric take precedence spots.","code":""},{"path":"/reference/add_overlap_info.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add info about how spots overlap among capture areas — add_overlap_info","text":"SpatialExperiment object additional colData columns spe$exclude_overlapping spe$overlap_key.","code":""},{"path":"/reference/add_overlap_info.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add info about how spots overlap among capture areas — add_overlap_info","text":"spe$exclude_overlapping TRUE spots higher-quality overlapping capture area FALSE otherwise. vis_clus onlydisplays FALSE spots prevent overplotting regions overlap. spe$overlap_key gives comma-separated strings containing keys overlapping spots, empty string otherwise.","code":""},{"path":"/reference/add_overlap_info.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Add info about how spots overlap among capture areas — add_overlap_info","text":"Nicholas J. Eagles","code":""},{"path":"/reference/add_overlap_info.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add info about how spots overlap among capture areas — add_overlap_info","text":"","code":"if (!exists(\"spe\")) { spe <- spatialLIBD::fetch_data(type = \"visiumStitched_brain_spe\") } #> 2024-10-18 14:27:56.973583 loading file /github/home/.cache/R/BiocFileCache/25739445980_visiumStitched_brain_spe.rds%3Frlkey%3Dnq6a82u23xuu9hohr86oodwdi%26dl%3D1 # Find the mean of the 'sum_umi' metric by capture area to understand # which capture areas will be excluded in regions of overlap SummarizedExperiment::colData(spe) |> dplyr::as_tibble() |> dplyr::group_by(capture_area) |> dplyr::summarize(mean_sum_umi = mean(sum_umi)) #> # A tibble: 3 × 2 #> capture_area mean_sum_umi #> #> 1 V13B23-283_A1 2075. #> 2 V13B23-283_C1 1188. #> 3 V13B23-283_D1 2083. spe <- add_overlap_info(spe, \"sum_umi\") # See how many spots were excluded by capture area table(spe$exclude_overlapping, spe$capture_area) #> #> V13B23-283_A1 V13B23-283_C1 V13B23-283_D1 #> FALSE 3920 4367 4596 #> TRUE 1032 50 0 # Examine how data about overlapping spots is stored (for the first # few spots with overlap) head(spe$overlap_key[spe$overlap_key != \"\"]) #> [1] \"TCAGAACGGCGGTAAT-1_V13B23-283_D1,TGCCCGATAGTTAGAA-1_V13B23-283_D1\" #> [2] \"CGACTTGCCGGGAAAT-1_V13B23-283_D1,TCATGAAGCGCTGCAT-1_V13B23-283_D1\" #> [3] \"CCTTAAGTACGCAATT-1_V13B23-283_D1\" #> [4] \"GAAGCCACTGATTATG-1_V13B23-283_D1\" #> [5] \"ACTCAAGTGCAAGGCT-1_V13B23-283_D1\" #> [6] \"GGCCTGCTTCTCCCGA-1_V13B23-283_D1\""},{"path":"/reference/as.Seurat.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert a SpatialExperiment object to a Seurat object — as.Seurat","title":"Convert a SpatialExperiment object to a Seurat object — as.Seurat","text":"Given SpatialExperiment-class object, first .Seurat() run, operates SingleCellExperiment-class objects. remaining components (images, spatial coordinates) added manually. actual appearance images buggy now.","code":""},{"path":"/reference/as.Seurat.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert a SpatialExperiment object to a Seurat object — as.Seurat","text":"","code":"as.Seurat( spe, spatial_cols = c(tissue = \"in_tissue\", row = \"array_row\", col = \"array_col\", imagerow = \"pxl_row_in_fullres\", imagecol = \"pxl_col_in_fullres\"), verbose = TRUE )"},{"path":"/reference/as.Seurat.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert a SpatialExperiment object to a Seurat object — as.Seurat","text":"spe SpatialExperiment-class colData() spatialCoords() columns given spatial_cols. stitched spe object function work type spe objects. spatial_cols character(5) named vector mapping colData(spe) spatialCoords(spe) columns contain tissue, row, col, imagerow, imagecol information expected Seurat. verbose logical(1) vector. TRUE, print status update conversion process. information can useful debugging.","code":""},{"path":"/reference/as.Seurat.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert a SpatialExperiment object to a Seurat object — as.Seurat","text":"Seurat object.","code":""},{"path":"/reference/as.Seurat.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Convert a SpatialExperiment object to a Seurat object — as.Seurat","text":"Note lowres images imgData(spe) used.","code":""},{"path":"/reference/as.Seurat.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Convert a SpatialExperiment object to a Seurat object — as.Seurat","text":"Nicholas J. Eagles","code":""},{"path":"/reference/as.Seurat.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert a SpatialExperiment object to a Seurat object — as.Seurat","text":"","code":"## Download some example data spe_unstitched <- spatialLIBD::fetch_data( type = \"spatialDLPFC_Visium_example_subset\" )[seq(100), seq(100)] #> 2024-10-18 14:28:01.274002 loading file /github/home/.cache/R/BiocFileCache/e1457e2cf2a_spatialDLPFC_spe_subset_example.rds%3Fdl%3D1 ## Make the column names unique colnames(spe_unstitched) <- spatialLIBD::add_key(spe_unstitched)$key #> Overwriting 'spe$key'. Set 'overwrite = FALSE' if you do not want to overwrite it. ## Convert from a SpatialExperiment to a Seurat object seur <- as.Seurat(spe_unstitched) #> Running 'as.Seurat(spe)'... #> Registered S3 method overwritten by 'spatstat.geom': #> method from #> plot.imlist imager #> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from pc. to pc_ #> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from tsne. to tsne_ #> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from umap. to umap_ #> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from PC to PC_ #> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from UMAP to UMAP_ #> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from TSNE_perplexity80_ to TSNEperplexity80_ #> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from UMAP to UMAP_ #> Warning: Key ‘UMAP_’ taken, using ‘umapharmony_’ instead #> Adding spot coordinates and images for sample Br6432_ant... #> Returning converted object... seur #> An object of class Seurat #> 100 features across 100 samples within 1 assay #> Active assay: originalexp (100 features, 0 variable features) #> 2 layers present: counts, data #> 8 dimensional reductions calculated: X10x_pca, X10x_tsne, X10x_umap, PCA, UMAP, TSNE_perplexity80, HARMONY, UMAP.HARMONY #> 1 image present: Br6432_ant ## Example with an stitched SPE object if (!exists(\"spe\")) { spe <- spatialLIBD::fetch_data(type = \"visiumStitched_brain_spe\") } #> 2024-10-18 14:28:07.148939 loading file /github/home/.cache/R/BiocFileCache/25739445980_visiumStitched_brain_spe.rds%3Frlkey%3Dnq6a82u23xuu9hohr86oodwdi%26dl%3D1 seur_stitched <- as.Seurat(spe[seq(100), seq(100)]) #> Running 'as.Seurat(spe)'... #> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from PC to PC_ #> Adding spot coordinates and images for sample Br2719... #> Returning converted object... ## Let's look at our resulting Seurat object seur_stitched #> An object of class Seurat #> 100 features across 100 samples within 1 assay #> Active assay: originalexp (100 features, 0 variable features) #> 2 layers present: counts, data #> 1 dimensional reduction calculated: PCA #> 1 image present: Br2719"},{"path":"/reference/build_SpatialExperiment.html","id":null,"dir":"Reference","previous_headings":"","what":"Build stitched SpatialExperiment — build_SpatialExperiment","title":"Build stitched SpatialExperiment — build_SpatialExperiment","text":"First, read capture-area-level SpaceRanger https://www.10xgenomics.com/support/software/space-ranger/latest/analysis/running-pipelines/space-ranger-count outputs. , overwrite spatial coordinates images represent group-level samples using sample_info$group (though keep original coordinates colData columns ending suffix \"_original\"). Next, add info overlaps (via spe$exclude_overlapping spe$overlap_key). Ultimately, return SpatialExperiment-class ready visualization downstream analysis.","code":""},{"path":"/reference/build_SpatialExperiment.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Build stitched SpatialExperiment — build_SpatialExperiment","text":"","code":"build_SpatialExperiment( sample_info, coords_dir, count_type = \"sparse\", reference_gtf = NULL, gtf_cols = c(\"source\", \"type\", \"gene_id\", \"gene_version\", \"gene_name\", \"gene_type\"), calc_error_metrics = FALSE )"},{"path":"/reference/build_SpatialExperiment.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Build stitched SpatialExperiment — build_SpatialExperiment","text":"sample_info data.frame() columns capture_area, group, fiji_xml_path, fiji_image_path, spaceranger_dir, intra_group_scalar, group_hires_scalef. last two made rescale_fiji_inputs(). coords_dir character(1) vector giving directory containing sample directories tissue_positions.csv, scalefactors_json.json, tissue_lowres_image.png files produced refinement prep_fiji_coords() related functions. count_type character(1) vector passed type SpatialExperiment::read10xVisium, defaulting \"sparse\". reference_gtf Passed spatialLIBD::read10xVisiumWrapper(). working system SpaceRanger run, GTF automatically found; otherwise character(1) path may supplied, pointing GTF file gene annotation populate rowData() . gtf_cols Passed spatialLIBD::read10xVisiumWrapper(). Columns reference GTF extract populate rowData(). calc_error_metrics logical(1) vector indicating whether calculate error metrics related mapping spots well-defined array coordinates. TRUE, adds euclidean_error shared_neighbors spot-level metrics colData(). former indicates distance number inter-spot distances \"move\" spot new array position; latter indicates fraction neighbors associated capture area retained mapping, can quite time-consuming compute.","code":""},{"path":"/reference/build_SpatialExperiment.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Build stitched SpatialExperiment — build_SpatialExperiment","text":"SpatialExperiment-class object one sample per group specified sample_info using transformed pixel array coordinates (including spatialCoords()).","code":""},{"path":"/reference/build_SpatialExperiment.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Build stitched SpatialExperiment — build_SpatialExperiment","text":"Nicholas J. Eagles","code":""},{"path":"/reference/build_SpatialExperiment.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Build stitched SpatialExperiment — build_SpatialExperiment","text":"","code":"######################################################################## # Prepare sample_info ######################################################################## sample_info_path = file.path(tempdir(), \"sample_info.rds\") if (file.exists(sample_info_path)) { sample_info <- readRDS(sample_info_path) } else { sample_info <- dplyr::tibble( group = \"Br2719\", capture_area = c(\"V13B23-283_A1\", \"V13B23-283_C1\", \"V13B23-283_D1\") ) # Add 'spaceranger_dir' column sr_dir <- tempdir() temp <- unzip( spatialLIBD::fetch_data(\"visiumStitched_brain_spaceranger\"), exdir = sr_dir ) sample_info$spaceranger_dir <- file.path( sr_dir, sample_info$capture_area, \"outs\", \"spatial\" ) # Add Fiji-output-related columns fiji_dir <- tempdir() temp <- unzip( spatialLIBD::fetch_data(\"visiumStitched_brain_Fiji_out\"), exdir = fiji_dir ) sample_info$fiji_xml_path <- temp[grep(\"xml$\", temp)] sample_info$fiji_image_path <- temp[grep(\"png$\", temp)] ## Re-size images and add more information to the sample_info sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir()) saveRDS(sample_info, sample_info_path) } ## Preparing Fiji coordinates and images for build_SpatialExperiment() spe_input_dir <- tempdir() prep_fiji_coords(sample_info, out_dir = spe_input_dir) #> [1] \"/tmp/RtmppTuXYz/Br2719/tissue_positions.csv\" prep_fiji_image(sample_info, out_dir = spe_input_dir) #> [1] \"/tmp/RtmppTuXYz/Br2719/tissue_lowres_image.png\" #> [2] \"/tmp/RtmppTuXYz/Br2719/scalefactors_json.json\" ######################################################################## # Build the SpatialExperiment ######################################################################## # Since we don't have access to the original GTF used to run SpaceRanger, # we must explicitly supply our own GTF to build_SpatialExperiment(). We use # GENCODE release 32, intended to be quite close to the actual GTF used, # which is available from: # https://cf.10xgenomics.com/supp/cell-exp/refdata-gex-GRCh38-2024-A.tar.gz bfc <- BiocFileCache::BiocFileCache() gtf_cache <- BiocFileCache::bfcrpath( bfc, paste0( \"ftp://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/\", \"release_32/gencode.v32.annotation.gtf.gz\" ) ) ## Now we can build the stitched SpatialExperiment object spe <- build_SpatialExperiment( sample_info, coords_dir = spe_input_dir, reference_gtf = gtf_cache ) #> Building SpatialExperiment using capture area as sample ID #> 2024-10-18 14:28:10.819786 SpatialExperiment::read10xVisium: reading basic data from SpaceRanger #> 2024-10-18 14:28:17.832969 read10xVisiumAnalysis: reading analysis output from SpaceRanger #> 2024-10-18 14:28:18.145846 add10xVisiumAnalysis: adding analysis output from SpaceRanger #> 2024-10-18 14:28:18.447235 rtracklayer::import: reading the reference GTF file #> 2024-10-18 14:28:48.016788 adding gene information to the SPE object #> Warning: Gene IDs did not match. This typically happens when you are not using the same GTF file as the one that was used by SpaceRanger. For example, one file uses GENCODE IDs and the other one ENSEMBL IDs. read10xVisiumWrapper() will try to convert them to ENSEMBL IDs. #> Warning: Dropping 2226 out of 38606 genes for which we don't have information on the reference GTF file. This typically happens when you are not using the same GTF file as the one that was used by SpaceRanger. #> 2024-10-18 14:28:48.243393 adding information used by spatialLIBD #> Overwriting imgData(spe) with merged images (one per group) #> Adding array coordinates and overlap info ## Let's explore the stitched SpatialExperiment object spe #> class: SpatialExperiment #> dim: 36380 14976 #> metadata(0): #> assays(1): counts #> rownames(36380): ENSG00000243485.5 ENSG00000237613.2 ... #> ENSG00000198695.2 ENSG00000198727.2 #> rowData names(6): source type ... gene_type gene_search #> colnames(14976): AAACAACGAATAGTTC-1_V13B23-283_A1 #> AAACAAGTATCTCCCA-1_V13B23-283_A1 ... TTGTTTGTATTACACG-1_V13B23-283_D1 #> TTGTTTGTGTAAATTC-1_V13B23-283_D1 #> colData names(31): sample_id in_tissue ... overlap_key #> exclude_overlapping #> reducedDimNames(0): #> mainExpName: NULL #> altExpNames(0): #> spatialCoords names(2) : pxl_col_in_fullres pxl_row_in_fullres #> imgData names(4): sample_id image_id data scaleFactor"},{"path":"/reference/dot-add_error_metrics.html","id":null,"dir":"Reference","previous_headings":"","what":"Add error metrics related to array-coordinate mapping — .add_error_metrics","title":"Add error metrics related to array-coordinate mapping — .add_error_metrics","text":"Given tibble()s mapping new array coordinates, calculate metrics related suitability mapping.","code":""},{"path":"/reference/dot-add_error_metrics.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add error metrics related to array-coordinate mapping — .add_error_metrics","text":"","code":".add_error_metrics(coords, coords_new, inter_spot_dist_px)"},{"path":"/reference/dot-add_error_metrics.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add error metrics related to array-coordinate mapping — .add_error_metrics","text":"coords tibble() containing array_row, array_col, key, pxl_col_in_fullres, pxl_row_in_fullres, pxl_col_in_fullres_rounded, pxl_row_in_fullres_rounded, capture_area columns, representing data mapping new array coordinates one group. coords_new tibble() containing array_row, array_col, key, pxl_col_in_fullres, pxl_row_in_fullres, pxl_col_in_fullres_rounded, pxl_row_in_fullres_rounded columns, representing data mapping new array coordinates one group. inter_spot_dist_px numeric(1) giving number pixels spots group.","code":""},{"path":"/reference/dot-add_error_metrics.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add error metrics related to array-coordinate mapping — .add_error_metrics","text":"tibble() copy coords_new additional shared_neighbors euclidean_error columns.","code":""},{"path":"/reference/dot-add_error_metrics.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add error metrics related to array-coordinate mapping — .add_error_metrics","text":"Add column shared_neighbors, fraction neighbors spot started retained mapping; add column euclidean_error, number multiples inter-spot distance spot must move placed new array coordinates.","code":""},{"path":"/reference/dot-add_error_metrics.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Add error metrics related to array-coordinate mapping — .add_error_metrics","text":"Nicholas J. Eagles","code":""},{"path":"/reference/dot-clean_round.html","id":null,"dir":"Reference","previous_headings":"","what":"Round to the nearest integer, always rounding up at 0.5 — .clean_round","title":"Round to the nearest integer, always rounding up at 0.5 — .clean_round","text":"consistent behavior favorable application, want minimize duplicate mappings spots new array coordinates.","code":""},{"path":"/reference/dot-clean_round.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Round to the nearest integer, always rounding up at 0.5 — .clean_round","text":"","code":".clean_round(x)"},{"path":"/reference/dot-clean_round.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Round to the nearest integer, always rounding up at 0.5 — .clean_round","text":"x numeric() vector.","code":""},{"path":"/reference/dot-clean_round.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Round to the nearest integer, always rounding up at 0.5 — .clean_round","text":"numeric() vector rounded nearest integer.","code":""},{"path":"/reference/dot-clean_round.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Round to the nearest integer, always rounding up at 0.5 — .clean_round","text":"Nicholas J. Eagles","code":""},{"path":"/reference/dot-fit_to_array.html","id":null,"dir":"Reference","previous_headings":"","what":"Fit spots to a new Visium-like array — .fit_to_array","title":"Fit spots to a new Visium-like array — .fit_to_array","text":"Given transformed pixel coordinates, modify 'array_row' 'array_col' columns represent larger Visium capture area containing capture areas common coordinate system. number array rows/cols generally changes Visium standards 78 128 (even may change ratio num rows num cols).","code":""},{"path":"/reference/dot-fit_to_array.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fit spots to a new Visium-like array — .fit_to_array","text":"","code":".fit_to_array(coords, inter_spot_dist_px)"},{"path":"/reference/dot-fit_to_array.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fit spots to a new Visium-like array — .fit_to_array","text":"coords data.frame() whose rows represent capture areas group, containing columns 'array_row', 'array_col', 'pxl_row_in_fullres', 'pxl_col_in_fullres'. inter_spot_dist_px numeric(1) vector giving pixel distance 2 spots new coordinates.","code":""},{"path":"/reference/dot-fit_to_array.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fit spots to a new Visium-like array — .fit_to_array","text":"tibble modified array_row + array_col columns, well new pxl_row_in_fullres_rounded pxl_col_in_fullres_rounded columns representing pixel coordinates rounded nearest exact array coordinates.","code":""},{"path":"/reference/dot-fit_to_array.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Fit spots to a new Visium-like array — .fit_to_array","text":"Runtime O(n) number spots, making much faster say, distance-matrix-based approach running O(n^2).","code":""},{"path":"/reference/dot-fit_to_array.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Fit spots to a new Visium-like array — .fit_to_array","text":"Nicholas J. Eagles","code":""},{"path":"/reference/dot-get_neighbors.html","id":null,"dir":"Reference","previous_headings":"","what":"Get keys of neighboring spots — .get_neighbors","title":"Get keys of neighboring spots — .get_neighbors","text":"given row tibble() containing array coordinates, find associated spot's neighbors (belonging capture area) return keys.","code":""},{"path":"/reference/dot-get_neighbors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get keys of neighboring spots — .get_neighbors","text":"","code":".get_neighbors(i, coords)"},{"path":"/reference/dot-get_neighbors.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get keys of neighboring spots — .get_neighbors","text":"integer(1) giving row index coords. coords tibble() containing array_row, array_col, key, capture_area columns.","code":""},{"path":"/reference/dot-get_neighbors.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get keys of neighboring spots — .get_neighbors","text":"character() neighboring spot keys.","code":""},{"path":"/reference/dot-get_neighbors.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Get keys of neighboring spots — .get_neighbors","text":"Nicholas J. Eagles","code":""},{"path":"/reference/dot-get_shared_neighbors.html","id":null,"dir":"Reference","previous_headings":"","what":"Calculate fraction of neighbors retained after mapping to new array coordinates — .get_shared_neighbors","title":"Calculate fraction of neighbors retained after mapping to new array coordinates — .get_shared_neighbors","text":"Given tibble()s mapping new array coordinates, calculate spot fraction starting neighboring spots retained new array-coordinate system. Add metric return.","code":""},{"path":"/reference/dot-get_shared_neighbors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Calculate fraction of neighbors retained after mapping to new array coordinates — .get_shared_neighbors","text":"","code":".get_shared_neighbors(coords_new, coords)"},{"path":"/reference/dot-get_shared_neighbors.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Calculate fraction of neighbors retained after mapping to new array coordinates — .get_shared_neighbors","text":"coords_new tibble() containing array_row, array_col, key, capture_area columns, representing data mapping new array coordinates. coords tibble() containing array_row, array_col, key, capture_area columns, representing data mapping new array coordinates.","code":""},{"path":"/reference/dot-get_shared_neighbors.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Calculate fraction of neighbors retained after mapping to new array coordinates — .get_shared_neighbors","text":"tibble() copy coords_new additional shared_neighbors column.","code":""},{"path":"/reference/dot-get_shared_neighbors.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Calculate fraction of neighbors retained after mapping to new array coordinates — .get_shared_neighbors","text":"Nicholas J. Eagles","code":""},{"path":"/reference/dot-refine_fit.html","id":null,"dir":"Reference","previous_headings":"","what":"Return array coordinates fit to nearest spot with associated error — .refine_fit","title":"Return array coordinates fit to nearest spot with associated error — .refine_fit","text":"First, values x rounded nearest integer. , values y rounded nearest valid integer constraint coordinates x y must odd even. rounded values returned, along Euclidean distance needed move x y original, non-integer values rounded values.","code":""},{"path":"/reference/dot-refine_fit.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Return array coordinates fit to nearest spot with associated error — .refine_fit","text":"","code":".refine_fit(x, y, INTERVAL_X, INTERVAL_Y)"},{"path":"/reference/dot-refine_fit.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Return array coordinates fit to nearest spot with associated error — .refine_fit","text":"x numeric() vector giving \"ideal\" array coordinates given every spot's transformed pixel coordinates. y x, though y must represent ideal array columns iff x represents array rows, vice versa. INTERVAL_X numeric(1) giving pixel distance coordinate units used x (e.g. x represents ideal array_col values, INTERVAL_X represents pixel distance spot columns). INTERVAL_Y numeric(1) giving pixel distance coordinate units used y.","code":""},{"path":"/reference/dot-refine_fit.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Return array coordinates fit to nearest spot with associated error — .refine_fit","text":"list consisting 3 unnamed numeric() vectors: rounded x, rounded y, Euclidean distance pixels rounding x y.","code":""},{"path":"/reference/dot-refine_fit.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Return array coordinates fit to nearest spot with associated error — .refine_fit","text":"Nicholas J. Eagles","code":""},{"path":"/reference/dot-validate_array.html","id":null,"dir":"Reference","previous_headings":"","what":"Check if coordinates are Visium-like — .validate_array","title":"Check if coordinates are Visium-like — .validate_array","text":"Sanity check designed catch unforeseen bugs: halt tibble-like coords, expected contain columns 'array_row' 'array_col', represents invalid Visium array.","code":""},{"path":"/reference/dot-validate_array.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check if coordinates are Visium-like — .validate_array","text":"","code":".validate_array(coords)"},{"path":"/reference/dot-validate_array.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check if coordinates are Visium-like — .validate_array","text":"coords data.frame() containing 'array_row' 'array_col' columns calculated internally add_array_coords().","code":""},{"path":"/reference/dot-validate_array.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Check if coordinates are Visium-like — .validate_array","text":"returns NULL tests correct.","code":""},{"path":"/reference/dot-validate_array.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Check if coordinates are Visium-like — .validate_array","text":"Nicholas J. Eagles","code":""},{"path":"/reference/merge_overlapping.html","id":null,"dir":"Reference","previous_headings":"","what":"Merge overlapping spots — merge_overlapping","title":"Merge overlapping spots — merge_overlapping","text":"Given stitched SpatialExperiment-class, merge overlapping (array coordinates) spots adding expression (.e. assays(spe)$counts), returning SpatialExperiment one spot per array location.","code":""},{"path":"/reference/merge_overlapping.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Merge overlapping spots — merge_overlapping","text":"","code":"merge_overlapping(spe)"},{"path":"/reference/merge_overlapping.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Merge overlapping spots — merge_overlapping","text":"spe SpatialExperiment-class colData(spe) columns array_row, array_col, key, group, capture_area.","code":""},{"path":"/reference/merge_overlapping.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Merge overlapping spots — merge_overlapping","text":"SpatialExperiment one spot per array location","code":""},{"path":"/reference/merge_overlapping.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Merge overlapping spots — merge_overlapping","text":"colData(spe) spatialCoords(spe) merged spots taken spots whose exclude_overlapping values TRUE.","code":""},{"path":"/reference/merge_overlapping.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Merge overlapping spots — merge_overlapping","text":"Nicholas J. Eagles","code":""},{"path":"/reference/merge_overlapping.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Merge overlapping spots — merge_overlapping","text":"","code":"if (!exists(\"spe\")) { spe <- spatialLIBD::fetch_data(type = \"visiumStitched_brain_spe\") } #> 2024-10-18 14:28:52.408461 loading file /github/home/.cache/R/BiocFileCache/25739445980_visiumStitched_brain_spe.rds%3Frlkey%3Dnq6a82u23xuu9hohr86oodwdi%26dl%3D1 # Group colData by group and array coordinates grouped_coldata = colData(spe) |> dplyr::as_tibble() |> dplyr::group_by(group, array_row, array_col) # Find the first 100 keys that overlap other spots and don't, respectively overlapping_keys = grouped_coldata |> dplyr::filter(dplyr::n() > 1) |> dplyr::slice_head(n = 2) |> dplyr::ungroup() |> dplyr::slice_head(n = 100) |> dplyr::pull(key) nonoverlapping_keys = grouped_coldata |> dplyr::filter(dplyr::n() == 1) |> dplyr::ungroup() |> dplyr::slice_head(n = 100) |> dplyr::pull(key) # Built a small SPE containing some overlaps and some non-overlapping spots small_spe = spe[, c(overlapping_keys, nonoverlapping_keys)] # Merge overlapping spots small_spe_merged = merge_overlapping(small_spe) #> Warning: Dropping assays other than 'counts' for merging. #> Warning: Dropped reducedDims(spe) for merging #> 'sample_id's are duplicated across 'SpatialExperiment' objects to cbind; appending sample indices. # All array coordinates have just one unique spot after merging colData(small_spe_merged) |> dplyr::as_tibble() |> dplyr::group_by(group, array_row, array_col) |> dplyr::summarize(n = dplyr::n()) |> dplyr::pull(n) |> table() #> `summarise()` has grouped output by 'group', 'array_row'. You can override #> using the `.groups` argument. #> #> 1 #> 142"},{"path":"/reference/prep_fiji.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare Fiji outputs for building a SpatialExperiment — prep_fiji","title":"Prepare Fiji outputs for building a SpatialExperiment — prep_fiji","text":"Together, prep_fiji_image() prep_fiji_coords() process Fiji outputs generate one directory per group resembling Spaceranger's spatial outputs; particular, tissue_positions.csv, tissue_lowres_image.png, scalefactors_json.json files created. functions necessary run preparation build_SpatialExperiment().","code":""},{"path":"/reference/prep_fiji.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare Fiji outputs for building a SpatialExperiment — prep_fiji","text":"","code":"prep_fiji_image(sample_info, out_dir, lowres_max_size = 1200) prep_fiji_coords(sample_info, out_dir)"},{"path":"/reference/prep_fiji.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare Fiji outputs for building a SpatialExperiment — prep_fiji","text":"sample_info data.frame() columns capture_area, group, fiji_xml_path, fiji_image_path, spaceranger_dir, intra_group_scalar, group_hires_scalef. last two made rescale_fiji_inputs(). out_dir character(1) vector giving path directory place output pixel coordinates CSVs. must exist advance. lowres_max_size integer(1) vector: resolution (number pixels) larger dimension output image(s), considered \"low resolution\". default value 1200 assumes stitching together 2 2 grid Visium capture areas, 600 pixels longest dimension (default SpaceRanger).","code":""},{"path":"/reference/prep_fiji.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare Fiji outputs for building a SpatialExperiment — prep_fiji","text":"function returns character() file paths files created. prep_fiji_coords(), tissue_positions.csv files; prep_fiji_image(), tissue_lowres_image.png scalefactors_json.json files.","code":""},{"path":"/reference/prep_fiji.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Prepare Fiji outputs for building a SpatialExperiment — prep_fiji","text":"Given data.frame() sample information (sample_info) columns capture_area, group, fiji_xml_path, expected one unique path Fiji XML output per group, prep_fiji_coords reads pixel coordinates capture area's tissue_positions.csv file SpaceRanger, transform using rotation matrix specified Fiji https://imagej.net/software/fiji/. writes one new tissue_positions.csv file per group. stitching groups sample_info Fiji, images various resolutions (pixel dimensions) left. prep_fiji_image() creates copies image whose largest dimension lowres_max_size pixels. also creates corresponding scalefactors_json.json file much like SpaceRanger's.","code":""},{"path":"/reference/prep_fiji.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Prepare Fiji outputs for building a SpatialExperiment — prep_fiji","text":"prep_fiji_image(): Create low-res images scale factors high-res Fiji output images prep_fiji_coords(): Apply transform info Fiji XML output","code":""},{"path":"/reference/prep_fiji.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Prepare Fiji outputs for building a SpatialExperiment — prep_fiji","text":"Nicholas J. Eagles","code":""},{"path":"/reference/prep_fiji.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Prepare Fiji outputs for building a SpatialExperiment — prep_fiji","text":"","code":"sample_info_path = file.path(tempdir(), \"sample_info.rds\") if (file.exists(sample_info_path)) { sample_info <- readRDS(sample_info_path) } else { sample_info <- dplyr::tibble( group = \"Br2719\", capture_area = c(\"V13B23-283_A1\", \"V13B23-283_C1\", \"V13B23-283_D1\") ) # Add 'spaceranger_dir' column sr_dir <- tempdir() temp <- unzip( spatialLIBD::fetch_data(\"visiumStitched_brain_spaceranger\"), exdir = sr_dir ) sample_info$spaceranger_dir <- file.path( sr_dir, sample_info$capture_area, \"outs\", \"spatial\" ) # Add Fiji-output-related columns fiji_dir <- tempdir() temp <- unzip( spatialLIBD::fetch_data(\"visiumStitched_brain_Fiji_out\"), exdir = fiji_dir ) sample_info$fiji_xml_path <- temp[grep(\"xml$\", temp)] sample_info$fiji_image_path <- temp[grep(\"png$\", temp)] ## Re-size images and add more information to the sample_info sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir()) saveRDS(sample_info, sample_info_path) } spe_input_dir <- tempdir() out_paths_image <- prep_fiji_image( sample_info, out_dir = spe_input_dir, lowres_max_size = 1000 ) out_path_coords <- prep_fiji_coords(sample_info, out_dir = spe_input_dir) # A \"low resolution\" stitched image was produced, which has 1000 # pixels in its largest dimension this_image <- imager::load.image( file.path(spe_input_dir, \"Br2719\", \"tissue_lowres_image.png\") ) dim(this_image) #> [1] 461 1000 1 3 library(\"imager\") #> Loading required package: magrittr #> #> Attaching package: ‘magrittr’ #> The following object is masked from ‘package:GenomicRanges’: #> #> subtract #> #> Attaching package: ‘imager’ #> The following object is masked from ‘package:magrittr’: #> #> add #> The following objects are masked from ‘package:SummarizedExperiment’: #> #> resize, width #> The following object is masked from ‘package:Biobase’: #> #> channel #> The following objects are masked from ‘package:GenomicRanges’: #> #> resize, width #> The following objects are masked from ‘package:IRanges’: #> #> resize, width #> The following object is masked from ‘package:S4Vectors’: #> #> width #> The following object is masked from ‘package:BiocGenerics’: #> #> width #> The following objects are masked from ‘package:stats’: #> #> convolve, spectrum #> The following object is masked from ‘package:graphics’: #> #> frame #> The following object is masked from ‘package:base’: #> #> save.image plot(this_image) # 'prep_fiji_image' produced an image and scalefactors out_paths_image #> [1] \"/tmp/RtmppTuXYz/Br2719/tissue_lowres_image.png\" #> [2] \"/tmp/RtmppTuXYz/Br2719/scalefactors_json.json\" # 'prep_fiji_coords' produced a file of spatial coordinates for the # stitched Br2719 readr::read_csv(out_path_coords) #> Rows: 14976 Columns: 6 #> ── Column specification ──────────────────────────────────────────────────────── #> Delimiter: \",\" #> chr (1): key #> dbl (5): in_tissue, array_row, array_col, pxl_row_in_fullres, pxl_col_in_ful... #> #> ℹ Use `spec()` to retrieve the full column specification for this data. #> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. #> # A tibble: 14,976 × 6 #> key in_tissue array_row array_col pxl_row_in_fullres pxl_col_in_fullres #> #> 1 ACGCCTGA… 1 0 0 52935. 1873. #> 2 TACCGATC… 1 1 1 52797. 2115. #> 3 ATTAAAGC… 1 0 2 52658. 1873. #> 4 GATAAGGG… 1 1 3 52519. 2115. #> 5 GTGCAAAT… 1 0 4 52381. 1874. #> 6 TGTTGGCT… 1 1 5 52242. 2115. #> 7 GCATCCTC… 1 0 6 52104. 1874. #> 8 GCGAGGGA… 1 1 7 51965. 2115. #> 9 TGGTACCG… 1 0 8 51826. 1874. #> 10 GCGCGTTT… 1 1 9 51688. 2115. #> # ℹ 14,966 more rows"},{"path":"/reference/rescale_fiji_inputs.html","id":null,"dir":"Reference","previous_headings":"","what":"Write same-scale hires images for input to Fiji — rescale_fiji_inputs","title":"Write same-scale hires images for input to Fiji — rescale_fiji_inputs","text":"Given data.frame() sample information (sample_info) columns capture_area, group, spaceranger_dir, Write new high-resolution images use input Fiji https://imagej.net/software/fiji/. Particularly capture areas come different slides, risk significant scale differences among SpaceRanger's tissue_hires_image.png images; , physical distance represented pixel capture area may differ nontrivially, leading distance-distorted output image, inconsistent scaling later transforming pixel coordinates. function writes approximately high-res images whose pixels equal physical size within group, adds intra_group_scalar group_hires_scalef columns sample_info. intra_group_scalar gives scalar given capture area's tissue_hires_image.png image pixel coordinates must multiplied match scale group members; group_hires_scalef gives new tissue_hires_scalef (SpaceRanger's scalefactors_json.json file) appropriate every capture area group.","code":""},{"path":"/reference/rescale_fiji_inputs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Write same-scale hires images for input to Fiji — rescale_fiji_inputs","text":"","code":"rescale_fiji_inputs(sample_info, out_dir)"},{"path":"/reference/rescale_fiji_inputs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Write same-scale hires images for input to Fiji — rescale_fiji_inputs","text":"sample_info data.frame() columns capture_area, group, fiji_xml_path, fiji_image_path, spaceranger_dir, intra_group_scalar, group_hires_scalef. last two made rescale_fiji_inputs(). out_dir character(1) vector giving path directory place output images, must exist advance.","code":""},{"path":"/reference/rescale_fiji_inputs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Write same-scale hires images for input to Fiji — rescale_fiji_inputs","text":"tibble: copy sample_info additional columns intra_group_scalar group_hires_scalef.","code":""},{"path":"/reference/rescale_fiji_inputs.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Write same-scale hires images for input to Fiji — rescale_fiji_inputs","text":"Nicholas J. Eagles","code":""},{"path":"/reference/rescale_fiji_inputs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Write same-scale hires images for input to Fiji — rescale_fiji_inputs","text":"","code":"# Define sample information for the example human brain data sample_info <- dplyr::tibble( group = \"Br2719\", capture_area = c(\"V13B23-283_A1\", \"V13B23-283_C1\", \"V13B23-283_D1\") ) # Add 'spaceranger_dir' column sr_dir <- tempdir() temp <- unzip( spatialLIBD::fetch_data(\"visiumStitched_brain_spaceranger\"), exdir = sr_dir ) #> 2024-10-18 14:29:08.020056 loading file /github/home/.cache/R/BiocFileCache/2573560f3ca_visiumStitched_brain_spaceranger.zip%3Frlkey%3Dbdgjc6mgy1ierdad6h6v5g29c%26dl%3D1 sample_info$spaceranger_dir <- file.path( sr_dir, sample_info$capture_area, \"outs\", \"spatial\" ) # Add Fiji-output-related columns fiji_dir <- tempdir() temp <- unzip( spatialLIBD::fetch_data(\"visiumStitched_brain_Fiji_out\"), exdir = fiji_dir ) #> 2024-10-18 14:29:10.552356 loading file /github/home/.cache/R/BiocFileCache/257305c881d_visiumStitched_brain_fiji_out.zip%3Frlkey%3Dptwal8f5zxakzejwd0oqw0lhj%26dl%3D1 sample_info$fiji_xml_path <- temp[grep(\"xml$\", temp)] sample_info$fiji_image_path <- temp[grep(\"png$\", temp)] ## Re-size images and add more information to the sample_info out_dir <- tempdir() sample_info_new <- rescale_fiji_inputs(sample_info, out_dir = out_dir) # Scale factors are computed that are necessary downstream (i.e. with # prep_fiji_*() functions) sample_info_new[, setdiff(colnames(sample_info_new), colnames(sample_info))] #> # A tibble: 3 × 2 #> intra_group_scalar group_hires_scalef #> #> 1 1.00 0.0825 #> 2 1.00 0.0825 #> 3 1 0.0825 # Image are produced that are ready for alignment in Fiji list.files(out_dir) #> [1] \"Br2719\" #> [2] \"Br2719.png\" #> [3] \"Br2719.xml\" #> [4] \"HDF5Array_dataset_creation_global_counter\" #> [5] \"HDF5Array_dump\" #> [6] \"HDF5Array_dump_log\" #> [7] \"HDF5Array_dump_names_global_counter\" #> [8] \"V13B23-283_A1\" #> [9] \"V13B23-283_A1.png\" #> [10] \"V13B23-283_C1\" #> [11] \"V13B23-283_C1.png\" #> [12] \"V13B23-283_D1\" #> [13] \"V13B23-283_D1.png\" #> [14] \"bslib-055181530015cbb2d59664d57848f4cd\" #> [15] \"downlit\" #> [16] \"file311f105977a1\" #> [17] \"file311f10ed7cca\" #> [18] \"file311f233522c9\" #> [19] \"file311f3e05378d\" #> [20] \"file311f587b9d39\" #> [21] \"file311f6e0910d\" #> [22] \"sample_info.rds\""},{"path":"/news/index.html","id":"visiumstitched-0990","dir":"Changelog","previous_headings":"","what":"visiumStitched 0.99.0","title":"visiumStitched 0.99.0","text":"NEW FEATURES Initial version visiumStiched package provides utilities stitching together Visium capture areas enables seamless downstream spatially-aware clustering methods identify clusters stitched data. example postmortem human brain dataset composed 3 Visium capture areas generated demonstrate utility visiumStitched. dataset available spatiaLIBD::fetch_data() version 1.17.8 newer. example data described https://research.libd.org/visiumStitched_brain/.","code":""}]
+[{"path":"/CONTRIBUTING.html","id":null,"dir":"","previous_headings":"","what":"Contributing to visiumStitched","title":"Contributing to visiumStitched","text":"outlines propose change visiumStitched. detailed discussion contributing tidyverse packages, please see development contributing guide code review principles.","code":""},{"path":"/CONTRIBUTING.html","id":"fixing-typos","dir":"","previous_headings":"","what":"Fixing typos","title":"Contributing to visiumStitched","text":"can fix typos, spelling mistakes, grammatical errors documentation directly using GitHub web interface, long changes made source file. generally means ’ll need edit roxygen2 comments .R, .Rd file. can find .R file generates .Rd reading comment first line.","code":""},{"path":"/CONTRIBUTING.html","id":"bigger-changes","dir":"","previous_headings":"","what":"Bigger changes","title":"Contributing to visiumStitched","text":"want make bigger change, ’s good idea first file issue make sure someone team agrees ’s needed. ’ve found bug, please file issue illustrates bug minimal reprex (also help write unit test, needed). See guide create great issue advice.","code":""},{"path":"/CONTRIBUTING.html","id":"pull-request-process","dir":"","previous_headings":"Bigger changes","what":"Pull request process","title":"Contributing to visiumStitched","text":"Fork package clone onto computer. haven’t done , recommend using usethis::create_from_github(\"LieberInstitute/visiumStitched\", fork = TRUE). Install development dependencies devtools::install_dev_deps(), make sure package passes R CMD check running devtools::check(). R CMD check doesn’t pass cleanly, ’s good idea ask help continuing. Create Git branch pull request (PR). recommend using usethis::pr_init(\"brief-description--change\"). Make changes, commit git, create PR running usethis::pr_push(), following prompts browser. title PR briefly describe change. body PR contain Fixes #issue-number. user-facing changes, add bullet top NEWS.md (.e. just first header). Follow style described https://style.tidyverse.org/news.html.","code":""},{"path":"/CONTRIBUTING.html","id":"code-style","dir":"","previous_headings":"Bigger changes","what":"Code style","title":"Contributing to visiumStitched","text":"New code follow tidyverse style guide. can use styler package apply styles, please don’t restyle code nothing PR. use roxygen2, Markdown syntax, documentation. use testthat unit tests. Contributions test cases included easier accept.","code":""},{"path":"/CONTRIBUTING.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Contributing to visiumStitched","text":"Please note visiumStitched project released Contributor Code Conduct. contributing project agree abide terms.","code":""},{"path":"/SUPPORT.html","id":null,"dir":"","previous_headings":"","what":"Getting help with visiumStitched","title":"Getting help with visiumStitched","text":"Thank using visiumStitched! filing issue, things know make process smooth possible parties.","code":""},{"path":"/SUPPORT.html","id":"make-a-reprex","dir":"","previous_headings":"","what":"Make a reprex","title":"Getting help with visiumStitched","text":"Start making minimally reproducible example, also known ‘reprex’. may use reprex R package create one, though necessary help. make R-question-asking endeavors easier. Learning use takes 5 10 minutes. tips make minimally reproducible example, see StackOverflow link.","code":""},{"path":"/SUPPORT.html","id":"where-to-post-it","dir":"","previous_headings":"","what":"Where to post it?","title":"Getting help with visiumStitched","text":"Bioconductor help web page gives overview places may help answer question. Bioconductor software related questions, bug reports feature requests, addressed appropriate Bioconductor/visiumStitched GitHub repository. Follow bug report feature request templates GitHub. package GitHub repository, see next bullet point. Bioconductor software usage questions addressed Bioconductor Support Website. Make sure use appropriate package tag, otherwise package authors get notification. General R questions can posed StackOverflow RStudio Community website especially pertain tidyverse RStudio GUI related products.","code":""},{"path":"/SUPPORT.html","id":"issues-or-feature-requests","dir":"","previous_headings":"","what":"Issues or Feature Requests","title":"Getting help with visiumStitched","text":"opening new issue feature request, sure search issues pull requests ensure one already exist implemented development version. Note. can remove :open search term issues page search open closed issues. See link learn modifying search.","code":""},{"path":"/SUPPORT.html","id":"what-happens-next","dir":"","previous_headings":"","what":"What happens next?","title":"Getting help with visiumStitched","text":"Bioconductor maintainers limited resources strive responsive possible. Please forget tag appropriate maintainer issue GitHub username (e.g., @username). order make easy possible Bioconductor core developers remediate issue. Provide accurate, brief, reproducible report outlined issue templates. Thank trusting Bioconductor.","code":""},{"path":"/articles/misc.html","id":"load-data","dir":"Articles","previous_headings":"","what":"Load data","title":"Miscellaneous notes","text":"Let’s load spatialLIBD package ’ll use vignette. Now can download example visiumStitched_brain data includes normalized logcounts. ’ll define example white matter marker genes.","code":"library(\"spatialLIBD\") ## Grab SpatialExperiment with normalized counts spe <- fetch_data(type = \"visiumStitched_brain_spe\") #> 2024-10-24 20:17:16.494094 loading file /github/home/.cache/R/BiocFileCache/760d7e2c6_visiumStitched_brain_spe.rds%3Frlkey%3Dnq6a82u23xuu9hohr86oodwdi%26dl%3D1 ## Check that spe does contain the \"logcounts\" assay assayNames(spe) #> [1] \"counts\" \"logcounts\" ## Define white matter marker genes wm_genes <- rownames(spe)[ match(c(\"MBP\", \"GFAP\", \"PLP1\", \"AQP4\"), rowData(spe)$gene_name) ]"},{"path":"/articles/misc.html","id":"geometric-transformations-notes","dir":"Articles","previous_headings":"","what":"Geometric transformations notes","title":"Miscellaneous notes","text":"SpatialExperiment, stitched data constructed visiumStitched::build_SpatialExperiment() may need rotated mirrored group. can done using SpatialExperiment::rotateObject() SpatialExperiment::mirrorObject() functions. functions useful case image needs transformed reach preferred tissue orientation. might want re-make plots spatial = TRUE can see histology image gets rotated /mirrored. file size purposes vignette, use spatial = FALSE.","code":"## Rotate image and gene-expression data by 180 degrees, plotting a combination ## of white-matter genes vis_gene( rotateObject(spe, sample_id = \"Br2719\", degrees = 180), geneid = wm_genes, assayname = \"counts\", is_stitched = TRUE, spatial = FALSE ) ## Mirror image and gene-expression data across a vertical axis, plotting a ## combination of white-matter genes vis_gene( mirrorObject(spe, sample_id = \"Br2719\", axis = \"v\"), geneid = wm_genes, assayname = \"counts\", is_stitched = TRUE, spatial = FALSE )"},{"path":"/articles/misc.html","id":"a-note-on-normalization","dir":"Articles","previous_headings":"Geometric transformations notes","what":"A note on normalization","title":"Miscellaneous notes","text":"noted main vignette, library-size variation across spots can bias apparent spatial distribution genes raw counts used. effect often dramatic enough spatial trends easily seen across stitched data data log-normalized. Instead performing normalization , ’ll fetch object normalized counts spatialLIBD, plot white matter genes : Recall unnormalized version plot, nearly clean: actual normalization code example data available .","code":"## Plot combination of normalized counts for some white-matter genes vis_gene( spe, geneid = wm_genes, assayname = \"logcounts\", is_stitched = TRUE, spatial = FALSE ) ## Plot raw counts, which are noisier ## Same plot we made before, but this time with no histology images vis_gene( spe, geneid = wm_genes, assayname = \"counts\", is_stitched = TRUE, spatial = FALSE )"},{"path":"/articles/misc.html","id":"merging-overlapping-spots","dir":"Articles","previous_headings":"","what":"Merging overlapping spots","title":"Miscellaneous notes","text":"general, recommend retaining spots downstream analysis, even means including multiple spots per array coordinate. show many software tools, BayesSpace PRECAST, can smoothly handle data format. However, given multiple spots array coordinates atypical Visium experiments, caution ’s possible software may break perform intended stitched data. provide merge_overlapping() function address case. particular, merge_overlapping() sums raw counts across spots overlap, ultimately producing SpatialExperiment one spot per array coordinate. colData() information, discrete continuous, taken spots exclude_overlapping FALSE. Note function can quite memory-intensive time-consuming.","code":"spe_merged <- merge_overlapping(spe)"},{"path":[]},{"path":"/articles/visiumStitched.html","id":"install-visiumstitched","dir":"Articles","previous_headings":"Basics","what":"Install visiumStitched","title":"Introduction to visiumStitched","text":"visiumStitched Bioconductor R package can installed following commands R session:","code":"if (!requireNamespace(\"BiocManager\", quietly = TRUE)) { install.packages(\"BiocManager\") } BiocManager::install(\"visiumStitched\")"},{"path":"/articles/visiumStitched.html","id":"citing-visiumstitched","dir":"Articles","previous_headings":"Basics","what":"Citing visiumStitched","title":"Introduction to visiumStitched","text":"hope visiumStitched useful research. Please use following information cite package overall approach. Thank !","code":"## Citation info citation(\"visiumStitched\") #> To cite package 'visiumStitched' in publications use: #> #> Eagles NJ, Collado-Torres L (2024). _Enable downstream analysis of #> Visium capture areas stitched together with Fiji_. #> doi:10.18129/B9.bioc.visiumStitched #> , #> https://github.com/LieberInstitute/visiumStitched/visiumStitched - R #> package version 0.99.12, #> . #> #> Eagles NJ, Bach S, Tippani M, Ravichandran P, Du Y, Miller RA, Hyde #> TM, Page SC, Martinowich K, Collado-Torres L (2024). #> \"visiumStitched.\" _bioRxiv_. doi:10.1101/TODO #> , #> . #> #> To see these entries in BibTeX format, use 'print(, #> bibtex=TRUE)', 'toBibtex(.)', or set #> 'options(citation.bibtex.max=999)'."},{"path":"/articles/visiumStitched.html","id":"packages-used-in-this-vignette","dir":"Articles","previous_headings":"Basics","what":"Packages used in this vignette","title":"Introduction to visiumStitched","text":"Let’s load packages ’ll use vignette.","code":"library(\"SpatialExperiment\") library(\"visiumStitched\") library(\"dplyr\") library(\"spatialLIBD\") library(\"BiocFileCache\") library(\"ggplot2\")"},{"path":"/articles/visiumStitched.html","id":"preparing-experiment-information","dir":"Articles","previous_headings":"","what":"Preparing Experiment Information","title":"Introduction to visiumStitched","text":"Much visiumStitched package uses tibble (data.frame) defining information experiment. fundamentally, group column allows line capture areas, capture_area column, stitched together later. case, just one unique group, consisting three capture areas. Note multiple groups supported. end demo, SpatialExperiment consist just one sample composed three capture areas; general, one sample per group. Next, ’ll need Spaceranger outputs capture area, can retrieved spatialLIBD::fetch_data().","code":"## Create initial sample_info sample_info <- data.frame( group = \"Br2719\", capture_area = c(\"V13B23-283_A1\", \"V13B23-283_C1\", \"V13B23-283_D1\") ) ## Initial sample_info sample_info #> group capture_area #> 1 Br2719 V13B23-283_A1 #> 2 Br2719 V13B23-283_C1 #> 3 Br2719 V13B23-283_D1 ## Download example SpaceRanger output files sr_dir <- tempdir() temp <- unzip(spatialLIBD::fetch_data(\"visiumStitched_brain_spaceranger\"), exdir = sr_dir ) #> 2024-10-24 20:17:42.34181 loading file /github/home/.cache/R/BiocFileCache/7603a007f35_visiumStitched_brain_spaceranger.zip%3Frlkey%3Dbdgjc6mgy1ierdad6h6v5g29c%26dl%3D1 sample_info$spaceranger_dir <- file.path( sr_dir, sample_info$capture_area, \"outs\", \"spatial\" ) ## Sample_info with paths to SpaceRanger output directories sample_info #> group capture_area spaceranger_dir #> 1 Br2719 V13B23-283_A1 /tmp/RtmpV5W4lk/V13B23-283_A1/outs/spatial #> 2 Br2719 V13B23-283_C1 /tmp/RtmpV5W4lk/V13B23-283_C1/outs/spatial #> 3 Br2719 V13B23-283_D1 /tmp/RtmpV5W4lk/V13B23-283_D1/outs/spatial"},{"path":"/articles/visiumStitched.html","id":"preparing-inputs-to-fiji","dir":"Articles","previous_headings":"","what":"Preparing Inputs to Fiji","title":"Introduction to visiumStitched","text":"visiumStitched workflow makes use Fiji, distribution ImageJ image-processing software, includes interface aligning images shared coordinate system. aligning anything Fiji, need ensure images align capture areas scale– , pixel image represents distance. typically approximately true, guaranteed exactly true, especially capture areas align come different Visium slides. rescale_fiji_inputs() reads high-resolution tissue images capture area, uses info spot diameters pixels scale factors rescale images appropriately (even different Visium slides). demonstration purposes, ’ll set out_dir temporary location. Typically, really suitable directory place rescaled images later input Fiji.","code":"# Generate rescaled approximately high-resolution images sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir()) ## Sample_info with output directories sample_info #> # A tibble: 3 × 5 #> group capture_area spaceranger_dir intra_group_scalar group_hires_scalef #> #> 1 Br2719 V13B23-283_A1 /tmp/RtmpV5W4lk/V1… 1.00 0.0825 #> 2 Br2719 V13B23-283_C1 /tmp/RtmpV5W4lk/V1… 1.00 0.0825 #> 3 Br2719 V13B23-283_D1 /tmp/RtmpV5W4lk/V1… 1 0.0825"},{"path":[]},{"path":"/articles/visiumStitched.html","id":"stitching-images-with-fiji","dir":"Articles","previous_headings":"Building a SpatialExperiment","what":"Stitching Images with Fiji","title":"Introduction to visiumStitched","text":"building SpatialExperiment stitched dataset, must align images group Fiji. Check video guide process example data.","code":""},{"path":"/articles/visiumStitched.html","id":"creating-group-level-samples","dir":"Articles","previous_headings":"Building a SpatialExperiment","what":"Creating Group-Level Samples","title":"Introduction to visiumStitched","text":"Fiji alignment, two output files produced: XML file specifying rigid affine transformations capture area, stitched approximately high-resolution image. files dataset available spatialLIBD::fetch_data(). ’ll need add paths XML PNG files fiji_xml_path fiji_image_path columns sample_info, respectively. now every column present sample_info necessary visiumStitched function. building SpatialExperiment, idea create directory structure similar Spaceranger’s spatial outputs group, opposed capture-area-level directories already . ’ll place directory temporary location later read produce final SpatialExperiment. First, prep_fiji_coords() apply rigid affine transformations specified Fiji’s output XML file spatial coordinates, ultimately producing group-level tissue_positions.csv file. Next, prep_fiji_image() rescale stitched image default 1,200 pixels longest dimension. idea experiment multiple groups, images stored SpatialExperiment group similarly scaled occupy similar memory footprints.","code":"fiji_dir <- tempdir() temp <- unzip(fetch_data(\"visiumStitched_brain_Fiji_out\"), exdir = fiji_dir) #> 2024-10-24 20:17:55.9535 loading file /github/home/.cache/R/BiocFileCache/76048672d76_visiumStitched_brain_fiji_out.zip%3Frlkey%3Dptwal8f5zxakzejwd0oqw0lhj%26dl%3D1 sample_info$fiji_xml_path <- temp[grep(\"xml$\", temp)] sample_info$fiji_image_path <- temp[grep(\"png$\", temp)] ## Complete sample_info sample_info #> # A tibble: 3 × 7 #> group capture_area spaceranger_dir intra_group_scalar group_hires_scalef #> #> 1 Br2719 V13B23-283_A1 /tmp/RtmpV5W4lk/V1… 1.00 0.0825 #> 2 Br2719 V13B23-283_C1 /tmp/RtmpV5W4lk/V1… 1.00 0.0825 #> 3 Br2719 V13B23-283_D1 /tmp/RtmpV5W4lk/V1… 1 0.0825 #> # ℹ 2 more variables: fiji_xml_path , fiji_image_path ## Prepare the Fiji coordinates and images. ## These functions return the file paths to the newly-created files that follow ## the standard directory structure from SpaceRanger (10x Genomics) spe_input_dir <- tempdir() prep_fiji_coords(sample_info, out_dir = spe_input_dir) #> [1] \"/tmp/RtmpV5W4lk/Br2719/tissue_positions.csv\" prep_fiji_image(sample_info, out_dir = spe_input_dir) #> [1] \"/tmp/RtmpV5W4lk/Br2719/tissue_lowres_image.png\" #> [2] \"/tmp/RtmpV5W4lk/Br2719/scalefactors_json.json\""},{"path":"/articles/visiumStitched.html","id":"constructing-the-object","dir":"Articles","previous_headings":"Building a SpatialExperiment","what":"Constructing the Object","title":"Introduction to visiumStitched","text":"now pieces create SpatialExperiment object. constructing base object, information related spots may overlap capture areas group added. sum_umi metric default determine spots overlapping regions exclude plots. particular, regions overlap, spots capture areas higher average UMI (unique molecular identifier) counts plotted, spots shown using spatialLIBD::vis_clus(), spatialLIBD::vis_gene(), related visualization functions. ’ll also mirror image gene-expression data match orientation specified wet bench. info performing geometric transformations . colData(spe)$exclude_overlapping column controls spots drop visualization purposes. Note also overlap_key column added, gives comma-separated string spot keys overlapping given spot, empty string otherwise. spatial clustering, overlap_key information can useful check frequently overlapping spots assigned cluster.","code":"## Download the Gencode v32 GTF file which is the closest one to the one ## that was used with SpaceRanger. Note that SpaceRanger GTFs are available at ## https://cf.10xgenomics.com/supp/cell-exp/refdata-gex-GRCh38-2024-A.tar.gz ## but is too large for us to download here since it includes many other files ## we don't need right now. ## However, ideally you would adapt this code and use the actual GTF file you ## used when running SpaceRanger. bfc <- BiocFileCache::BiocFileCache() gtf_cache <- bfcrpath( bfc, paste0( \"ftp://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/\", \"release_32/gencode.v32.annotation.gtf.gz\" ) ) ## Now we can build the SpatialExperiment object. We'll later explore error ## metrics related to computing new array coordinates, and thus specify ## 'calc_error_metrics = TRUE'. spe <- build_SpatialExperiment( sample_info, coords_dir = spe_input_dir, reference_gtf = gtf_cache, calc_error_metrics = TRUE ) #> Building SpatialExperiment using capture area as sample ID #> 2024-10-24 20:17:59.027873 SpatialExperiment::read10xVisium: reading basic data from SpaceRanger #> 2024-10-24 20:18:05.856143 read10xVisiumAnalysis: reading analysis output from SpaceRanger #> 2024-10-24 20:18:06.240782 add10xVisiumAnalysis: adding analysis output from SpaceRanger #> 2024-10-24 20:18:06.590185 rtracklayer::import: reading the reference GTF file #> 2024-10-24 20:18:37.255172 adding gene information to the SPE object #> Warning: Gene IDs did not match. This typically happens when you are not using #> the same GTF file as the one that was used by SpaceRanger. For example, one #> file uses GENCODE IDs and the other one ENSEMBL IDs. read10xVisiumWrapper() #> will try to convert them to ENSEMBL IDs. #> Warning: Dropping 2226 out of 38606 genes for which we don't have information #> on the reference GTF file. This typically happens when you are not using the #> same GTF file as the one that was used by SpaceRanger. #> 2024-10-24 20:18:37.485096 adding information used by spatialLIBD #> Overwriting imgData(spe) with merged images (one per group) #> Adding array coordinates with error metrics and adding overlap info ## The images in this example data have to be mirrored across the horizontal axis. spe <- SpatialExperiment::mirrorObject(spe, axis = \"h\") ## Explore stitched spe object spe #> class: SpatialExperiment #> dim: 36380 14976 #> metadata(0): #> assays(1): counts #> rownames(36380): ENSG00000243485.5 ENSG00000237613.2 ... #> ENSG00000198695.2 ENSG00000198727.2 #> rowData names(6): source type ... gene_type gene_search #> colnames(14976): AAACAACGAATAGTTC-1_V13B23-283_A1 #> AAACAAGTATCTCCCA-1_V13B23-283_A1 ... TTGTTTGTATTACACG-1_V13B23-283_D1 #> TTGTTTGTGTAAATTC-1_V13B23-283_D1 #> colData names(33): sample_id in_tissue ... overlap_key #> exclude_overlapping #> reducedDimNames(0): #> mainExpName: NULL #> altExpNames(0): #> spatialCoords names(2) : pxl_col_in_fullres pxl_row_in_fullres #> imgData names(4): sample_id image_id data scaleFactor ## Examine spots to exclude for plotting table(spe$exclude_overlapping) #> #> FALSE TRUE #> 13426 1550"},{"path":[]},{"path":"/articles/visiumStitched.html","id":"stitched-plotting","dir":"Articles","previous_headings":"Examining the stitched data","what":"Stitched plotting","title":"Introduction to visiumStitched","text":"demonstrate ’ve stitched gene expression image data successfully, ’ll use spatialLIBD::vis_gene(is_stitched = TRUE) (version 1.17.8 newer) plot distribution white matter spatially. context human brain white matter spatial marker genes, check previous work subject. Note ’re plotting raw counts; prior normalization, library-size variation across spots can bias apparent distribution. Later, ’ll show normalization critical producing visually seamless transition overlapping capture areas.","code":"## Show combined raw expression of white-matter marker genes wm_genes <- rownames(spe)[ match(c(\"MBP\", \"GFAP\", \"PLP1\", \"AQP4\"), rowData(spe)$gene_name) ] vis_gene(spe, geneid = wm_genes, assayname = \"counts\", is_stitched = TRUE)"},{"path":"/articles/visiumStitched.html","id":"defining-array-coordinates","dir":"Articles","previous_headings":"Examining the stitched data","what":"Defining Array Coordinates","title":"Introduction to visiumStitched","text":"Given stitched data larger default Visium capture area, add_array_coords() (used internally build_SpatialExperiment()) recomputed array coordinates (.e. spe$array_row spe$array_col) sensibly index stitched data. Let’s explain detail. definition, array coordinates (see documentation 10X) integer indices spot Visium capture area, numbering typically 78 128 rows columns, respectively, 6.5mm capture area. build_SpatialExperiment() function retains capture area’s original array coordinates, spe$array_row_original spe$array_col_original, typically useful represent group-level, stitched data. fact, stitched capture area exact array coordinates, despite different spatial positions stitching. ’ll take -tissue spots use transparency emphasize overlap among capture areas: Let’s contrast array coordinates recomputed visiumStitched. Briefly, visiumStitched forms new hexagonal, Visium-like grid spanning space occupied capture areas stitching. , true spot positions fit nearest new spot positions, terms Euclidean distance. Finally, array coordinates re-indexed according new spot assignments, resulting spatially meaningful values apply group level stitched data. important downstream application array coordinates, enables methods rely hexagonal grid structure Visium find original six neighboring spots. enables clustering BayesSpace PRECAST, treat group spatially continuous sample. can see BayesSpace:::.find_neighbors() version 1.11.0 uses hexagonal Visium grid properties find spot neighbors. See also BayesSpace Figure 1b illustration process. Yet, doesn’t matter actually two spots six neighbor positions. visiumStitched takes advantage property enable BayesSpace spatially-aware clustering methods use data overlapping spots performing spatial clustering. can use colData(spe)$overlap_key inspect whether overlapping spots assigned spatial cluster.","code":"## Plot positions of default array coordinates, before overwriting with more ## meaningful values. Use custom colors for each capture area ca_colors <- c(\"#A33B20\", \"#e7bb41\", \"#3d3b8e\") names(ca_colors) <- c(\"V13B23-283_C1\", \"V13B23-283_D1\", \"V13B23-283_A1\") colData(spe) |> as_tibble() |> filter(in_tissue) |> ggplot( mapping = aes( x = array_row_original, y = array_col_original, color = capture_area ) ) + geom_point(alpha = 0.3) + scale_color_manual(values = ca_colors) ## Plot positions of redefined array coordinates colData(spe) |> as_tibble() |> filter(in_tissue) |> ggplot( mapping = aes( x = array_row, y = array_col, color = capture_area ) ) + geom_point(alpha = 0.3) + scale_color_manual(values = ca_colors)"},{"path":"/articles/visiumStitched.html","id":"error-metrics","dir":"Articles","previous_headings":"Examining the stitched data > Defining Array Coordinates","what":"Error metrics","title":"Introduction to visiumStitched","text":"algorithm can fit set capture areas’ spots onto single hexagonal grid without error. , define spot’s error assigned new array coordinates two independent metrics, stored spe$euclidean_error spe$shared_neighbors user opts compute build_SpatialExperiment(calc_error_metrics = TRUE). latter metric can take couple minutes compute, thus default metrics computed. first metric Euclidean distance, multiples 100 microns (distance spots Visium capture area), spot’s original position position assigned array coordinates. metric, spe$shared_neighbors, measures fraction original neighbors (capture area) retained mapping new array coordinates. Thus, value 1 ideal. theory, error measured metrics slight impact quality clustering results downstream. envision interested users checking metrics interpreting specific spots’ cluster assignments downstream.","code":"# Explore the distribution of Euclidean error colData(spe) |> as_tibble() |> ggplot(mapping = aes(x = 0, y = euclidean_error)) + geom_boxplot() # Explore the distribution of Euclidean error colData(spe) |> as_tibble() |> ggplot(mapping = aes(x = 0, y = shared_neighbors)) + geom_boxplot()"},{"path":"/articles/visiumStitched.html","id":"downstream-applications","dir":"Articles","previous_headings":"","what":"Downstream applications","title":"Introduction to visiumStitched","text":"One common area analysis spatial transcriptomics involves clustering– particular, spatially-aware clustering. Many spatially-aware clustering algorithms check array coordinates determine neighboring spots ultimately produce spatially smooth clusters. previously explained, visiumStitched re-computes array coordinates meaningful way, software like BayesSpace PRECAST work ---box stitched data, treating group single continuous sample. ’ve already run PRECAST, can visualize results , see fairly seamless transition cluster assignments across capture-area boundaries. First, let’s examine k = 2: can see two spatial clusters differentiating white vs gray matter based white matter marker genes previously visualized. example data, k = 4 k = 8 also computed. Let’s visualize k = 4 results. biological interpretation spatial clusters need work, using methods : spatial registration reference sc/snRNA-seq spatial data, visualization known marker genes tissue interest, identification data driven marker genes using spatialLIBD::registration_wrapper(), DeconvoBuddies::findMarkers_1vAll(), DeconvoBuiddies::get_mean_ratio() tools. See Pullin McCarthy, Genome Biol., 2024 list marker gene selection methods.","code":"## Grab SpatialExperiment with normalized counts spe_norm <- fetch_data(type = \"visiumStitched_brain_spe\") #> 2024-10-24 20:19:53.190345 loading file /github/home/.cache/R/BiocFileCache/760d7e2c6_visiumStitched_brain_spe.rds%3Frlkey%3Dnq6a82u23xuu9hohr86oodwdi%26dl%3D1 assayNames(spe_norm) #> [1] \"counts\" \"logcounts\" ## PRECAST k = 2 clusters with our manually chosen colors vis_clus( spe_norm, clustervar = \"precast_k2_stitched\", is_stitched = TRUE, colors = c( \"1\" = \"gold\", \"2\" = \"darkblue\", \"NA\" = \"white\" ), spatial = FALSE ) ## PRECAST results already available in this example data vars <- colnames(colData(spe_norm)) vars[grep(\"precast\", vars)] #> [1] \"precast_k2_stitched\" \"precast_k4_stitched\" \"precast_k8_stitched\" #> [4] \"precast_k16_stitched\" \"precast_k24_stitched\" \"precast_k2_unstitched\" #> [7] \"precast_k4_unstitched\" \"precast_k8_unstitched\" \"precast_k16_unstitched\" #> [10] \"precast_k24_unstitched\" ## PRECAST k = 4 clusters with default cluster colors vis_clus( spe_norm, clustervar = \"precast_k4_stitched\", is_stitched = TRUE, spatial = FALSE )"},{"path":"/articles/visiumStitched.html","id":"conclusion","dir":"Articles","previous_headings":"","what":"Conclusion","title":"Introduction to visiumStitched","text":"visiumStitched provides set helper functions, conjunction ImageJ/Fiji, intended simplify stitching Visium data spatially integrated SpatialExperiment object ready analysis. hope find useful research!","code":""},{"path":"/articles/visiumStitched.html","id":"reproducibility","dir":"Articles","previous_headings":"","what":"Reproducibility","title":"Introduction to visiumStitched","text":"visiumStitched package (Eagles Collado-Torres, 2024) made possible thanks : R (R Core Team, 2024) BiocFileCache (Shepherd Morgan, 2024) BiocStyle (Oleś, 2024) dplyr (Wickham, François, Henry, Müller, Vaughan, 2023) DropletUtils (Lun, Riesenfeld, Andrews, Dao, Gomes, participants 1st Human Cell Atlas Jamboree, Marioni, 2019) ggplot2 (Wickham, 2016) imager (Barthelme, 2024) knitr (Xie, 2024) pkgcond (Redd R Documentation Task Force, 2021) RefManageR (McLean, 2017) rjson (Couture-Beil, 2024) rmarkdown (Allaire, Xie, Dervieux, McPherson, Luraschi, Ushey, Atkins, Wickham, Cheng, Chang, Iannone, 2024) S4Vectors (Pagès, Lawrence, Aboyoun, 2024) sessioninfo (Wickham, Chang, Flight, Müller, Hester, 2021) Seurat (Hao, Stuart, Kowalski, Choudhary, Hoffman, Hartman, Srivastava, Molla, Madad, Fernandez-Granda, Satija, 2023) SpatialExperiment (Righelli, Weber, Crowell, Pardo, Collado-Torres, Ghazanfar, Lun, Hicks, Risso, 2022) spatialLIBD (Pardo, Spangler, Weber, Hicks, Jaffe, Martinowich, Maynard, Collado-Torres, 2022) stringr (Wickham, 2023) SummarizedExperiment (Morgan, Obenchain, Hester, Pagès, 2024) testthat (Wickham, 2011) xml2 (Wickham, Hester, Ooms, 2023) package developed using biocthis. Code creating vignette R session information.","code":"## Create the vignette library(\"rmarkdown\") system.time(render(\"visiumStitched.Rmd\", \"BiocStyle::html_document\")) ## Extract the R code library(\"knitr\") knit(\"visiumStitched.Rmd\", tangle = TRUE) #> ─ Session info ─────────────────────────────────────────────────────────────────────────────────────────────────────── #> setting value #> version R version 4.4.1 (2024-06-14) #> os Ubuntu 22.04.5 LTS #> system x86_64, linux-gnu #> ui X11 #> language en #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz UTC #> date 2024-10-24 #> pandoc 3.4 @ /usr/bin/ (via rmarkdown) #> #> ─ Packages ─────────────────────────────────────────────────────────────────────────────────────────────────────────── #> package * version date (UTC) lib source #> abind 1.4-8 2024-09-12 [1] RSPM (R 4.4.0) #> AnnotationDbi 1.67.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> AnnotationHub 3.13.3 2024-08-19 [1] Bioconductor 3.20 (R 4.4.1) #> attempt 0.3.1 2020-05-03 [1] RSPM (R 4.4.0) #> backports 1.5.0 2024-05-23 [1] RSPM (R 4.4.0) #> beachmat 2.21.8 2024-10-21 [1] Bioconductor 3.20 (R 4.4.1) #> beeswarm 0.4.0 2021-06-01 [1] RSPM (R 4.4.0) #> benchmarkme 1.0.8 2022-06-12 [1] RSPM (R 4.4.0) #> benchmarkmeData 1.0.4 2020-04-23 [1] RSPM (R 4.4.0) #> bibtex 0.5.1 2023-01-26 [1] RSPM (R 4.4.0) #> Biobase * 2.65.1 2024-08-28 [1] Bioconductor 3.20 (R 4.4.1) #> BiocBaseUtils 1.7.3 2024-08-29 [1] Bioconductor 3.20 (R 4.4.1) #> BiocFileCache * 2.13.2 2024-10-11 [1] Bioconductor 3.20 (R 4.4.1) #> BiocGenerics * 0.51.3 2024-10-02 [1] Bioconductor 3.20 (R 4.4.1) #> BiocIO 1.15.2 2024-08-23 [1] Bioconductor 3.20 (R 4.4.1) #> BiocManager 1.30.25 2024-08-28 [2] CRAN (R 4.4.1) #> BiocNeighbors 1.99.3 2024-10-21 [1] Bioconductor 3.20 (R 4.4.1) #> BiocParallel 1.39.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> BiocSingular 1.21.4 2024-09-22 [1] Bioconductor 3.20 (R 4.4.1) #> BiocStyle * 2.33.1 2024-06-12 [1] Bioconductor 3.20 (R 4.4.0) #> BiocVersion 3.20.0 2024-05-01 [2] Bioconductor 3.20 (R 4.4.1) #> Biostrings 2.73.2 2024-09-26 [1] Bioconductor 3.20 (R 4.4.1) #> bit 4.5.0 2024-09-20 [1] RSPM (R 4.4.0) #> bit64 4.5.2 2024-09-22 [1] RSPM (R 4.4.0) #> bitops 1.0-9 2024-10-03 [1] RSPM (R 4.4.0) #> blob 1.2.4 2023-03-17 [1] RSPM (R 4.4.0) #> bmp 0.3 2017-09-11 [1] RSPM (R 4.4.0) #> bookdown 0.41 2024-10-16 [1] RSPM (R 4.4.0) #> bslib 0.8.0 2024-07-29 [2] RSPM (R 4.4.0) #> cachem 1.1.0 2024-05-16 [2] RSPM (R 4.4.0) #> cli 3.6.3 2024-06-21 [2] RSPM (R 4.4.0) #> codetools 0.2-20 2024-03-31 [3] CRAN (R 4.4.1) #> colorspace 2.1-1 2024-07-26 [1] RSPM (R 4.4.0) #> config 0.3.2 2023-08-30 [1] RSPM (R 4.4.0) #> cowplot 1.1.3 2024-01-22 [1] RSPM (R 4.4.0) #> crayon 1.5.3 2024-06-20 [2] RSPM (R 4.4.0) #> curl 5.2.3 2024-09-20 [2] RSPM (R 4.4.0) #> data.table 1.16.2 2024-10-10 [1] RSPM (R 4.4.0) #> DBI 1.2.3 2024-06-02 [1] RSPM (R 4.4.0) #> dbplyr * 2.5.0 2024-03-19 [1] RSPM (R 4.4.0) #> DelayedArray 0.31.14 2024-10-03 [1] Bioconductor 3.20 (R 4.4.1) #> DelayedMatrixStats 1.27.3 2024-08-08 [1] Bioconductor 3.20 (R 4.4.1) #> desc 1.4.3 2023-12-10 [2] RSPM (R 4.4.0) #> digest 0.6.37 2024-08-19 [2] RSPM (R 4.4.0) #> doParallel 1.0.17 2022-02-07 [1] RSPM (R 4.4.0) #> dotCall64 1.2 2024-10-04 [1] RSPM (R 4.4.0) #> dplyr * 1.1.4 2023-11-17 [1] RSPM (R 4.4.0) #> dqrng 0.4.1 2024-05-28 [1] RSPM (R 4.4.0) #> DropletUtils 1.25.2 2024-07-23 [1] Bioconductor 3.20 (R 4.4.1) #> DT 0.33 2024-04-04 [1] RSPM (R 4.4.0) #> edgeR 4.3.20 2024-10-21 [1] Bioconductor 3.20 (R 4.4.1) #> evaluate 1.0.1 2024-10-10 [2] RSPM (R 4.4.0) #> ExperimentHub 2.13.1 2024-07-31 [1] Bioconductor 3.20 (R 4.4.1) #> fansi 1.0.6 2023-12-08 [2] RSPM (R 4.4.0) #> farver 2.1.2 2024-05-13 [1] RSPM (R 4.4.0) #> fastmap 1.2.0 2024-05-15 [2] RSPM (R 4.4.0) #> fields 16.3 2024-09-30 [1] RSPM (R 4.4.0) #> filelock 1.0.3 2023-12-11 [1] RSPM (R 4.4.0) #> foreach 1.5.2 2022-02-02 [1] RSPM (R 4.4.0) #> fs 1.6.4 2024-04-25 [2] RSPM (R 4.4.0) #> generics 0.1.3 2022-07-05 [1] RSPM (R 4.4.0) #> GenomeInfoDb * 1.41.2 2024-10-02 [1] Bioconductor 3.20 (R 4.4.1) #> GenomeInfoDbData 1.2.13 2024-10-16 [1] Bioconductor #> GenomicAlignments 1.41.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> GenomicRanges * 1.57.2 2024-10-09 [1] Bioconductor 3.20 (R 4.4.1) #> ggbeeswarm 0.7.2 2023-04-29 [1] RSPM (R 4.4.0) #> ggplot2 * 3.5.1 2024-04-23 [1] RSPM (R 4.4.0) #> ggrepel 0.9.6 2024-09-07 [1] RSPM (R 4.4.0) #> glue 1.8.0 2024-09-30 [2] RSPM (R 4.4.0) #> golem 0.5.1 2024-08-27 [1] RSPM (R 4.4.0) #> gridExtra 2.3 2017-09-09 [1] RSPM (R 4.4.0) #> gtable 0.3.5 2024-04-22 [1] RSPM (R 4.4.0) #> HDF5Array 1.33.8 2024-10-04 [1] Bioconductor 3.20 (R 4.4.1) #> highr 0.11 2024-05-26 [2] RSPM (R 4.4.0) #> hms 1.1.3 2023-03-21 [1] RSPM (R 4.4.0) #> htmltools 0.5.8.1 2024-04-04 [2] RSPM (R 4.4.0) #> htmlwidgets 1.6.4 2023-12-06 [2] RSPM (R 4.4.0) #> httpuv 1.6.15 2024-03-26 [2] RSPM (R 4.4.0) #> httr 1.4.7 2023-08-15 [1] RSPM (R 4.4.0) #> igraph 2.1.1 2024-10-19 [1] RSPM (R 4.4.0) #> imager 1.0.2 2024-05-13 [1] RSPM (R 4.4.0) #> IRanges * 2.39.2 2024-07-17 [1] Bioconductor 3.20 (R 4.4.1) #> irlba 2.3.5.1 2022-10-03 [1] RSPM (R 4.4.0) #> iterators 1.0.14 2022-02-05 [1] RSPM (R 4.4.0) #> jpeg 0.1-10 2022-11-29 [1] RSPM (R 4.4.0) #> jquerylib 0.1.4 2021-04-26 [2] RSPM (R 4.4.0) #> jsonlite 1.8.9 2024-09-20 [2] RSPM (R 4.4.0) #> KEGGREST 1.45.1 2024-06-17 [1] Bioconductor 3.20 (R 4.4.0) #> knitr 1.48 2024-07-07 [2] RSPM (R 4.4.0) #> labeling 0.4.3 2023-08-29 [1] RSPM (R 4.4.0) #> later 1.3.2 2023-12-06 [2] RSPM (R 4.4.0) #> lattice 0.22-6 2024-03-20 [3] CRAN (R 4.4.1) #> lazyeval 0.2.2 2019-03-15 [1] RSPM (R 4.4.0) #> lifecycle 1.0.4 2023-11-07 [2] RSPM (R 4.4.0) #> limma 3.61.12 2024-09-30 [1] Bioconductor 3.20 (R 4.4.1) #> locfit 1.5-9.10 2024-06-24 [1] RSPM (R 4.4.0) #> lubridate 1.9.3 2023-09-27 [1] RSPM (R 4.4.0) #> magick 2.8.5 2024-09-20 [1] RSPM (R 4.4.0) #> magrittr 2.0.3 2022-03-30 [2] RSPM (R 4.4.0) #> maps 3.4.2 2023-12-15 [1] RSPM (R 4.4.0) #> Matrix 1.7-1 2024-10-18 [3] RSPM (R 4.4.0) #> MatrixGenerics * 1.17.1 2024-10-23 [1] Bioconductor 3.20 (R 4.4.1) #> matrixStats * 1.4.1 2024-09-08 [1] RSPM (R 4.4.0) #> memoise 2.0.1 2021-11-26 [2] RSPM (R 4.4.0) #> mime 0.12 2021-09-28 [2] RSPM (R 4.4.0) #> munsell 0.5.1 2024-04-01 [1] RSPM (R 4.4.0) #> paletteer 1.6.0 2024-01-21 [1] RSPM (R 4.4.0) #> pillar 1.9.0 2023-03-22 [2] RSPM (R 4.4.0) #> pkgcond 0.1.1 2021-04-28 [1] RSPM (R 4.4.0) #> pkgconfig 2.0.3 2019-09-22 [2] RSPM (R 4.4.0) #> pkgdown 2.1.1.9000 2024-10-24 [1] Github (r-lib/pkgdown@8d9cba1) #> plotly 4.10.4 2024-01-13 [1] RSPM (R 4.4.0) #> plyr 1.8.9 2023-10-02 [1] RSPM (R 4.4.0) #> png 0.1-8 2022-11-29 [1] RSPM (R 4.4.0) #> promises 1.3.0 2024-04-05 [2] RSPM (R 4.4.0) #> purrr 1.0.2 2023-08-10 [2] RSPM (R 4.4.0) #> R.methodsS3 1.8.2 2022-06-13 [1] RSPM (R 4.4.0) #> R.oo 1.26.0 2024-01-24 [1] RSPM (R 4.4.0) #> R.utils 2.12.3 2023-11-18 [1] RSPM (R 4.4.0) #> R6 2.5.1 2021-08-19 [2] RSPM (R 4.4.0) #> ragg 1.3.3 2024-09-11 [2] RSPM (R 4.4.0) #> rappdirs 0.3.3 2021-01-31 [2] RSPM (R 4.4.0) #> RColorBrewer 1.1-3 2022-04-03 [1] RSPM (R 4.4.0) #> Rcpp 1.0.13 2024-07-17 [2] RSPM (R 4.4.0) #> RCurl 1.98-1.16 2024-07-11 [1] RSPM (R 4.4.0) #> readbitmap 0.1.5 2018-06-27 [1] RSPM (R 4.4.0) #> readr 2.1.5 2024-01-10 [1] RSPM (R 4.4.0) #> RefManageR * 1.4.0 2022-09-30 [1] RSPM (R 4.4.0) #> rematch2 2.1.2 2020-05-01 [2] RSPM (R 4.4.0) #> restfulr 0.0.15 2022-06-16 [1] RSPM (R 4.4.0) #> rhdf5 2.49.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> rhdf5filters 1.17.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> Rhdf5lib 1.27.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> rjson 0.2.23 2024-09-16 [1] RSPM (R 4.4.0) #> rlang 1.1.4 2024-06-04 [2] RSPM (R 4.4.0) #> rmarkdown 2.28 2024-08-17 [2] RSPM (R 4.4.0) #> Rsamtools 2.21.2 2024-09-26 [1] Bioconductor 3.20 (R 4.4.1) #> RSQLite 2.3.7 2024-05-27 [1] RSPM (R 4.4.0) #> rsvd 1.0.5 2021-04-16 [1] RSPM (R 4.4.0) #> rtracklayer 1.65.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> S4Arrays 1.5.11 2024-10-14 [1] Bioconductor 3.20 (R 4.4.1) #> S4Vectors * 0.43.2 2024-07-17 [1] Bioconductor 3.20 (R 4.4.1) #> sass 0.4.9 2024-03-15 [2] RSPM (R 4.4.0) #> ScaledMatrix 1.13.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> scales 1.3.0 2023-11-28 [1] RSPM (R 4.4.0) #> scater 1.33.4 2024-07-21 [1] Bioconductor 3.20 (R 4.4.1) #> scuttle 1.15.4 2024-08-14 [1] Bioconductor 3.20 (R 4.4.1) #> sessioninfo * 1.2.2 2021-12-06 [2] RSPM (R 4.4.0) #> shiny 1.9.1 2024-08-01 [2] RSPM (R 4.4.0) #> shinyWidgets 0.8.7 2024-09-23 [1] RSPM (R 4.4.0) #> SingleCellExperiment * 1.27.2 2024-05-24 [1] Bioconductor 3.20 (R 4.4.0) #> spam 2.11-0 2024-10-03 [1] RSPM (R 4.4.0) #> SparseArray 1.5.45 2024-10-21 [1] Bioconductor 3.20 (R 4.4.1) #> sparseMatrixStats 1.17.2 2024-06-12 [1] Bioconductor 3.20 (R 4.4.0) #> SpatialExperiment * 1.15.1 2024-06-20 [1] Bioconductor 3.20 (R 4.4.0) #> spatialLIBD * 1.17.10 2024-10-24 [1] Github (LieberInstitute/spatialLIBD@05e7886) #> statmod 1.5.0 2023-01-06 [1] RSPM (R 4.4.0) #> stringi 1.8.4 2024-05-06 [2] RSPM (R 4.4.0) #> stringr 1.5.1 2023-11-14 [2] RSPM (R 4.4.0) #> SummarizedExperiment * 1.35.4 2024-10-09 [1] Bioconductor 3.20 (R 4.4.1) #> systemfonts 1.1.0 2024-05-15 [2] RSPM (R 4.4.0) #> textshaping 0.4.0 2024-05-24 [2] RSPM (R 4.4.0) #> tibble 3.2.1 2023-03-20 [2] RSPM (R 4.4.0) #> tidyr 1.3.1 2024-01-24 [1] RSPM (R 4.4.0) #> tidyselect 1.2.1 2024-03-11 [1] RSPM (R 4.4.0) #> tiff 0.1-12 2023-11-28 [1] RSPM (R 4.4.0) #> timechange 0.3.0 2024-01-18 [1] RSPM (R 4.4.0) #> tzdb 0.4.0 2023-05-12 [1] RSPM (R 4.4.0) #> UCSC.utils 1.1.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> utf8 1.2.4 2023-10-22 [2] RSPM (R 4.4.0) #> vctrs 0.6.5 2023-12-01 [2] RSPM (R 4.4.0) #> vipor 0.4.7 2023-12-18 [1] RSPM (R 4.4.0) #> viridis 0.6.5 2024-01-29 [1] RSPM (R 4.4.0) #> viridisLite 0.4.2 2023-05-02 [1] RSPM (R 4.4.0) #> visiumStitched * 0.99.12 2024-10-24 [1] Bioconductor #> vroom 1.6.5 2023-12-05 [1] RSPM (R 4.4.0) #> withr 3.0.1 2024-07-31 [2] RSPM (R 4.4.0) #> xfun 0.48 2024-10-03 [2] RSPM (R 4.4.0) #> XML 3.99-0.17 2024-06-25 [1] RSPM (R 4.4.0) #> xml2 1.3.6 2023-12-04 [2] RSPM (R 4.4.0) #> xtable 1.8-4 2019-04-21 [2] RSPM (R 4.4.0) #> XVector 0.45.0 2024-05-01 [1] Bioconductor 3.20 (R 4.4.0) #> yaml 2.3.10 2024-07-26 [2] RSPM (R 4.4.0) #> zlibbioc 1.51.2 2024-10-21 [1] Bioconductor 3.20 (R 4.4.1) #> #> [1] /__w/_temp/Library #> [2] /usr/local/lib/R/site-library #> [3] /usr/local/lib/R/library #> #> ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────"},{"path":"/articles/visiumStitched.html","id":"bibliography","dir":"Articles","previous_headings":"","what":"Bibliography","title":"Introduction to visiumStitched","text":"vignette generated using BiocStyle (Oleś, 2024) knitr (Xie, 2024) rmarkdown (Allaire, Xie, Dervieux et al., 2024) running behind scenes. Citations made RefManageR (McLean, 2017). [1] J. Allaire, Y. Xie, C. Dervieux, et al. rmarkdown: Dynamic Documents R. R package version 2.28. 2024. URL: https://github.com/rstudio/rmarkdown. [2] S. Barthelme. imager: Image Processing Library Based ‘CImg’. R package version 1.0.2, https://github.com/asgr/imager/. 2024. URL: https://asgr.github.io/imager/. [3] . Couture-Beil. rjson: JSON R. R package version 0.2.23. 2024. URL: https://github.com/alexcb/rjson. [4] N. J. Eagles L. Collado-Torres. Enable downstream analysis Visium capture areas stitched together Fiji. https://github.com/LieberInstitute/visiumStitched/visiumStitched - R package version 0.99.12. 2024. DOI: 10.18129/B9.bioc.visiumStitched. URL: http://www.bioconductor.org/packages/visiumStitched. [5] Y. Hao, T. Stuart, M. H. Kowalski, et al. “Dictionary learning integrative, multimodal scalable single-cell analysis”. : Nature Biotechnology (2023). DOI: 10.1038/s41587-023-01767-y. URL: https://doi.org/10.1038/s41587-023-01767-y. [6] . T. L. Lun, S. Riesenfeld, T. Andrews, et al. “EmptyDrops: distinguishing cells empty droplets droplet-based single-cell RNA sequencing data”. : Genome Biol. 20 (2019), p. 63. DOI: 10.1186/s13059-019-1662-y. [7] M. W. McLean. “RefManageR: Import Manage BibTeX BibLaTeX References R”. : Journal Open Source Software (2017). DOI: 10.21105/joss.00338. [8] M. Morgan, V. Obenchain, J. Hester, et al. SummarizedExperiment: SummarizedExperiment container. R package version 1.35.4. 2024. DOI: 10.18129/B9.bioc.SummarizedExperiment. URL: https://bioconductor.org/packages/SummarizedExperiment. [9] . Oleś. BiocStyle: Standard styles vignettes Bioconductor documents. R package version 2.33.1. 2024. DOI: 10.18129/B9.bioc.BiocStyle. URL: https://bioconductor.org/packages/BiocStyle. [10] H. Pagès, M. Lawrence, P. Aboyoun. S4Vectors: Foundation vector-like list-like containers Bioconductor. R package version 0.43.2. 2024. DOI: 10.18129/B9.bioc.S4Vectors. URL: https://bioconductor.org/packages/S4Vectors. [11] B. Pardo, . Spangler, L. M. Weber, et al. “spatialLIBD: R/Bioconductor package visualize spatially-resolved transcriptomics data”. : BMC Genomics (2022). DOI: 10.1186/s12864-022-08601-w. URL: https://doi.org/10.1186/s12864-022-08601-w. [12] R Core Team. R: Language Environment Statistical Computing. R Foundation Statistical Computing. Vienna, Austria, 2024. URL: https://www.R-project.org/. [13] . Redd R Documentation Task Force. pkgcond: Classed Error Warning Conditions. R package version 0.1.1. 2021. URL: https://github.com/RDocTaskForce/pkgcond. [14] D. Righelli, L. M. Weber, H. L. Crowell, et al. “SpatialExperiment: infrastructure spatially-resolved transcriptomics data R using Bioconductor”. : Bioinformatics 38.11 (2022), pp. -3. DOI: https://doi.org/10.1093/bioinformatics/btac299. [15] L. Shepherd M. Morgan. BiocFileCache: Manage Files Across Sessions. R package version 2.13.2. 2024. DOI: 10.18129/B9.bioc.BiocFileCache. URL: https://bioconductor.org/packages/BiocFileCache. [16] H. Wickham. ggplot2: Elegant Graphics Data Analysis. Springer-Verlag New York, 2016. ISBN: 978-3-319-24277-4. URL: https://ggplot2.tidyverse.org. [17] H. Wickham. stringr: Simple, Consistent Wrappers Common String Operations. R package version 1.5.1, https://github.com/tidyverse/stringr. 2023. URL: https://stringr.tidyverse.org. [18] H. Wickham. “testthat: Get Started Testing”. : R Journal 3 (2011), pp. 5–10. URL: https://journal.r-project.org/archive/2011-1/RJournal_2011-1_Wickham.pdf. [19] H. Wickham, W. Chang, R. Flight, et al. sessioninfo: R Session Information. R package version 1.2.2, https://r-lib.github.io/sessioninfo/. 2021. URL: https://github.com/r-lib/sessioninfo#readme. [20] H. Wickham, R. François, L. Henry, et al. dplyr: Grammar Data Manipulation. R package version 1.1.4, https://github.com/tidyverse/dplyr. 2023. URL: https://dplyr.tidyverse.org. [21] H. Wickham, J. Hester, J. Ooms. xml2: Parse XML. R package version 1.3.6, https://github.com/r-lib/xml2. 2023. URL: https://xml2.r-lib.org/. [22] Y. Xie. knitr: General-Purpose Package Dynamic Report Generation R. R package version 1.48. 2024. URL: https://yihui.org/knitr/.","code":""},{"path":"/authors.html","id":null,"dir":"","previous_headings":"","what":"Authors","title":"Authors and Citation","text":"Nicholas J. Eagles. Author, maintainer. Leonardo Collado-Torres. Contributor.","code":""},{"path":"/authors.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Authors and Citation","text":"Eagles NJ, Collado-Torres L (2024). Enable downstream analysis Visium capture areas stitched together Fiji. doi:10.18129/B9.bioc.visiumStitched, https://github.com/LieberInstitute/visiumStitched/visiumStitched - R package version 0.99.12, http://www.bioconductor.org/packages/visiumStitched. Eagles NJ, Bach S, Tippani M, Ravichandran P, Du Y, Miller RA, Hyde TM, Page SC, Martinowich K, Collado-Torres L (2024). “visiumStitched.” bioRxiv. doi:10.1101/TODO, https://www.biorxiv.org/content/10.1101/TODO.","code":"@Manual{, title = {Enable downstream analysis of Visium capture areas stitched together with Fiji}, author = {Nicholas J. Eagles and Leonardo Collado-Torres}, year = {2024}, url = {http://www.bioconductor.org/packages/visiumStitched}, note = {https://github.com/LieberInstitute/visiumStitched/visiumStitched - R package version 0.99.12}, doi = {10.18129/B9.bioc.visiumStitched}, } @Article{, title = {visiumStitched}, author = {Nicholas J. Eagles and Svitlana Bach and Madhavi Tippani and Prashanthi Ravichandran and Yufeng Du and Ryan A. Miller and Thomas M. Hyde and Stephanie C. Page and Keri Martinowich and Leonardo Collado-Torres}, year = {2024}, journal = {bioRxiv}, doi = {10.1101/TODO}, url = {https://www.biorxiv.org/content/10.1101/TODO}, }"},{"path":"/index.html","id":"visiumstitched-","dir":"","previous_headings":"","what":"Enable downstream analysis of Visium capture areas stitched together with Fiji","title":"Enable downstream analysis of Visium capture areas stitched together with Fiji","text":"visiumStitched provides helper functions working multiple Visium capture areas overlap . package developed along companion example use case data available https://github.com/LieberInstitute/visiumStitched_brain. visiumStitched prepares SpaceRanger (10x Genomics) output files can stitch images groups capture areas together Fiji. visiumStitched builds SpatialExperiment object stitched data makes artificial hexagonal grid enabling seamless use spatial clustering methods rely grid identify neighboring spots, PRECAST BayesSpace. SpatialExperiment objects created visiumStitched compatible spatialLIBD, can used build interactive websites stitched SpatialExperiment objects (check example human brain data). visiumStitched also enables casting SpatialExperiment objects Seurat objects. details, check documentation site.","code":""},{"path":"/index.html","id":"example-data-processed-with-visiumstitched","dir":"","previous_headings":"","what":"Example data processed with visiumStitched","title":"Enable downstream analysis of Visium capture areas stitched together with Fiji","text":"example human brain data LieberInstitute/visiumStitched_brain stitched together using visiumStitched. resulting data can accessed visualized spatialLIBD version 1.17.8 newer.","code":"## Check that you have a recent version of spatialLIBD installed stopifnot(packageVersion(\"spatialLIBD\") >= \"1.17.8\") ## Download the spot-level data, which is a SpatialExperiment object spe <- spatialLIBD::fetch_data(type = \"visiumStitched_brain_spe\") #> snapshotDate(): 2024-04-29 #> 2024-10-14 11:39:40.997043 loading file /users/neagles/.cache/R/BiocFileCache/feb652e603a7a_visiumStitched_brain_spe.rds%3Frlkey%3Dnq6a82u23xuu9hohr86oodwdi%26dl%3D1 ## Explore the stitched data spe #> class: SpatialExperiment #> dim: 26369 13965 #> metadata(0): #> assays(2): counts logcounts #> rownames(26369): ENSG00000238009 ENSG00000241860 ... ENSG00000278817 #> ENSG00000277196 #> rowData names(7): source type ... gene_type gene_search #> colnames(13965): AAACAACGAATAGTTC-1_V13B23-283_A1 #> AAACAAGTATCTCCCA-1_V13B23-283_A1 ... TTGTTTGTATTACACG-1_V13B23-283_D1 #> TTGTTTGTGTAAATTC-1_V13B23-283_D1 #> colData names(40): sample_id in_tissue ... precast_k4 precast_k8 #> reducedDimNames(1): PCA #> mainExpName: NULL #> altExpNames(0): #> spatialCoords names(2) : pxl_col_in_fullres pxl_row_in_fullres #> imgData names(4): sample_id image_id data scaleFactor ## Show clustering results from PRECAST at k = 8 spatialLIBD::vis_clus( spe, clustervar = \"precast_k8\", is_stitched = TRUE )"},{"path":"/index.html","id":"installation-instructions","dir":"","previous_headings":"","what":"Installation instructions","title":"Enable downstream analysis of Visium capture areas stitched together with Fiji","text":"Get latest stable R release CRAN. install visiumStitched Bioconductor using following code:","code":"if (!requireNamespace(\"BiocManager\", quietly = TRUE)) { install.packages(\"BiocManager\") } BiocManager::install(\"visiumStitched\")"},{"path":"/index.html","id":"citation","dir":"","previous_headings":"","what":"Citation","title":"Enable downstream analysis of Visium capture areas stitched together with Fiji","text":"citation output using citation('visiumStitched') R. Please run check updates cite visiumStitched. Please note visiumStitched made possible thanks many R bioinformatics software authors, cited either vignettes /paper(s) describing package.","code":"print(citation(\"visiumStitched\"), bibtex = TRUE) #> Warning in packageDescription(pkg = package, lib.loc = dirname(dir)): no #> package 'visiumStitched' was found #> Eagles NJ, Collado-Torres L (2024). _Enable downstream analysis of #> Visium capture areas stitched together with Fiji_. #> doi:10.18129/B9.bioc.visiumStitched #> , #> https://github.com/LieberInstitute/visiumStitched/visiumStitched - R #> package version, . #> #> A BibTeX entry for LaTeX users is #> #> @Manual{, #> title = {Enable downstream analysis of Visium capture areas stitched together with Fiji}, #> author = {Nicholas J. Eagles and Leonardo Collado-Torres}, #> year = {2024}, #> url = {http://www.bioconductor.org/packages/visiumStitched}, #> note = {https://github.com/LieberInstitute/visiumStitched/visiumStitched - R package version}, #> doi = {10.18129/B9.bioc.visiumStitched}, #> } #> #> Eagles NJ, Bach S, Tippani M, Ravichandran P, Du Y, Miller RA, Hyde TM, #> Page SC, Martinowich K, Collado-Torres L (2024). \"visiumStitched.\" #> _bioRxiv_. doi:10.1101/TODO , #> . #> #> A BibTeX entry for LaTeX users is #> #> @Article{, #> title = {visiumStitched}, #> author = {Nicholas J. Eagles and Svitlana Bach and Madhavi Tippani and Prashanthi Ravichandran and Yufeng Du and Ryan A. Miller and Thomas M. Hyde and Stephanie C. Page and Keri Martinowich and Leonardo Collado-Torres}, #> year = {2024}, #> journal = {bioRxiv}, #> doi = {10.1101/TODO}, #> url = {https://www.biorxiv.org/content/10.1101/TODO}, #> }"},{"path":"/index.html","id":"code-of-conduct","dir":"","previous_headings":"","what":"Code of Conduct","title":"Enable downstream analysis of Visium capture areas stitched together with Fiji","text":"Please note visiumStitched project released Contributor Code Conduct. contributing project, agree abide terms.","code":""},{"path":"/index.html","id":"development-tools","dir":"","previous_headings":"","what":"Development tools","title":"Enable downstream analysis of Visium capture areas stitched together with Fiji","text":"Continuous code testing possible thanks GitHub actions usethis, remotes, rcmdcheck customized use Bioconductor’s docker containers BiocCheck. Code coverage assessment possible thanks codecov covr. documentation website automatically updated thanks pkgdown. code styled automatically thanks styler. documentation formatted thanks devtools roxygen2. details, check dev directory. package developed using biocthis.","code":""},{"path":"/reference/add_array_coords.html","id":null,"dir":"Reference","previous_headings":"","what":"Add transformed array and pixel coordinates to a SpatialExperiment — add_array_coords","title":"Add transformed array and pixel coordinates to a SpatialExperiment — add_array_coords","text":"Given SpatialExperiment-class, sample information, coordinates produced refinement workflow, add array pixel coordinates appropriate linearly transformed capture areas making group present SpatialExperiment-class.","code":""},{"path":"/reference/add_array_coords.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add transformed array and pixel coordinates to a SpatialExperiment — add_array_coords","text":"","code":"add_array_coords(spe, sample_info, coords_dir, calc_error_metrics = FALSE)"},{"path":"/reference/add_array_coords.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add transformed array and pixel coordinates to a SpatialExperiment — add_array_coords","text":"spe SpatialExperiment-class object. sample_info data.frame() columns capture_area, group, fiji_xml_path, fiji_image_path, spaceranger_dir, intra_group_scalar, group_hires_scalef. last two made rescale_fiji_inputs(). coords_dir character(1) vector giving directory containing sample directories tissue_positions.csv, scalefactors_json.json, tissue_lowres_image.png files produced refinement prep_fiji_coords() related functions. calc_error_metrics logical(1) vector indicating whether calculate error metrics related mapping spots well-defined array coordinates. TRUE, adds euclidean_error shared_neighbors spot-level metrics colData(). former indicates distance number inter-spot distances \"move\" spot new array position; latter indicates fraction neighbors associated capture area retained mapping, can quite time-consuming compute.","code":""},{"path":"/reference/add_array_coords.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add transformed array and pixel coordinates to a SpatialExperiment — add_array_coords","text":"SpatialExperiment-class object additional colData columns pxl_row_in_fullres_[suffix] pxl_col_in_fullres_[suffix] [suffix] values original rounded; array_row_original array_col_original columns; modified colData() columns array_row array_col spatialCoords() transformed values.","code":""},{"path":"/reference/add_array_coords.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add transformed array and pixel coordinates to a SpatialExperiment — add_array_coords","text":"Array coordinates determined via algorithm fits spot nearest spot new, imaginary, Visium-like capture area. imaginary capture area differs real capture area extent; array coordinates still start 0 may extend arbitrarily beyond normal maximum indices 77 127 fit every capture area group defined SpatialExperiment-class. goal return well-defined array coordinates consistent spatial orientation group, downstream applications, clustering BayesSpace, can process group really one capture area first place. See https://research.libd.org/visiumStitched/articles/visiumStitched.html#defining-array-coordinates details.","code":""},{"path":"/reference/add_array_coords.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Add transformed array and pixel coordinates to a SpatialExperiment — add_array_coords","text":"Nicholas J. Eagles","code":""},{"path":"/reference/add_array_coords.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add transformed array and pixel coordinates to a SpatialExperiment — add_array_coords","text":"","code":"if (!exists(\"spe\")) { spe <- spatialLIBD::fetch_data(type = \"visiumStitched_brain_spe\") } #> 2024-10-24 20:15:01.365432 loading file /github/home/.cache/R/BiocFileCache/760d7e2c6_visiumStitched_brain_spe.rds%3Frlkey%3Dnq6a82u23xuu9hohr86oodwdi%26dl%3D1 ######################################################################## # Prepare sample_info ######################################################################## sample_info <- dplyr::tibble( group = \"Br2719\", capture_area = c(\"V13B23-283_A1\", \"V13B23-283_C1\", \"V13B23-283_D1\") ) # Add 'spaceranger_dir' column sr_dir <- tempdir() temp <- unzip( spatialLIBD::fetch_data(\"visiumStitched_brain_spaceranger\"), exdir = sr_dir ) #> 2024-10-24 20:15:06.235759 loading file /github/home/.cache/R/BiocFileCache/7603a007f35_visiumStitched_brain_spaceranger.zip%3Frlkey%3Dbdgjc6mgy1ierdad6h6v5g29c%26dl%3D1 sample_info$spaceranger_dir <- file.path( sr_dir, sample_info$capture_area, \"outs\", \"spatial\" ) # Add Fiji-output-related columns fiji_dir <- tempdir() temp <- unzip( spatialLIBD::fetch_data(\"visiumStitched_brain_Fiji_out\"), exdir = fiji_dir ) #> 2024-10-24 20:15:08.648643 loading file /github/home/.cache/R/BiocFileCache/76048672d76_visiumStitched_brain_fiji_out.zip%3Frlkey%3Dptwal8f5zxakzejwd0oqw0lhj%26dl%3D1 sample_info$fiji_xml_path <- temp[grep(\"xml$\", temp)] sample_info$fiji_image_path <- temp[grep(\"png$\", temp)] ## Re-size images and add more information to the sample_info sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir()) ## Preparing Fiji coordinates and images for build_SpatialExperiment() spe_input_dir <- tempdir() prep_fiji_coords(sample_info, out_dir = spe_input_dir) #> [1] \"/tmp/RtmpphIhEc/Br2719/tissue_positions.csv\" prep_fiji_image(sample_info, out_dir = spe_input_dir) #> [1] \"/tmp/RtmpphIhEc/Br2719/tissue_lowres_image.png\" #> [2] \"/tmp/RtmpphIhEc/Br2719/scalefactors_json.json\" ######################################################################## # Add array coordinates ######################################################################## spe_new <- add_array_coords(spe, sample_info, tempdir()) # Several columns related to spatial coordinates were added added_cols_regex <- \"^(array|pxl)_(row|col)(_in_fullres)?_(original|rounded)$\" colnames(SummarizedExperiment::colData(spe_new))[ grep(added_cols_regex, colnames(SummarizedExperiment::colData(spe_new))) ] #> [1] \"array_row_original\" \"array_col_original\" #> [3] \"pxl_col_in_fullres_rounded\" \"pxl_row_in_fullres_rounded\" #> [5] \"pxl_row_in_fullres_original\" \"pxl_col_in_fullres_original\" # 'array_row', 'array_col', and spatialCoords() were overwritten with # their transformed values head(spe$array_row) #> [1] 0 50 3 59 14 43 head(spe$array_col) #> [1] 16 102 43 19 94 9 head(SpatialExperiment::spatialCoords(spe_new)) #> pxl_col_in_fullres pxl_row_in_fullres #> AAACAACGAATAGTTC-1 1874 50718 #> AAACAAGTATCTCCCA-1 13935 38805 #> AAACAATCTACTAGCA-1 2599 46977 #> AAACACCAATAACTGC-1 16101 50308 #> AAACAGAGCGACTCCT-1 5255 39910 #> AAACAGCTTTCAGAAG-1 12242 51692"},{"path":"/reference/add_overlap_info.html","id":null,"dir":"Reference","previous_headings":"","what":"Add info about how spots overlap among capture areas — add_overlap_info","title":"Add info about how spots overlap among capture areas — add_overlap_info","text":"Given SpatialExperiment-class column name colData, return modified copy SpatialExperiment additional colData columns: spe$exclude_overlapping spe$overlap_key.","code":""},{"path":"/reference/add_overlap_info.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add info about how spots overlap among capture areas — add_overlap_info","text":"","code":"add_overlap_info(spe, metric_name)"},{"path":"/reference/add_overlap_info.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add info about how spots overlap among capture areas — add_overlap_info","text":"spe SpatialExperiment-class colData(spe) columns array_row, array_col, key, capture_area. metric_name character(1) colnames(colData(spe)), spots belonging capture area highest average value metric take precedence spots.","code":""},{"path":"/reference/add_overlap_info.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add info about how spots overlap among capture areas — add_overlap_info","text":"SpatialExperiment object additional colData columns spe$exclude_overlapping spe$overlap_key.","code":""},{"path":"/reference/add_overlap_info.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add info about how spots overlap among capture areas — add_overlap_info","text":"spe$exclude_overlapping TRUE spots higher-quality overlapping capture area FALSE otherwise. vis_clus onlydisplays FALSE spots prevent overplotting regions overlap. spe$overlap_key gives comma-separated strings containing keys overlapping spots, empty string otherwise.","code":""},{"path":"/reference/add_overlap_info.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Add info about how spots overlap among capture areas — add_overlap_info","text":"Nicholas J. Eagles","code":""},{"path":"/reference/add_overlap_info.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Add info about how spots overlap among capture areas — add_overlap_info","text":"","code":"if (!exists(\"spe\")) { spe <- spatialLIBD::fetch_data(type = \"visiumStitched_brain_spe\") } #> 2024-10-24 20:15:21.971441 loading file /github/home/.cache/R/BiocFileCache/760d7e2c6_visiumStitched_brain_spe.rds%3Frlkey%3Dnq6a82u23xuu9hohr86oodwdi%26dl%3D1 # Find the mean of the 'sum_umi' metric by capture area to understand # which capture areas will be excluded in regions of overlap SummarizedExperiment::colData(spe) |> dplyr::as_tibble() |> dplyr::group_by(capture_area) |> dplyr::summarize(mean_sum_umi = mean(sum_umi)) #> # A tibble: 3 × 2 #> capture_area mean_sum_umi #> #> 1 V13B23-283_A1 2075. #> 2 V13B23-283_C1 1188. #> 3 V13B23-283_D1 2083. spe <- add_overlap_info(spe, \"sum_umi\") # See how many spots were excluded by capture area table(spe$exclude_overlapping, spe$capture_area) #> #> V13B23-283_A1 V13B23-283_C1 V13B23-283_D1 #> FALSE 3920 4367 4596 #> TRUE 1032 50 0 # Examine how data about overlapping spots is stored (for the first # few spots with overlap) head(spe$overlap_key[spe$overlap_key != \"\"]) #> [1] \"TCAGAACGGCGGTAAT-1_V13B23-283_D1,TGCCCGATAGTTAGAA-1_V13B23-283_D1\" #> [2] \"CGACTTGCCGGGAAAT-1_V13B23-283_D1,TCATGAAGCGCTGCAT-1_V13B23-283_D1\" #> [3] \"CCTTAAGTACGCAATT-1_V13B23-283_D1\" #> [4] \"GAAGCCACTGATTATG-1_V13B23-283_D1\" #> [5] \"ACTCAAGTGCAAGGCT-1_V13B23-283_D1\" #> [6] \"GGCCTGCTTCTCCCGA-1_V13B23-283_D1\""},{"path":"/reference/as.Seurat.html","id":null,"dir":"Reference","previous_headings":"","what":"Convert a SpatialExperiment object to a Seurat object — as.Seurat","title":"Convert a SpatialExperiment object to a Seurat object — as.Seurat","text":"Given SpatialExperiment-class object, first .Seurat() run, operates SingleCellExperiment-class objects. remaining components (images, spatial coordinates) added manually. actual appearance images buggy now.","code":""},{"path":"/reference/as.Seurat.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Convert a SpatialExperiment object to a Seurat object — as.Seurat","text":"","code":"as.Seurat( spe, spatial_cols = c(tissue = \"in_tissue\", row = \"array_row\", col = \"array_col\", imagerow = \"pxl_row_in_fullres\", imagecol = \"pxl_col_in_fullres\"), verbose = TRUE )"},{"path":"/reference/as.Seurat.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Convert a SpatialExperiment object to a Seurat object — as.Seurat","text":"spe SpatialExperiment-class colData() spatialCoords() columns given spatial_cols. stitched spe object function work type spe objects. spatial_cols character(5) named vector mapping colData(spe) spatialCoords(spe) columns contain tissue, row, col, imagerow, imagecol information expected Seurat. verbose logical(1) vector. TRUE, print status update conversion process. information can useful debugging.","code":""},{"path":"/reference/as.Seurat.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Convert a SpatialExperiment object to a Seurat object — as.Seurat","text":"Seurat object.","code":""},{"path":"/reference/as.Seurat.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Convert a SpatialExperiment object to a Seurat object — as.Seurat","text":"Note lowres images imgData(spe) used.","code":""},{"path":"/reference/as.Seurat.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Convert a SpatialExperiment object to a Seurat object — as.Seurat","text":"Nicholas J. Eagles","code":""},{"path":"/reference/as.Seurat.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Convert a SpatialExperiment object to a Seurat object — as.Seurat","text":"","code":"## Download some example data spe_unstitched <- spatialLIBD::fetch_data( type = \"spatialDLPFC_Visium_example_subset\" )[seq(100), seq(100)] #> 2024-10-24 20:15:26.263044 loading file /github/home/.cache/R/BiocFileCache/131c3e5993ec_spatialDLPFC_spe_subset_example.rds%3Fdl%3D1 ## Make the column names unique colnames(spe_unstitched) <- spatialLIBD::add_key(spe_unstitched)$key #> Overwriting 'spe$key'. Set 'overwrite = FALSE' if you do not want to overwrite it. ## Convert from a SpatialExperiment to a Seurat object seur <- as.Seurat(spe_unstitched) #> Running 'as.Seurat(spe)'... #> Registered S3 method overwritten by 'spatstat.geom': #> method from #> plot.imlist imager #> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from pc. to pc_ #> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from tsne. to tsne_ #> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from umap. to umap_ #> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from PC to PC_ #> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from UMAP to UMAP_ #> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from TSNE_perplexity80_ to TSNEperplexity80_ #> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from UMAP to UMAP_ #> Warning: Key ‘UMAP_’ taken, using ‘umapharmony_’ instead #> Adding spot coordinates and images for sample Br6432_ant... #> Returning converted object... seur #> An object of class Seurat #> 100 features across 100 samples within 1 assay #> Active assay: originalexp (100 features, 0 variable features) #> 2 layers present: counts, data #> 8 dimensional reductions calculated: X10x_pca, X10x_tsne, X10x_umap, PCA, UMAP, TSNE_perplexity80, HARMONY, UMAP.HARMONY #> 1 image present: Br6432_ant ## Example with an stitched SPE object if (!exists(\"spe\")) { spe <- spatialLIBD::fetch_data(type = \"visiumStitched_brain_spe\") } #> 2024-10-24 20:15:32.352409 loading file /github/home/.cache/R/BiocFileCache/760d7e2c6_visiumStitched_brain_spe.rds%3Frlkey%3Dnq6a82u23xuu9hohr86oodwdi%26dl%3D1 seur_stitched <- as.Seurat(spe[seq(100), seq(100)]) #> Running 'as.Seurat(spe)'... #> Warning: Keys should be one or more alphanumeric characters followed by an underscore, setting key from PC to PC_ #> Adding spot coordinates and images for sample Br2719... #> Returning converted object... ## Let's look at our resulting Seurat object seur_stitched #> An object of class Seurat #> 100 features across 100 samples within 1 assay #> Active assay: originalexp (100 features, 0 variable features) #> 2 layers present: counts, data #> 1 dimensional reduction calculated: PCA #> 1 image present: Br2719"},{"path":"/reference/build_SpatialExperiment.html","id":null,"dir":"Reference","previous_headings":"","what":"Build stitched SpatialExperiment — build_SpatialExperiment","title":"Build stitched SpatialExperiment — build_SpatialExperiment","text":"First, read capture-area-level SpaceRanger https://www.10xgenomics.com/support/software/space-ranger/latest/analysis/running-pipelines/space-ranger-count outputs. , overwrite spatial coordinates images represent group-level samples using sample_info$group (though keep original coordinates colData columns ending suffix \"_original\"). Next, add info overlaps (via spe$exclude_overlapping spe$overlap_key). Ultimately, return SpatialExperiment-class ready visualization downstream analysis.","code":""},{"path":"/reference/build_SpatialExperiment.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Build stitched SpatialExperiment — build_SpatialExperiment","text":"","code":"build_SpatialExperiment( sample_info, coords_dir, count_type = \"sparse\", reference_gtf = NULL, gtf_cols = c(\"source\", \"type\", \"gene_id\", \"gene_version\", \"gene_name\", \"gene_type\"), calc_error_metrics = FALSE )"},{"path":"/reference/build_SpatialExperiment.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Build stitched SpatialExperiment — build_SpatialExperiment","text":"sample_info data.frame() columns capture_area, group, fiji_xml_path, fiji_image_path, spaceranger_dir, intra_group_scalar, group_hires_scalef. last two made rescale_fiji_inputs(). coords_dir character(1) vector giving directory containing sample directories tissue_positions.csv, scalefactors_json.json, tissue_lowres_image.png files produced refinement prep_fiji_coords() related functions. count_type character(1) vector passed type SpatialExperiment::read10xVisium, defaulting \"sparse\". reference_gtf Passed spatialLIBD::read10xVisiumWrapper(). working system SpaceRanger run, GTF automatically found; otherwise character(1) path may supplied, pointing GTF file gene annotation populate rowData() . gtf_cols Passed spatialLIBD::read10xVisiumWrapper(). Columns reference GTF extract populate rowData(). calc_error_metrics logical(1) vector indicating whether calculate error metrics related mapping spots well-defined array coordinates. TRUE, adds euclidean_error shared_neighbors spot-level metrics colData(). former indicates distance number inter-spot distances \"move\" spot new array position; latter indicates fraction neighbors associated capture area retained mapping, can quite time-consuming compute.","code":""},{"path":"/reference/build_SpatialExperiment.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Build stitched SpatialExperiment — build_SpatialExperiment","text":"SpatialExperiment-class object one sample per group specified sample_info using transformed pixel array coordinates (including spatialCoords()).","code":""},{"path":"/reference/build_SpatialExperiment.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Build stitched SpatialExperiment — build_SpatialExperiment","text":"Nicholas J. Eagles","code":""},{"path":"/reference/build_SpatialExperiment.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Build stitched SpatialExperiment — build_SpatialExperiment","text":"","code":"######################################################################## # Prepare sample_info ######################################################################## sample_info <- dplyr::tibble( group = \"Br2719\", capture_area = c(\"V13B23-283_A1\", \"V13B23-283_C1\", \"V13B23-283_D1\") ) # Add 'spaceranger_dir' column sr_dir <- tempdir() temp <- unzip( spatialLIBD::fetch_data(\"visiumStitched_brain_spaceranger\"), exdir = sr_dir ) #> 2024-10-24 20:15:35.672125 loading file /github/home/.cache/R/BiocFileCache/7603a007f35_visiumStitched_brain_spaceranger.zip%3Frlkey%3Dbdgjc6mgy1ierdad6h6v5g29c%26dl%3D1 sample_info$spaceranger_dir <- file.path( sr_dir, sample_info$capture_area, \"outs\", \"spatial\" ) # Add Fiji-output-related columns fiji_dir <- tempdir() temp <- unzip( spatialLIBD::fetch_data(\"visiumStitched_brain_Fiji_out\"), exdir = fiji_dir ) #> 2024-10-24 20:15:38.221787 loading file /github/home/.cache/R/BiocFileCache/76048672d76_visiumStitched_brain_fiji_out.zip%3Frlkey%3Dptwal8f5zxakzejwd0oqw0lhj%26dl%3D1 sample_info$fiji_xml_path <- temp[grep(\"xml$\", temp)] sample_info$fiji_image_path <- temp[grep(\"png$\", temp)] ## Re-size images and add more information to the sample_info sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir()) ## Preparing Fiji coordinates and images for build_SpatialExperiment() spe_input_dir <- tempdir() prep_fiji_coords(sample_info, out_dir = spe_input_dir) #> [1] \"/tmp/RtmpphIhEc/Br2719/tissue_positions.csv\" prep_fiji_image(sample_info, out_dir = spe_input_dir) #> [1] \"/tmp/RtmpphIhEc/Br2719/tissue_lowres_image.png\" #> [2] \"/tmp/RtmpphIhEc/Br2719/scalefactors_json.json\" ######################################################################## # Build the SpatialExperiment ######################################################################## # Since we don't have access to the original GTF used to run SpaceRanger, # we must explicitly supply our own GTF to build_SpatialExperiment(). We use # GENCODE release 32, intended to be quite close to the actual GTF used, # which is available from: # https://cf.10xgenomics.com/supp/cell-exp/refdata-gex-GRCh38-2024-A.tar.gz bfc <- BiocFileCache::BiocFileCache() gtf_cache <- BiocFileCache::bfcrpath( bfc, paste0( \"ftp://ftp.ebi.ac.uk/pub/databases/gencode/Gencode_human/\", \"release_32/gencode.v32.annotation.gtf.gz\" ) ) ## Now we can build the stitched SpatialExperiment object spe <- build_SpatialExperiment( sample_info, coords_dir = spe_input_dir, reference_gtf = gtf_cache ) #> Building SpatialExperiment using capture area as sample ID #> 2024-10-24 20:15:47.126858 SpatialExperiment::read10xVisium: reading basic data from SpaceRanger #> 2024-10-24 20:15:53.129575 read10xVisiumAnalysis: reading analysis output from SpaceRanger #> 2024-10-24 20:15:53.448283 add10xVisiumAnalysis: adding analysis output from SpaceRanger #> 2024-10-24 20:15:53.750296 rtracklayer::import: reading the reference GTF file #> 2024-10-24 20:16:22.091238 adding gene information to the SPE object #> Warning: Gene IDs did not match. This typically happens when you are not using the same GTF file as the one that was used by SpaceRanger. For example, one file uses GENCODE IDs and the other one ENSEMBL IDs. read10xVisiumWrapper() will try to convert them to ENSEMBL IDs. #> Warning: Dropping 2226 out of 38606 genes for which we don't have information on the reference GTF file. This typically happens when you are not using the same GTF file as the one that was used by SpaceRanger. #> 2024-10-24 20:16:22.530429 adding information used by spatialLIBD #> Overwriting imgData(spe) with merged images (one per group) #> Adding array coordinates and overlap info ## Let's explore the stitched SpatialExperiment object spe #> class: SpatialExperiment #> dim: 36380 14976 #> metadata(0): #> assays(1): counts #> rownames(36380): ENSG00000243485.5 ENSG00000237613.2 ... #> ENSG00000198695.2 ENSG00000198727.2 #> rowData names(6): source type ... gene_type gene_search #> colnames(14976): AAACAACGAATAGTTC-1_V13B23-283_A1 #> AAACAAGTATCTCCCA-1_V13B23-283_A1 ... TTGTTTGTATTACACG-1_V13B23-283_D1 #> TTGTTTGTGTAAATTC-1_V13B23-283_D1 #> colData names(31): sample_id in_tissue ... overlap_key #> exclude_overlapping #> reducedDimNames(0): #> mainExpName: NULL #> altExpNames(0): #> spatialCoords names(2) : pxl_col_in_fullres pxl_row_in_fullres #> imgData names(4): sample_id image_id data scaleFactor"},{"path":"/reference/dot-add_error_metrics.html","id":null,"dir":"Reference","previous_headings":"","what":"Add error metrics related to array-coordinate mapping — .add_error_metrics","title":"Add error metrics related to array-coordinate mapping — .add_error_metrics","text":"Given tibble()s mapping new array coordinates, calculate metrics related suitability mapping.","code":""},{"path":"/reference/dot-add_error_metrics.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Add error metrics related to array-coordinate mapping — .add_error_metrics","text":"","code":".add_error_metrics(coords, coords_new, inter_spot_dist_px)"},{"path":"/reference/dot-add_error_metrics.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Add error metrics related to array-coordinate mapping — .add_error_metrics","text":"coords tibble() containing array_row, array_col, key, pxl_col_in_fullres, pxl_row_in_fullres, pxl_col_in_fullres_rounded, pxl_row_in_fullres_rounded, capture_area columns, representing data mapping new array coordinates one group. coords_new tibble() containing array_row, array_col, key, pxl_col_in_fullres, pxl_row_in_fullres, pxl_col_in_fullres_rounded, pxl_row_in_fullres_rounded columns, representing data mapping new array coordinates one group. inter_spot_dist_px numeric(1) giving number pixels spots group.","code":""},{"path":"/reference/dot-add_error_metrics.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Add error metrics related to array-coordinate mapping — .add_error_metrics","text":"tibble() copy coords_new additional shared_neighbors euclidean_error columns.","code":""},{"path":"/reference/dot-add_error_metrics.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Add error metrics related to array-coordinate mapping — .add_error_metrics","text":"Add column shared_neighbors, fraction neighbors spot started retained mapping; add column euclidean_error, number multiples inter-spot distance spot must move placed new array coordinates.","code":""},{"path":"/reference/dot-add_error_metrics.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Add error metrics related to array-coordinate mapping — .add_error_metrics","text":"Nicholas J. Eagles","code":""},{"path":"/reference/dot-clean_round.html","id":null,"dir":"Reference","previous_headings":"","what":"Round to the nearest integer, always rounding up at 0.5 — .clean_round","title":"Round to the nearest integer, always rounding up at 0.5 — .clean_round","text":"consistent behavior favorable application, want minimize duplicate mappings spots new array coordinates.","code":""},{"path":"/reference/dot-clean_round.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Round to the nearest integer, always rounding up at 0.5 — .clean_round","text":"","code":".clean_round(x)"},{"path":"/reference/dot-clean_round.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Round to the nearest integer, always rounding up at 0.5 — .clean_round","text":"x numeric() vector.","code":""},{"path":"/reference/dot-clean_round.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Round to the nearest integer, always rounding up at 0.5 — .clean_round","text":"numeric() vector rounded nearest integer.","code":""},{"path":"/reference/dot-clean_round.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Round to the nearest integer, always rounding up at 0.5 — .clean_round","text":"Nicholas J. Eagles","code":""},{"path":"/reference/dot-fit_to_array.html","id":null,"dir":"Reference","previous_headings":"","what":"Fit spots to a new Visium-like array — .fit_to_array","title":"Fit spots to a new Visium-like array — .fit_to_array","text":"Given transformed pixel coordinates, modify 'array_row' 'array_col' columns represent larger Visium capture area containing capture areas common coordinate system. number array rows/cols generally changes Visium standards 78 128 (even may change ratio num rows num cols).","code":""},{"path":"/reference/dot-fit_to_array.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Fit spots to a new Visium-like array — .fit_to_array","text":"","code":".fit_to_array(coords, inter_spot_dist_px)"},{"path":"/reference/dot-fit_to_array.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Fit spots to a new Visium-like array — .fit_to_array","text":"coords data.frame() whose rows represent capture areas group, containing columns 'array_row', 'array_col', 'pxl_row_in_fullres', 'pxl_col_in_fullres'. inter_spot_dist_px numeric(1) vector giving pixel distance 2 spots new coordinates.","code":""},{"path":"/reference/dot-fit_to_array.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Fit spots to a new Visium-like array — .fit_to_array","text":"tibble modified array_row + array_col columns, well new pxl_row_in_fullres_rounded pxl_col_in_fullres_rounded columns representing pixel coordinates rounded nearest exact array coordinates.","code":""},{"path":"/reference/dot-fit_to_array.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Fit spots to a new Visium-like array — .fit_to_array","text":"Runtime O(n) number spots, making much faster say, distance-matrix-based approach running O(n^2).","code":""},{"path":"/reference/dot-fit_to_array.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Fit spots to a new Visium-like array — .fit_to_array","text":"Nicholas J. Eagles","code":""},{"path":"/reference/dot-get_neighbors.html","id":null,"dir":"Reference","previous_headings":"","what":"Get keys of neighboring spots — .get_neighbors","title":"Get keys of neighboring spots — .get_neighbors","text":"given row tibble() containing array coordinates, find associated spot's neighbors (belonging capture area) return keys.","code":""},{"path":"/reference/dot-get_neighbors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Get keys of neighboring spots — .get_neighbors","text":"","code":".get_neighbors(i, coords)"},{"path":"/reference/dot-get_neighbors.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Get keys of neighboring spots — .get_neighbors","text":"integer(1) giving row index coords. coords tibble() containing array_row, array_col, key, capture_area columns.","code":""},{"path":"/reference/dot-get_neighbors.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Get keys of neighboring spots — .get_neighbors","text":"character() neighboring spot keys.","code":""},{"path":"/reference/dot-get_neighbors.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Get keys of neighboring spots — .get_neighbors","text":"Nicholas J. Eagles","code":""},{"path":"/reference/dot-get_shared_neighbors.html","id":null,"dir":"Reference","previous_headings":"","what":"Calculate fraction of neighbors retained after mapping to new array coordinates — .get_shared_neighbors","title":"Calculate fraction of neighbors retained after mapping to new array coordinates — .get_shared_neighbors","text":"Given tibble()s mapping new array coordinates, calculate spot fraction starting neighboring spots retained new array-coordinate system. Add metric return.","code":""},{"path":"/reference/dot-get_shared_neighbors.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Calculate fraction of neighbors retained after mapping to new array coordinates — .get_shared_neighbors","text":"","code":".get_shared_neighbors(coords_new, coords)"},{"path":"/reference/dot-get_shared_neighbors.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Calculate fraction of neighbors retained after mapping to new array coordinates — .get_shared_neighbors","text":"coords_new tibble() containing array_row, array_col, key, capture_area columns, representing data mapping new array coordinates. coords tibble() containing array_row, array_col, key, capture_area columns, representing data mapping new array coordinates.","code":""},{"path":"/reference/dot-get_shared_neighbors.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Calculate fraction of neighbors retained after mapping to new array coordinates — .get_shared_neighbors","text":"tibble() copy coords_new additional shared_neighbors column.","code":""},{"path":"/reference/dot-get_shared_neighbors.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Calculate fraction of neighbors retained after mapping to new array coordinates — .get_shared_neighbors","text":"Nicholas J. Eagles","code":""},{"path":"/reference/dot-refine_fit.html","id":null,"dir":"Reference","previous_headings":"","what":"Return array coordinates fit to nearest spot with associated error — .refine_fit","title":"Return array coordinates fit to nearest spot with associated error — .refine_fit","text":"First, values x rounded nearest integer. , values y rounded nearest valid integer constraint coordinates x y must odd even. rounded values returned, along Euclidean distance needed move x y original, non-integer values rounded values.","code":""},{"path":"/reference/dot-refine_fit.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Return array coordinates fit to nearest spot with associated error — .refine_fit","text":"","code":".refine_fit(x, y, INTERVAL_X, INTERVAL_Y)"},{"path":"/reference/dot-refine_fit.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Return array coordinates fit to nearest spot with associated error — .refine_fit","text":"x numeric() vector giving \"ideal\" array coordinates given every spot's transformed pixel coordinates. y x, though y must represent ideal array columns iff x represents array rows, vice versa. INTERVAL_X numeric(1) giving pixel distance coordinate units used x (e.g. x represents ideal array_col values, INTERVAL_X represents pixel distance spot columns). INTERVAL_Y numeric(1) giving pixel distance coordinate units used y.","code":""},{"path":"/reference/dot-refine_fit.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Return array coordinates fit to nearest spot with associated error — .refine_fit","text":"list consisting 3 unnamed numeric() vectors: rounded x, rounded y, Euclidean distance pixels rounding x y.","code":""},{"path":"/reference/dot-refine_fit.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Return array coordinates fit to nearest spot with associated error — .refine_fit","text":"Nicholas J. Eagles","code":""},{"path":"/reference/dot-validate_array.html","id":null,"dir":"Reference","previous_headings":"","what":"Check if coordinates are Visium-like — .validate_array","title":"Check if coordinates are Visium-like — .validate_array","text":"Sanity check designed catch unforeseen bugs: halt tibble-like coords, expected contain columns 'array_row' 'array_col', represents invalid Visium array.","code":""},{"path":"/reference/dot-validate_array.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Check if coordinates are Visium-like — .validate_array","text":"","code":".validate_array(coords)"},{"path":"/reference/dot-validate_array.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Check if coordinates are Visium-like — .validate_array","text":"coords data.frame() containing 'array_row' 'array_col' columns calculated internally add_array_coords().","code":""},{"path":"/reference/dot-validate_array.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Check if coordinates are Visium-like — .validate_array","text":"returns NULL tests correct.","code":""},{"path":"/reference/dot-validate_array.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Check if coordinates are Visium-like — .validate_array","text":"Nicholas J. Eagles","code":""},{"path":"/reference/merge_overlapping.html","id":null,"dir":"Reference","previous_headings":"","what":"Merge overlapping spots — merge_overlapping","title":"Merge overlapping spots — merge_overlapping","text":"Given stitched SpatialExperiment-class, merge overlapping (array coordinates) spots adding expression (.e. assays(spe)$counts), returning SpatialExperiment one spot per array location.","code":""},{"path":"/reference/merge_overlapping.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Merge overlapping spots — merge_overlapping","text":"","code":"merge_overlapping(spe)"},{"path":"/reference/merge_overlapping.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Merge overlapping spots — merge_overlapping","text":"spe SpatialExperiment-class colData(spe) columns array_row, array_col, key, group, capture_area.","code":""},{"path":"/reference/merge_overlapping.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Merge overlapping spots — merge_overlapping","text":"SpatialExperiment one spot per array location","code":""},{"path":"/reference/merge_overlapping.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Merge overlapping spots — merge_overlapping","text":"colData(spe) spatialCoords(spe) merged spots taken spots whose exclude_overlapping values TRUE.","code":""},{"path":"/reference/merge_overlapping.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Merge overlapping spots — merge_overlapping","text":"Nicholas J. Eagles","code":""},{"path":"/reference/merge_overlapping.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Merge overlapping spots — merge_overlapping","text":"","code":"if (!exists(\"spe\")) { spe <- spatialLIBD::fetch_data(type = \"visiumStitched_brain_spe\") } #> 2024-10-24 20:16:27.531784 loading file /github/home/.cache/R/BiocFileCache/760d7e2c6_visiumStitched_brain_spe.rds%3Frlkey%3Dnq6a82u23xuu9hohr86oodwdi%26dl%3D1 # Group colData by group and array coordinates grouped_coldata = colData(spe) |> dplyr::as_tibble() |> dplyr::group_by(group, array_row, array_col) # Find the first 100 keys that overlap other spots and don't, respectively overlapping_keys = grouped_coldata |> dplyr::filter(dplyr::n() > 1) |> dplyr::slice_head(n = 2) |> dplyr::ungroup() |> dplyr::slice_head(n = 100) |> dplyr::pull(key) nonoverlapping_keys = grouped_coldata |> dplyr::filter(dplyr::n() == 1) |> dplyr::ungroup() |> dplyr::slice_head(n = 100) |> dplyr::pull(key) # Built a small SPE containing some overlaps and some non-overlapping spots small_spe = spe[, c(overlapping_keys, nonoverlapping_keys)] # Merge overlapping spots small_spe_merged = merge_overlapping(small_spe) #> Warning: Dropping assays other than 'counts' for merging. #> Warning: Dropped reducedDims(spe) for merging #> 'sample_id's are duplicated across 'SpatialExperiment' objects to cbind; appending sample indices. # All array coordinates have just one unique spot after merging colData(small_spe_merged) |> dplyr::as_tibble() |> dplyr::group_by(group, array_row, array_col) |> dplyr::summarize(n = dplyr::n()) |> dplyr::pull(n) |> table() #> `summarise()` has grouped output by 'group', 'array_row'. You can override #> using the `.groups` argument. #> #> 1 #> 142"},{"path":"/reference/prep_fiji.html","id":null,"dir":"Reference","previous_headings":"","what":"Prepare Fiji outputs for building a SpatialExperiment — prep_fiji","title":"Prepare Fiji outputs for building a SpatialExperiment — prep_fiji","text":"Together, prep_fiji_image() prep_fiji_coords() process Fiji outputs generate one directory per group resembling Spaceranger's spatial outputs; particular, tissue_positions.csv, tissue_lowres_image.png, scalefactors_json.json files created. functions necessary run preparation build_SpatialExperiment().","code":""},{"path":"/reference/prep_fiji.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Prepare Fiji outputs for building a SpatialExperiment — prep_fiji","text":"","code":"prep_fiji_image(sample_info, out_dir, lowres_max_size = 1200) prep_fiji_coords(sample_info, out_dir)"},{"path":"/reference/prep_fiji.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Prepare Fiji outputs for building a SpatialExperiment — prep_fiji","text":"sample_info data.frame() columns capture_area, group, fiji_xml_path, fiji_image_path, spaceranger_dir, intra_group_scalar, group_hires_scalef. last two made rescale_fiji_inputs(). out_dir character(1) vector giving path directory place output pixel coordinates CSVs. must exist advance. lowres_max_size integer(1) vector: resolution (number pixels) larger dimension output image(s), considered \"low resolution\". default value 1200 assumes stitching together 2 2 grid Visium capture areas, 600 pixels longest dimension (default SpaceRanger).","code":""},{"path":"/reference/prep_fiji.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Prepare Fiji outputs for building a SpatialExperiment — prep_fiji","text":"function returns character() file paths files created. prep_fiji_coords(), tissue_positions.csv files; prep_fiji_image(), tissue_lowres_image.png scalefactors_json.json files.","code":""},{"path":"/reference/prep_fiji.html","id":"details","dir":"Reference","previous_headings":"","what":"Details","title":"Prepare Fiji outputs for building a SpatialExperiment — prep_fiji","text":"Given data.frame() sample information (sample_info) columns capture_area, group, fiji_xml_path, expected one unique path Fiji XML output per group, prep_fiji_coords reads pixel coordinates capture area's tissue_positions.csv file SpaceRanger, transform using rotation matrix specified Fiji https://imagej.net/software/fiji/. writes one new tissue_positions.csv file per group. stitching groups sample_info Fiji, images various resolutions (pixel dimensions) left. prep_fiji_image() creates copies image whose largest dimension lowres_max_size pixels. also creates corresponding scalefactors_json.json file much like SpaceRanger's.","code":""},{"path":"/reference/prep_fiji.html","id":"functions","dir":"Reference","previous_headings":"","what":"Functions","title":"Prepare Fiji outputs for building a SpatialExperiment — prep_fiji","text":"prep_fiji_image(): Create low-res images scale factors high-res Fiji output images prep_fiji_coords(): Apply transform info Fiji XML output","code":""},{"path":"/reference/prep_fiji.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Prepare Fiji outputs for building a SpatialExperiment — prep_fiji","text":"Nicholas J. Eagles","code":""},{"path":"/reference/prep_fiji.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Prepare Fiji outputs for building a SpatialExperiment — prep_fiji","text":"","code":"sample_info <- dplyr::tibble( group = \"Br2719\", capture_area = c(\"V13B23-283_A1\", \"V13B23-283_C1\", \"V13B23-283_D1\") ) # Add 'spaceranger_dir' column sr_dir <- tempdir() temp <- unzip( spatialLIBD::fetch_data(\"visiumStitched_brain_spaceranger\"), exdir = sr_dir ) #> 2024-10-24 20:16:39.11547 loading file /github/home/.cache/R/BiocFileCache/7603a007f35_visiumStitched_brain_spaceranger.zip%3Frlkey%3Dbdgjc6mgy1ierdad6h6v5g29c%26dl%3D1 sample_info$spaceranger_dir <- file.path( sr_dir, sample_info$capture_area, \"outs\", \"spatial\" ) # Add Fiji-output-related columns fiji_dir <- tempdir() temp <- unzip( spatialLIBD::fetch_data(\"visiumStitched_brain_Fiji_out\"), exdir = fiji_dir ) #> 2024-10-24 20:16:41.501629 loading file /github/home/.cache/R/BiocFileCache/76048672d76_visiumStitched_brain_fiji_out.zip%3Frlkey%3Dptwal8f5zxakzejwd0oqw0lhj%26dl%3D1 sample_info$fiji_xml_path <- temp[grep(\"xml$\", temp)] sample_info$fiji_image_path <- temp[grep(\"png$\", temp)] ## Re-size images and add more information to the sample_info sample_info <- rescale_fiji_inputs(sample_info, out_dir = tempdir()) spe_input_dir <- tempdir() out_paths_image <- prep_fiji_image( sample_info, out_dir = spe_input_dir, lowres_max_size = 1000 ) out_path_coords <- prep_fiji_coords(sample_info, out_dir = spe_input_dir) # A \"low resolution\" stitched image was produced, which has 1000 # pixels in its largest dimension this_image <- imager::load.image( file.path(spe_input_dir, \"Br2719\", \"tissue_lowres_image.png\") ) dim(this_image) #> [1] 461 1000 1 3 library(\"imager\") #> Loading required package: magrittr #> #> Attaching package: ‘magrittr’ #> The following object is masked from ‘package:GenomicRanges’: #> #> subtract #> #> Attaching package: ‘imager’ #> The following object is masked from ‘package:magrittr’: #> #> add #> The following objects are masked from ‘package:SummarizedExperiment’: #> #> resize, width #> The following object is masked from ‘package:Biobase’: #> #> channel #> The following objects are masked from ‘package:GenomicRanges’: #> #> resize, width #> The following objects are masked from ‘package:IRanges’: #> #> resize, width #> The following object is masked from ‘package:S4Vectors’: #> #> width #> The following object is masked from ‘package:BiocGenerics’: #> #> width #> The following objects are masked from ‘package:stats’: #> #> convolve, spectrum #> The following object is masked from ‘package:graphics’: #> #> frame #> The following object is masked from ‘package:base’: #> #> save.image plot(this_image) # 'prep_fiji_image' produced an image and scalefactors out_paths_image #> [1] \"/tmp/RtmpphIhEc/Br2719/tissue_lowres_image.png\" #> [2] \"/tmp/RtmpphIhEc/Br2719/scalefactors_json.json\" # 'prep_fiji_coords' produced a file of spatial coordinates for the # stitched Br2719 readr::read_csv(out_path_coords) #> Rows: 14976 Columns: 6 #> ── Column specification ──────────────────────────────────────────────────────── #> Delimiter: \",\" #> chr (1): key #> dbl (5): in_tissue, array_row, array_col, pxl_row_in_fullres, pxl_col_in_ful... #> #> ℹ Use `spec()` to retrieve the full column specification for this data. #> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message. #> # A tibble: 14,976 × 6 #> key in_tissue array_row array_col pxl_row_in_fullres pxl_col_in_fullres #> #> 1 ACGCCTGA… 1 0 0 52935. 1873. #> 2 TACCGATC… 1 1 1 52797. 2115. #> 3 ATTAAAGC… 1 0 2 52658. 1873. #> 4 GATAAGGG… 1 1 3 52519. 2115. #> 5 GTGCAAAT… 1 0 4 52381. 1874. #> 6 TGTTGGCT… 1 1 5 52242. 2115. #> 7 GCATCCTC… 1 0 6 52104. 1874. #> 8 GCGAGGGA… 1 1 7 51965. 2115. #> 9 TGGTACCG… 1 0 8 51826. 1874. #> 10 GCGCGTTT… 1 1 9 51688. 2115. #> # ℹ 14,966 more rows"},{"path":"/reference/rescale_fiji_inputs.html","id":null,"dir":"Reference","previous_headings":"","what":"Write same-scale hires images for input to Fiji — rescale_fiji_inputs","title":"Write same-scale hires images for input to Fiji — rescale_fiji_inputs","text":"Given data.frame() sample information (sample_info) columns capture_area, group, spaceranger_dir, Write new high-resolution images use input Fiji https://imagej.net/software/fiji/. Particularly capture areas come different slides, risk significant scale differences among SpaceRanger's tissue_hires_image.png images; , physical distance represented pixel capture area may differ nontrivially, leading distance-distorted output image, inconsistent scaling later transforming pixel coordinates. function writes approximately high-res images whose pixels equal physical size within group, adds intra_group_scalar group_hires_scalef columns sample_info. intra_group_scalar gives scalar given capture area's tissue_hires_image.png image pixel coordinates must multiplied match scale group members; group_hires_scalef gives new tissue_hires_scalef (SpaceRanger's scalefactors_json.json file) appropriate every capture area group.","code":""},{"path":"/reference/rescale_fiji_inputs.html","id":"ref-usage","dir":"Reference","previous_headings":"","what":"Usage","title":"Write same-scale hires images for input to Fiji — rescale_fiji_inputs","text":"","code":"rescale_fiji_inputs(sample_info, out_dir)"},{"path":"/reference/rescale_fiji_inputs.html","id":"arguments","dir":"Reference","previous_headings":"","what":"Arguments","title":"Write same-scale hires images for input to Fiji — rescale_fiji_inputs","text":"sample_info data.frame() columns capture_area, group, fiji_xml_path, fiji_image_path, spaceranger_dir, intra_group_scalar, group_hires_scalef. last two made rescale_fiji_inputs(). out_dir character(1) vector giving path directory place output images, must exist advance.","code":""},{"path":"/reference/rescale_fiji_inputs.html","id":"value","dir":"Reference","previous_headings":"","what":"Value","title":"Write same-scale hires images for input to Fiji — rescale_fiji_inputs","text":"tibble: copy sample_info additional columns intra_group_scalar group_hires_scalef.","code":""},{"path":"/reference/rescale_fiji_inputs.html","id":"author","dir":"Reference","previous_headings":"","what":"Author","title":"Write same-scale hires images for input to Fiji — rescale_fiji_inputs","text":"Nicholas J. Eagles","code":""},{"path":"/reference/rescale_fiji_inputs.html","id":"ref-examples","dir":"Reference","previous_headings":"","what":"Examples","title":"Write same-scale hires images for input to Fiji — rescale_fiji_inputs","text":"","code":"# Define sample information for the example human brain data sample_info <- dplyr::tibble( group = \"Br2719\", capture_area = c(\"V13B23-283_A1\", \"V13B23-283_C1\", \"V13B23-283_D1\") ) # Add 'spaceranger_dir' column sr_dir <- tempdir() temp <- unzip( spatialLIBD::fetch_data(\"visiumStitched_brain_spaceranger\"), exdir = sr_dir ) #> 2024-10-24 20:16:55.189005 loading file /github/home/.cache/R/BiocFileCache/7603a007f35_visiumStitched_brain_spaceranger.zip%3Frlkey%3Dbdgjc6mgy1ierdad6h6v5g29c%26dl%3D1 sample_info$spaceranger_dir <- file.path( sr_dir, sample_info$capture_area, \"outs\", \"spatial\" ) # Add Fiji-output-related columns fiji_dir <- tempdir() temp <- unzip( spatialLIBD::fetch_data(\"visiumStitched_brain_Fiji_out\"), exdir = fiji_dir ) #> 2024-10-24 20:16:57.70092 loading file /github/home/.cache/R/BiocFileCache/76048672d76_visiumStitched_brain_fiji_out.zip%3Frlkey%3Dptwal8f5zxakzejwd0oqw0lhj%26dl%3D1 sample_info$fiji_xml_path <- temp[grep(\"xml$\", temp)] sample_info$fiji_image_path <- temp[grep(\"png$\", temp)] ## Re-size images and add more information to the sample_info out_dir <- tempdir() sample_info_new <- rescale_fiji_inputs(sample_info, out_dir = out_dir) # Scale factors are computed that are necessary downstream (i.e. with # prep_fiji_*() functions) sample_info_new[, setdiff(colnames(sample_info_new), colnames(sample_info))] #> # A tibble: 3 × 2 #> intra_group_scalar group_hires_scalef #> #> 1 1.00 0.0825 #> 2 1.00 0.0825 #> 3 1 0.0825 # Image are produced that are ready for alignment in Fiji list.files(out_dir) #> [1] \"Br2719\" #> [2] \"Br2719.png\" #> [3] \"Br2719.xml\" #> [4] \"HDF5Array_dataset_creation_global_counter\" #> [5] \"HDF5Array_dump\" #> [6] \"HDF5Array_dump_log\" #> [7] \"HDF5Array_dump_names_global_counter\" #> [8] \"V13B23-283_A1\" #> [9] \"V13B23-283_A1.png\" #> [10] \"V13B23-283_C1\" #> [11] \"V13B23-283_C1.png\" #> [12] \"V13B23-283_D1\" #> [13] \"V13B23-283_D1.png\" #> [14] \"bslib-5ff8f344b905f9ef2a33199151429212\" #> [15] \"downlit\" #> [16] \"file363713b563ec\" #> [17] \"file36373384864b\" #> [18] \"file36373a2556b5\" #> [19] \"file36374b3b5235\" #> [20] \"file363755368c23\" #> [21] \"file36377985d4b\""},{"path":"/news/index.html","id":"visiumstitched-0990","dir":"Changelog","previous_headings":"","what":"visiumStitched 0.99.0","title":"visiumStitched 0.99.0","text":"NEW FEATURES Initial version visiumStiched package provides utilities stitching together Visium capture areas enables seamless downstream spatially-aware clustering methods identify clusters stitched data. example postmortem human brain dataset composed 3 Visium capture areas generated demonstrate utility visiumStitched. dataset available spatiaLIBD::fetch_data() version 1.17.8 newer. example data described https://research.libd.org/visiumStitched_brain/.","code":""}]