2 Set up

First, we need to install and/or load the necessary packages and import the Visium data. To install STutility, follow the guide provided in the vignette: https://ludvigla.github.io/STUtility_web_site/Installation.html

When loading STutility, it automatically imports the packages Seurat and ggplot2.

library(STutility)
library(DT)

Next, we need to prepare the input files and how to import the data into R. 10X Visium data output is produced with the spaceranger command line tool from raw fastq files. The output includes a number of files, and the ones that needs to be imported into R for STutility are the following:

  • filtered_feature_bc_matrix.h5 or raw_feature_bc_matrix.h5 — Gene expression matrices in .h5 format containing the raw UMI counts for each spot and each gene. The “filtered_feature_bc_matrix.h5” matrix contains spots that are localized under the tissue while the “raw_feature_bc_matrix.h5” matrix contain all spots from the entire capture area. NOTE: if you want to include spots outside of the tissue, you need to set disable.subset = TRUE when running InputFromTable.

  • tissue_positions_list.csv — contains capture-spot barcodes and corresponding capture-spot coordinates.

  • tissue_hires_image.png — H&E image in PNG format with a width of 2000 pixels.

  • scalefactors_json.json — This file contains scaling factors subject to the H&E images of different resolutions. E.g. “tissue_hires_scalef”: 0.1, means that the pixel coordinates in the “tissue_positions_list.csv” table should be scaled by a factor of 0.1 to match the size of the “hires_image.png” file.

The recommended method to read the files into R is via the creation of a data.frame that we will call the infoTable. There are four columns in this table that are required for Visium data: samples, spotfiles, imgs and json. These columns specify the paths to the required input files.

Any number of extra columns can be added to the infoTable data frame that you want to include as meta data in your Seurat object, e.g. “gender”, “age”, “slide_id” etc.