Spatial Transcriptomics

The Jackson Laboratory for Genomic Medicine

Aug 13-14, 2024

9am - 4pm

Instructors: Antonios Somarakis, Brian White, Dan Gatti, Elaheh Alizadeh, Sue McClatchy

Helpers: Asli Uyar

General Information

Spatially resolved transcriptomics is a cutting-edge molecular profiling technology that measures transcript expression and position within a tissue. This course will teach you how to analyze spatial transcriptomics data generated by the 10X Genomics Visium platform. By the end of this course, you will be able to:

For more information about what this course covers, see the lesson material.

Who: The course is aimed at researchers who would like to analyze spatial transcriptomics data. External collaborators are welcome to participate.

Prerequisites: You should be proficient in R and have prior knowledge of bulk and single-cell RNA sequencing to succeed in this course.

Where: 10 Discovery Drive, Farmington, CT. Get directions with OpenStreetMap or Google Maps.

When: Aug 13-14, 2024. Add to your Google Calendar.

Requirements: Participants must bring a laptop with a Mac, Linux, or Windows operating system (not a tablet, Chromebook, etc.). They should have a few specific software packages installed (listed below).

Accessibility: We are committed to making this workshop accessible to everybody. For workshops at a physical location, the workshop organizers have checked that:

Materials will be provided in advance of the workshop and large-print handouts are available if needed by notifying the organizers in advance. If we can help making learning easier for you (e.g. sign-language interpreters, lactation facilities) please get in touch (using contact details below) and we will attempt to provide them.

Contact: Please email susan.mcclatchy@jax.org for more information.


Collaborative Notes

We will use this collaborative document for chatting, taking notes, and sharing URLs and bits of code.


Surveys

Please be sure to complete this survey after the workshop.

Post-workshop Survey


Schedule

Tuesday, Aug 13

08:30 Software troubleshooting/setup (optional)
09:00 Overview and introductions
09:15 Spatially Resolved Transcriptomics in Life Sciences Research
09:30 Data and Study Design
10:00 Data Preprocessing
10:30 Morning break
10:45 Data Preprocessing (continued)
11:50 Remove Low-quality Spots
12:00 Lunch break
13:00 Remove Low-quality Spots (continued)
14:05 Normalization in Spatial Transcriptomics
14:45 Afternoon break
15:00 Normalization in Spatial Transcriptomics (continued)
15:45 Wrap-up
16:00 END

Wednesday, Aug 14

09:00 Welcome back & recap of day 1
09:20 Feature Selection, Dimensionality Reduction, and Spot Clustering
10:45 Morning break
11:00 Deconvolution in Spatial Transcriptomics
12:00 Lunch break
13:00 Differential Expression Testing
14:10 Challenge: Run the pipeline on another sample
14:45 Afternoon break
15:00 Challenge (continued)
15:45 Wrap-up
15:55 Post-workshop Survey
16:00 END

Setup

To participate in a workshop, you will need access to software as described below. In addition, you will need an up-to-date web browser.

We maintain a list of common issues that occur during installation as a reference for instructors that may be useful on the Configuration Problems and Solutions wiki page.

R

R is a programming language that is especially powerful for data exploration, visualization, and statistical analysis. To interact with R, we use RStudio.

Install R by downloading and running this .exe file from CRAN. Also, please install the RStudio IDE. Note that if you have separate user and admin accounts, you should run the installers as administrator (right-click on .exe file and select "Run as administrator" instead of double-clicking). Otherwise problems may occur later, for example when installing R packages.

Video Tutorial

Instructions for R installation on various Linux platforms (debian, fedora, redhat, and ubuntu) can be found at <https://cran.r-project.org/bin/linux/>. These will instruct you to use your package manager (e.g. for Fedora run sudo dnf install R and for Debian/Ubuntu, add a ppa repository and then run sudo apt-get install r-base). Also, please install the RStudio IDE.

R Packages

Next, we will install the required packages for this lesson. Note that the spacexr package takes a long time to download. It may take up to 30 minutes for it to install.

In RStudio, copy and paste the following commands into the Console:

pkgs <- c("BiocManager", "data.table",  "ggExtra", "hdf5r",
          "here",        "igraph",      "leiden", "Matrix", "matrixStats", 
          "plyr",        "rcartocolor", "remotes",
          "Rfast2",      "Seurat",      "tidyverse", "R.utils")
for(pkg in pkgs) {
  if(!require(pkg, character.only=TRUE)) {
    install.packages(pkg, dependencies = TRUE)
  }
}
BiocManager::install(c("glmGamPoi", "rhdf5", "ComplexHeatmap"))

options(timeout = 1e6)
remotes::install_github("immunogenomics/presto",  build_vignettes = FALSE)
remotes::install_github("dmcable/spacexr",        build_vignettes = FALSE)

Once the installation has finished, copy and paste the following commands into the console to verify that both packages installed correctly.

library(BiocManager)
library(data.table)
library(R.utils)
library(hdf5r)
library(here)
library(presto)
library(rcartocolor)
library(remotes)
library(spacexr)
library(sparseMatrixStats)
library(Seurat)
library(tidyverse)
library(ComplexHeatmap)

Project Setup

  1. Create a new project called spatialRNA. Click the File menu button, then New Project. Click New Directory. Click New Project. Type spatialRNA as the directory name. Create the project anywhere you like, but don’t forget where you put it! Your desktop might be a handy place. Click the Create Project button. This will create a file called spatialRNA.Rproj in the directory you just created. In the future you can double-click on this file to open RStudio in this directory. This will be the easiest way to interact with the files/code you produce in this workshop.

  2. Create a data directory to hold the data, a scripts directory to house your scripts, and a results directory to hold results. You can use the Files tab at lower right to create these directories.

Alternatively, you can copy-paste the following into the R console for step 2 only. You still need to create a project with step 1.

dir.create("data")
dir.create("scripts")
dir.create("results")

Data Set Download

We will be working with brain data from Maynard et al., Nature Neuroscience, 2021. We have created links on Box from which you can download the data. Once you have opened your spatialRNA project in RStudio, copy-paste the code below into the console to download the data into your data directory.

dir.create("data/151508/spatial", recursive = TRUE)
download.file(url      = "https://thejacksonlaboratory.box.com/shared/static/vfbgloxx9ciu04hj9i9f5jjzglfrx0by.h5",
              destfile = "data/151508/151508_raw_feature_bc_matrix.h5",
              mode     = "wb")
download.file(url      = "https://thejacksonlaboratory.box.com/shared/static/puetvwocuf14kzyogtds7y1o7cme8dvp.h5",
              destfile = "data/151508/151508_filtered_feature_bc_matrix.h5",
              mode     = "wb")
download.file(url      = "https://thejacksonlaboratory.box.com/shared/static/zxulmiupeurvrmwe0tz1y0hslzrsj4wb.json",
              destfile = "data/151508/spatial/scalefactors_json.json",
              mode     = "wb")
download.file(url      = "https://thejacksonlaboratory.box.com/shared/static/w1bjdguo3emfb5uvwlys26yrudw08dm0.png",
              destfile = "data/151508/spatial/tissue_hires_image.png",
              mode     = "wb")
download.file(url      = "https://thejacksonlaboratory.box.com/shared/static/xgmx8tqdfjndejr1hp3r29r4531rd6s2.png",
              destfile = "data/151508/spatial/tissue_lowres_image.png",
              mode     = "wb")
download.file(url      = "https://thejacksonlaboratory.box.com/shared/static/gw2e7d47tihg25df8hahelrhx42y345o.csv",
              destfile = "data/151508/spatial/tissue_positions_list.csv",
              mode     = "wb")

dir.create("data/151673/spatial", recursive = TRUE)
download.file(url = "https://thejacksonlaboratory.box.com/shared/static/ge38lg6u1i45n3grusrdyd3nccukl489.h5",
              destfile = "data/151673/151673_raw_feature_bc_matrix.h5", mode = "wb")
download.file(url = "https://thejacksonlaboratory.box.com/shared/static/m8btvh1y9tjszfal99k2cvr1f32lh1si.h5",
              destfile = "data/151673/151673_filtered_feature_bc_matrix.h5", mode = "wb")
download.file(url      = "https://thejacksonlaboratory.box.com/shared/static/feb8gnawor51ojh2ci4mlshhxobpnaji.json",
              destfile = "data/151673/spatial/scalefactors_json.json",
              mode     = "wb")
download.file(url      = "https://thejacksonlaboratory.box.com/shared/static/ejyx4qkv62p5t0njwf5z8px2mqcjxnd7.png",
              destfile = "data/151673/spatial/tissue_hires_image.png",
              mode     = "wb")
download.file(url      = "https://thejacksonlaboratory.box.com/shared/static/8tgbt4654zbxwsqr3vwlk64dyzzulhlb.png",
              destfile = "data/151673/spatial/tissue_lowres_image.png",
              mode     = "wb")
download.file(url      = "https://thejacksonlaboratory.box.com/shared/static/drlayml5otq7n2xedndm0qsqly58g306.csv",
              destfile = "data/151673/spatial/tissue_positions_list.csv",
              mode     = "wb")


download.file(url      = "https://thejacksonlaboratory.box.com/shared/static/ny1wokl6sz1xjzz68aftbk209se5nvws.tsv",
              destfile = "data/spot-meta.tsv",
              mode     = "wb")

dir.create("data/scRNA-seq", recursive = TRUE)
download.file(url      = "https://thejacksonlaboratory.box.com/shared/static/ydu9rbdhum5qrvuijze23qwz7dlztefo.tsv",
              destfile = "data/scRNA-seq/sc_cell_types.tsv",
              mode     = "wb")
download.file(url      = "https://thejacksonlaboratory.box.com/shared/static/lasxuiq5wi3ms1jnokzmm7pp4hptr8ma.gz",
              destfile = "data/scRNA-seq/sc_counts.tsv.gz",
              mode     = "wb")

download.file(url      = "https://thejacksonlaboratory.box.com/shared/static/dt2chlmxtjajxfnlpfzolz1tvb6kic7p.rds",
              destfile = "data/rctd-sample-1.rds",
              mode     = "wb")

Session Info

sessionInfo()