Seurat Cheatsheet Answer Key

Authors

Noor Sohail

Will Gammerdinger

Published

December 7, 2025

Exercise 1

What are the last 5 cells barcodes and the last 5 genes in the seurat object.

# Show last bin barcodes
Cells(seurat_processed) %>% tail()
[1] "P5NAT_s_008um_00108_00352-1" "P5NAT_s_008um_00243_00304-1"
[3] "P5NAT_s_008um_00365_00197-1" "P5NAT_s_008um_00357_00367-1"
[5] "P5NAT_s_008um_00148_00248-1" "P5NAT_s_008um_00373_00222-1"
# Show last bin barcodes
colnames(seurat_processed) %>% tail()
[1] "P5NAT_s_008um_00108_00352-1" "P5NAT_s_008um_00243_00304-1"
[3] "P5NAT_s_008um_00365_00197-1" "P5NAT_s_008um_00357_00367-1"
[5] "P5NAT_s_008um_00148_00248-1" "P5NAT_s_008um_00373_00222-1"
# Show the last genes names
Features(seurat_processed) %>% tail()
[1] "MT-ND3"  "MT-ND4L" "MT-ND4"  "MT-ND5"  "MT-ND6"  "MT-CYB" 
# Show the last genes names
rownames(seurat_processed) %>% tail()
[1] "MT-ND3"  "MT-ND4L" "MT-ND4"  "MT-ND5"  "MT-ND6"  "MT-CYB" 

Exercise 2

What are the last 5 identities for the bins in the Seurat object?

# Print final five idents
Idents(seurat_processed) %>% 
  tail()
P5NAT_s_008um_00108_00352-1 P5NAT_s_008um_00243_00304-1 
                          4                           6 
P5NAT_s_008um_00365_00197-1 P5NAT_s_008um_00357_00367-1 
                          5                           7 
P5NAT_s_008um_00148_00248-1 P5NAT_s_008um_00373_00222-1 
                          5                           8 
14 Levels: Tumor B cells Intestinal epithelial cells 4 5 6 7 8 9 10 11 ... 14

Exercise 3

What are the 5 least variable genes in the Seurat object?

# Show five least variable features
VariableFeatures(seurat_processed) %>% 
  tail()
[1] "ADAM23" "PNMT"   "RSPO2"  "HTRA3"  "SLC3A1" "TLR8"  

Exercise 4

What are the dimensions for each assay in the Seurat object?

# Obtain the number of bins and genes for the Spatial.008um assay
dim(seurat_processed[["Spatial.008um"]])
[1]  18085 135798
# Obtain the number of bins and genes for the sketch assay
dim(seurat_processed[["sketch"]])
[1] 18085 10000

Exercise 5

Show the code to get the entire sketch log-normalized (data) count matrix.

# Obtain sketch count matrix for normalized count matrix
LayerData(seurat_processed,
          assay = "sketch",
          layer = "data")

Exercise 6

Show how you would use the FetchData() function to generate a dataframe of fullumapsketch_1, fullumapsketch_2 and orig.ident values for each cell.

# Use FetchData to pull selected information from the Seurat object
FetchData(seurat_processed,
          vars = c("fullumapsketch_1", "fullumapsketch_2", "orig.ident")) %>%
  head()
                            fullumapsketch_1 fullumapsketch_2 orig.ident
P5CRC_s_008um_00078_00444-1       -0.6143208        5.1682210      P5CRC
P5CRC_s_008um_00128_00278-1       10.2845659       -1.0381278      P5CRC
P5CRC_s_008um_00052_00559-1        4.1152215       -2.2149165      P5CRC
P5CRC_s_008um_00121_00413-1       -1.9594976       -1.1644329      P5CRC
P5CRC_s_008um_00202_00633-1       -4.8776975       -0.4168439      P5CRC
P5CRC_s_008um_00035_00460-1       -0.5702860        4.3981943      P5CRC