diff --git a/components/dictionary.txt b/components/dictionary.txt index 5b90d240..b28f1eef 100644 --- a/components/dictionary.txt +++ b/components/dictionary.txt @@ -84,6 +84,7 @@ codebook codeword codewords colData +colocalize colorectal colour ComplexHeatmap @@ -304,6 +305,7 @@ Menyhárt mer merchantability MERFISH +MERSCOPE mesenchymal mesoderm metacell @@ -344,6 +346,7 @@ myocytes myoepithelial myofibroblast myogenesis +NanoString natively NCI nd @@ -494,6 +497,7 @@ Srivastava SRP SRR StackOverflow +STARmap StatQuest Stoeckius str @@ -566,6 +570,7 @@ versicolor virginica Visium vitro +Vizgen VST Wattenberg WCSS diff --git a/module-cheatsheets/spatial-cheatsheet.md b/module-cheatsheets/spatial-cheatsheet.md index b9bb565e..4520ef24 100644 --- a/module-cheatsheets/spatial-cheatsheet.md +++ b/module-cheatsheets/spatial-cheatsheet.md @@ -20,12 +20,15 @@ If you have a different version of R or other R packages, the documentation may - [`SpotSweeper`](#spotsweeper) - [`Banksy`](#banksy) - [`spacexr`](#spacexr) +- [`SpatialExperimentIO`](#spatialexperimentio) +- [`hoodscanR`](#hoodscanr) - [`scuttle`, `scran`, and `scater`](#scuttle-scran-and-scater) - [`bluster`](#bluster) - [`patchwork`](#patchwork) - [`pals`](#pals) - [`pheatmap`](#pheatmap) - [`purrr`](#purrr) +- [`ComplexHeatmap`](#complexheatmap) @@ -125,6 +128,40 @@ Read the [`spacexr` package documentation](https://www.bioconductor.org/packages
+### `SpatialExperimentIO` + + +Read the [`SpatialExperimentIO` package documentation](https://www.bioconductor.org/packages/release/bioc/html/SpatialExperimentIO.html) and a [vignette on its usage](https://www.bioconductor.org/packages/release/bioc/vignettes/SpatialExperimentIO/inst/doc/SpatialExperimentIO.html). + +This package provides reader functions for imaging-based spatial transcriptomics platforms, including Xenium (10x Genomics), CosMx (NanoString), MERSCOPE (Vizgen), and STARmap PLUS. + + +| Library/Package | Piece of Code | What it's called | What it does | +|----------------------|----------------------------|--------------------------------------------|--------------------------------------------------------------| +| `SpatialExperimentIO` | [`readXeniumSXE()`](https://www.bioconductor.org/packages/release/bioc/vignettes/SpatialExperimentIO/inst/doc/SpatialExperimentIO.html#xenium) | Read Xenium into a Spatial Experiment | Loads an unzipped 10x Genomics Xenium output bundle directory into a `SpatialExperiment` object | + + + +### `hoodscanR` + + +Read the [`hoodscanR` package documentation](https://www.bioconductor.org/packages/release/bioc/html/hoodscanR.html) and a [vignette on its usage](https://www.bioconductor.org/packages/release/bioc/vignettes/hoodscanR/inst/doc/Quick_start.html). + +Note that the functions in this package are generally run in sequence, where the output of one function is the input to the next. + + +| Library/Package | Piece of Code | What it's called | What it does | +|----------------------|----------------------------|--------------------------------------------|--------------------------------------------------------------| +| `hoodscanR` | [`findNearCells()`](https://davislaboratory.github.io/hoodscanR/reference/findNearCells.html) | Find the k-the nearest cells for each | Find the `k` nearest cells to each cell in a `SpatialExperiment` object, returning a list with a matrix of distances and a matrix of the annotations (e.g., cell types) of those neighboring cells | +| `hoodscanR` | [`scanHoods()`](https://davislaboratory.github.io/hoodscanR/reference/scanHoods.html) | Scan cellular neighborhoods | Apply a modified softmax algorithm to the distance matrix from `hoodscanR::findNearCells()` to calculate the probability that each cell is associated with each of its nearest neighboring cells | +| `hoodscanR` | [`mergeByGroup()`](https://davislaboratory.github.io/hoodscanR/reference/mergeByGroup.html) | Merge probability matrix based on annotations | Collapse the probability matrix from `hoodscanR::scanHoods()` by annotation, so that each column is a group (e.g., a cell type) rather than an individual neighboring cell | +| `hoodscanR` | [`mergeHoodSpe()`](https://davislaboratory.github.io/hoodscanR/reference/mergeHoodSpe.html) | Merge probability matrix into Spatial Experiment object | Add the merged probability matrix into the `colData` of a `SpatialExperiment` object | +| `hoodscanR` | [`calcMetrics()`](https://davislaboratory.github.io/hoodscanR/reference/calcMetrics.html) | Calculate metrics for probability matrix | Calculate the entropy and perplexity of the probability matrix for each cell, which summarize how mixed or how distinct that cell's neighborhood is, and store them in `colData` | +| `hoodscanR` | [`plotColocal()`](https://davislaboratory.github.io/hoodscanR/reference/plotColocal.html) | Plot heatmap for neighborhood analysis | Plot a heatmap of the Pearson correlations between cells' neighborhood probability distributions to show which groups tend to colocalize | +| `hoodscanR` | [`clustByHood()`](https://davislaboratory.github.io/hoodscanR/reference/clustByHood.html) | Cluster the probability matrix with K-means | Perform k-means clustering on the probability matrix to assign each cell to a neighborhood cluster | +| `hoodscanR` | [`plotProbDist()`](https://davislaboratory.github.io/hoodscanR/reference/plotProbDist.html) | Plot probability distribution | Plot the distribution of neighborhood probabilities, optionally split by a grouping variable such as the neighborhood clusters from `hoodscanR::clustByHood()` | + + ### `scuttle`, `scran`, and `scater` @@ -141,6 +178,7 @@ Read the [`scater` package documentation](https://rdrr.io/bioc/scater/), and a [ | `scuttle`| [`addPerCellQC()`](https://rdrr.io/bioc/scuttle/man/addPerCellQC.html)| Add per cell quality control | For a `SingleCellExperiment` object, calculate and add quality control per cell and store in `colData` | | `scuttle` | [`computeLibraryFactors()`](https://rdrr.io/bioc/scuttle/man/librarySizeFactors.html) | Compute Library Factors | Returns a numeric vector of computed size factors for each spot (or cell) stored in a `SpatialExperiment` (or `SingleCellExperiment`) object. The size factor is computed as the library size of each spot/cell after scaling them to have a mean of 1 across all spots/cells | | `scuttle`| [`logNormCounts()`](https://rdrr.io/bioc/scuttle/man/logNormCounts.html)| Normalize log counts | Returns the `SpatialExperiment` (or `SingleCellExperiment`) object with normalized expression values for each spot (cell), using the size factors stored in the object | +| `scuttle`| [`isOutlier()`](https://rdrr.io/bioc/scuttle/man/isOutlier.html)| Identify outliers | Convenience function to determine which values in a numeric vector are outliers based on the median absolute deviation (MAD) | | `scran`| [`getTopHVGs()`](https://rdrr.io/bioc/scran/man/getTopHVGs.html)| Get top highly variable genes | Identify variable genes in a `SingleCellExperiment` object, based on variance | | `scran`| [`modelGeneVar()`](https://rdrr.io/bioc/scran/man/modelGeneVar.html)| model per gene variance | Model the per gene variance of a `SingleCellExperiment` object | | `scran`| [`clusterCells()`](https://rdrr.io/github/MarioniLab/scran/man/clusterCells.html)| Cluster cells | Perform clustering on an SCE object using the `bluster` package | @@ -148,7 +186,6 @@ Read the [`scater` package documentation](https://rdrr.io/bioc/scater/), and a [ | `scater`| [`runUMAP()`](https://rdrr.io/bioc/scater/man/runUMAP.html)| Run UMAP | Calculates uniform manifold approximate projection on a `SingleCellExperiment` object, returning an SCE object with a UMAP reduced dimension | | `scater`| [`plotUMAP()`](https://rdrr.io/bioc/scater/man/plot_reddim.html)| Plot UMAP | Plot the "UMAP"-named reduced dimension slot from a `SingleCellExperiment` object | - @@ -216,4 +253,14 @@ Read the [`purrr` package documentation](https://purrr.tidyverse.org/) and a [vi |----------------|--------------|-----------------|--------------| | `purrr`| [`map()`](https://purrr.tidyverse.org/reference/map.html)| map | Apply a function across each element of list; return a list | | `purrr`| [`imap()`](https://purrr.tidyverse.org/reference/imap.html)| imap | Apply a function across each element of list and its index/names; return a list | -| `purrr`| [`reduce()`](https://purrr.tidyverse.org/reference/reduce.html)| Reduce | Reduce a list to a single value by repeatedly applying a given function. Can also be used to iteratively modify a single object. | \ No newline at end of file +| `purrr`| [`reduce()`](https://purrr.tidyverse.org/reference/reduce.html)| Reduce | Reduce a list to a single value by repeatedly applying a given function. Can also be used to iteratively modify a single object. | + + +### `ComplexHeatmap` + +Read the [`ComplexHeatmap` package documentation](https://rdrr.io/bioc/ComplexHeatmap/) and the [`ComplexHeatmap` Complete Reference e-book](https://jokergoo.github.io/ComplexHeatmap-reference/book/). + + +| Library/Package | Piece of Code | What it's called | What it does | +|----------------------|--------------------|---------------------|---------------| +| `ComplexHeatmap`| [`Heatmap()`](https://rdrr.io/bioc/ComplexHeatmap/man/Heatmap.html)| Heatmap | Create a clustered heatmap from a matrix, with options to split, annotate, and combine it with other heatmaps | diff --git a/module-cheatsheets/spatial-cheatsheet.pdf b/module-cheatsheets/spatial-cheatsheet.pdf index 75da95f0..d2b921e5 100644 Binary files a/module-cheatsheets/spatial-cheatsheet.pdf and b/module-cheatsheets/spatial-cheatsheet.pdf differ diff --git a/spatial/05-xenium_processing.Rmd b/spatial/05-xenium_processing.Rmd index 2d8d93a6..f5a0ea1a 100644 --- a/spatial/05-xenium_processing.Rmd +++ b/spatial/05-xenium_processing.Rmd @@ -12,7 +12,7 @@ output: - Read Xenium data into R - Calculate quality control measures on imaging spatial transcriptomic data -- Remove likely low-quality spots with `SpaceTrooper()` +- Remove likely low-quality spots - Normalize spatial expression data ## Introduction @@ -398,7 +398,7 @@ p1 + p2 ``` To flag these cells, we summarize each cell by its counts-per-area ratio and look for cells that sit far below the bulk of the distribution. -Specifically, we use `scater::isOutlier()` to flag cells whose ratio falls more than three median absolute deviations (MADs) below the median. +Specifically, we use `scuttle::isOutlier()` to flag cells whose ratio falls more than three median absolute deviations (MADs) below the median. * The MAD is a robust measure of spread and is less sensitive to extreme values than the standard deviation. * We will use the common cutoff of 3 * MAD. @@ -412,7 +412,7 @@ count_area_ratio <- spe$total_counts / spe$cell_area # flag cells that are outliers on the low side # (3 median absolute deviations below the median, on the log2 scale since the metric is a ratio) -outliers <- scater::isOutlier(count_area_ratio, log = TRUE, type = "lower", nmads = 3) +outliers <- scuttle::isOutlier(count_area_ratio, log = TRUE, type = "lower", nmads = 3) # print the structure which tells us where to find the identified threshold str(outliers)