Setup

Experiment notes

16 scRNAseq samples of meningeal endothelial cells were sent for sequencing. In this experiment we treated E3 and E4, male and female mice (12-month-old), with a control diet or a PLX5622 diet (to ablate MHC-II high myeloid cells in the meninges), and we intend to see the effects on the transcriptome of BECs and LECs. This will then be correlated with the effects on the morphology of the meningeal lymphatics and with our very interesting behavior data. There are 8 groups and 2 biological replicates per groups (each replicate consisting of cells pooled from two animals). We will be submitting ~5000 cells for sequencing at 50k read pairs per cell.

Working directory

knitr::opts_knit$set(root.dir = ".")

Libraries

# load packages
library(Seurat,       # Idents()
        lib.loc = "/home/mayo/m214960/R/x86_64-pc-linux-gnu-library/4.2")    
library(dplyr)        # ungroup()
library(ggtree)       # BuildClusterTree()
library(gridExtra)    # grid.arrange()
library(gtools)       # smartbind()
library(parallel)     # detectCores()
library(plotly)       # plot_ly()
library(ShinyCell)    # createConfig()
library(tidyr)        # %>%

# work in parallel
options(mc.cores = detectCores() - 1)

Variables and functions

# variables
sample_order <- c("E3CF1","E3CF2","E3CM1","E3CM2","E3PF1","E3PF2","E3PM1","E3PM2",
                  "E4CF1","E4CF2","E4CM1","E4CM2","E4PF1","E4PF2","E4PM1","E4PM2")
sample_colors <- c("#9e0909","#f75959","#f0b402","#f5d67a",
                   "#fbff0a","#fafaa7","#1d8c0e","#63e851",
                   "#0271f0","#9cc3f0","#6c39f7","#c589fa",
                   "#ed2af7","#f5c1f7","#755410","#b5aa82")
group_colors <- c("#f75959","#f0b402",
                   "#fbff0a","#63e851",
                   "#0271f0","#c589fa",
                   "#ed2af7","#b5aa82")
group2_colors <- c("#f75959","#fbff0a","#63e851","#0271f0")
isoform_order <- c("E4","E3")
isoform_colors <- c("darkgray","cornflowerblue")
sex_order <- c("Male","Female")
sex_colors <- c("green","purple")
diet_order <- c("control","PLX5622")
diet_color <- c("coral","cyan")

# single cell functions
source("../../../functions/Kennedi_single_cell_functions.R")

# save function
saveToPDF <- function(...) {
    d = dev.copy(pdf,...)
    dev.off(d)
}

Read data

mouse.unannotated <- readRDS("../../rObjects/pass1_unannotated.rds")
Idents(mouse.unannotated) <- "seurat_clusters"
DefaultAssay(mouse.unannotated) <- "RNA"
mouse.unannotated <- NormalizeData(mouse.unannotated)

mouse.unannotated
## An object of class Seurat 
## 45085 features across 42378 samples within 2 assays 
## Active assay: RNA (23566 features, 0 variable features)
##  1 other assay present: SCT
##  2 dimensional reductions calculated: pca, umap

Unannotated QC

UMAP

cluster_colors <- c("black","gray40","gray","red1","blue","magenta1","darkorange2",
                    "darkorange4","yellow1","yellow4","yellow2","green","lightgreen",
                    "chartreuse1","Aquamarine","cyan","SteelBlue","red4","forestgreen",
                    "purple1","purple4","orange","plum1","salmon","tan","chocolate4")
u1 <- DimPlot(object = mouse.unannotated,
              reduction = "umap",
              shuffle = TRUE,
              repel = TRUE,
              cols = cluster_colors,
              label = TRUE)
u1

u2 <- DimPlot(object = mouse.unannotated,
              reduction = "umap",
              shuffle = TRUE,
              repel = TRUE,
              dims = c(2,3),
              cols = cluster_colors,
              label = TRUE)
u2

Feature plots

# UMAP percent.mt
FeaturePlot(mouse.unannotated,
            reduction = "umap", 
            features = "percent.mt") + 
  scale_colour_gradientn(colours = c("blue","lightblue","yellow","orange","red"))

# UMAP percent.ribo
FeaturePlot(mouse.unannotated,
            reduction = "umap", 
            features = "percent.ribo.protein") + 
  scale_colour_gradientn(colours = c("blue","lightblue","yellow","orange","red"))

# UMAP percent.hb
FeaturePlot(mouse.unannotated,
            reduction = "umap", 
            features = "percent.hb") + 
  scale_colour_gradientn(colours = c("blue","lightblue","yellow","orange","red"))

# UMAP nCount
FeaturePlot(mouse.unannotated,
            reduction = "umap", 
            features = "nCount_RNA") + 
  scale_colour_gradientn(colours = c("blue","lightblue","yellow","orange","red"))

# UMAP nFeature
FeaturePlot(mouse.unannotated,
            reduction = "umap", 
            features = "nFeature_RNA") + 
  scale_colour_gradientn(colours = c("blue","lightblue","yellow","orange","red"))

# UMAP cell.complexity
FeaturePlot(mouse.unannotated,
            reduction = "umap", 
            features = "cell.complexity") + 
  scale_colour_gradientn(colours = c("blue","lightblue","yellow","orange","red"))

# UMAP Ttr expression
FeaturePlot(mouse.unannotated,
            reduction = "umap", 
            features = "Ttr") + 
  scale_colour_gradientn(colours = c("blue","lightblue","yellow","orange","red"))

Violins

VlnPlot(mouse.unannotated,
        features = "nCount_RNA",
        split.by = "seurat_clusters")
## The default behaviour of split.by has changed.
## Separate violin plots are now plotted side-by-side.
## To restore the old behaviour of a single split violin,
## set split.plot = TRUE.
##       
## This message will be shown once per session.

VlnPlot(mouse.unannotated,
        features = "nFeature_RNA",
        split.by = "seurat_clusters")

Cells per cluster

# Cells per sample per cluster
sample_ncells <- FetchData(mouse.unannotated, 
                     vars = c("ident", "sample")) %>%
  dplyr::count(ident,sample) %>%
  tidyr::spread(ident, n)
sample_ncells
##    sample   0    1   2   3   4   5    6   7   8   9  10  11  12  13  14  15  16
## 1   E3CF1 581  285 163 116 178 167   40  63  87  62  44  37  57  45  50  33  32
## 2   E3CF2 389  201 143 115 118  96   45  68  63  48  37  31  43  29  33  30  26
## 3   E3CM1 720  531 382 273 235 126  103 444 187 144  75 142 123 105  43  79  28
## 4   E3CM2 334  149 162 162 116  63   43  97  72  44  36  40  52  31  14  38  14
## 5   E3PF1 111  175 262 136 230  49   23  63  39  66   8  24  39  19  10  60   9
## 6   E3PF2  91  164 159  86 204  45   37  31  40  30   9  72  26  23  19  28  14
## 7   E3PM1  72  163 152 293 139  38   26 110  62  53  41  34  15  28  16  39  29
## 8   E3PM2  96  413 290 433 166  60   68 140  88  83  60  74  22  51  20  40  39
## 9   E4CF1 668  243 193  67 203 283   51  68  51  28  11  45  49  33  30  37   6
## 10  E4CF2 774  352 319  60 252 294   59  96  87  33  25  53  89  70  53  67  20
## 11  E4CM1 420  369 519 440 118 198   74 150 124 230  29  84  48  47  21  41  47
## 12  E4CM2 256  100 180 248  79  64   38  42  46 111  56  27  25  10  16  33  46
## 13  E4PF1 423  312 445 255 401 451 1175 327 445  67 215 175 227 193 247  90 228
## 14  E4PF2 812 1207 716 644 726 139  294 216 298 224 424 225 229 154 236 125 162
## 15  E4PM1 159  335 372 580 163  50   27  99  93 207  98  62  37  36  49  49 108
## 16  E4PM2  92  268 243 183 121  38   33  76  50  70  34  50  17  27   8  48  17
##     17  18 19 20 21 22 23
## 1   18  30  7 10 15  1 NA
## 2   18  16 13  9  8 NA NA
## 3  176  54 50 28 12  6 NA
## 4   56  20 20  6  7 NA NA
## 5   22  26  6 12  6  1 NA
## 6   19  28 11  4  5 NA NA
## 7   57  10 21  8 10  3 NA
## 8  121  17 16 24 14  4 NA
## 9   14  32 10 11 19  2 NA
## 10  20  13 15 29 21  1 NA
## 11  28  20 16 18 15  3 NA
## 12   3   5  4  8  6  6 NA
## 13  63 196 58 15 15  4 39
## 14  22 105 62 92 68 11 NA
## 15   1  23 23 12  5 12 NA
## 16  NA  27 15 20 13  6 NA
# Cells per isoform per cluster
isoform_ncells <- FetchData(mouse.unannotated, 
                     vars = c("ident", "isoform")) %>%
  dplyr::count(ident,isoform) %>%
  tidyr::spread(ident, n)
isoform_ncells
##   isoform    0    1    2    3    4    5    6    7    8   9  10  11  12  13  14
## 1      E4 3604 3186 2987 2477 2063 1517 1751 1074 1194 970 892 721 721 570 660
## 2      E3 2394 2081 1713 1614 1386  644  385 1016  638 530 310 454 377 331 205
##    15  16  17  18  19  20  21 22 23
## 1 490 634 151 421 203 205 162 45 39
## 2 347 191 487 201 144 101  77 15 NA
# Cells per sex per cluster
sex_ncells <- FetchData(mouse.unannotated, 
                     vars = c("ident", "sex")) %>%
  dplyr::count(ident,sex) %>%
  tidyr::spread(ident, n)
sex_ncells
##      sex    0    1    2    3    4    5    6    7    8   9  10  11  12  13  14
## 1   Male 2149 2328 2300 2612 1137  637  412 1158  722 942 429 513 339 335 187
## 2 Female 3849 2939 2400 1479 2312 1524 1724  932 1110 558 773 662 759 566 678
##    15  16  17  18  19  20  21 22 23
## 1 367 328 442 176 165 124  82 40 NA
## 2 470 497 196 446 182 182 157 20 39
# Cells per diet per cluster
diet_ncells <- FetchData(mouse.unannotated, 
                     vars = c("ident", "diet")) %>%
  dplyr::count(ident, diet) %>%
  tidyr::spread(ident, n)
diet_ncells
##      diet    0    1    2    3    4    5    6    7    8   9  10  11  12  13  14
## 1 control 4142 2230 2061 1481 1299 1291  453 1028  717 700 313 459 486 370 260
## 2 PLX5622 1856 3037 2639 2610 2150  870 1683 1062 1115 800 889 716 612 531 605
##    15  16  17  18  19  20  21 22 23
## 1 358 219 333 190 135 119 103 19 NA
## 2 479 606 305 432 212 187 136 41 39

Gene histogram

# User params
goi <- "Malat1"
threshold <- 1

# Subset data
log2.threshold <- log2(threshold + 0.01)
counts.df <- FetchData(mouse.unannotated, vars = goi)
colnames(counts.df) <- "counts"
log2.counts.df <- log2(counts.df + 0.01)

# Histogram
title <- paste0(goi, "\nnCount_RNA > ", threshold)
hist1 <- ggplot(counts.df, aes(x = counts)) + 
  geom_histogram(bins = 100, fill = "gray", color = "black") + 
  labs(title = title, x=NULL, y=NULL) +
  xlab(paste0(goi, " nCount_RNA")) + ylab("# of Samples") + theme_bw() +
  geom_vline(xintercept = threshold, col = "blue") +
  annotate("rect", 
           xmin = -Inf,
           xmax = threshold, 
           ymin = 0, 
           ymax=Inf, 
           alpha=0.2, 
           fill="chocolate4") +
  annotate("rect", 
           xmin = threshold,
           xmax = Inf, 
           ymin = 0, 
           ymax=Inf, 
           alpha=0.2, 
           fill="deepskyblue")

# Histogram log transformed
hist2 <- ggplot(log2.counts.df, aes(x = counts)) + 
  geom_histogram(bins = 100, fill = "gray", color = "black") + 
  labs(title = title, x=NULL, y=NULL) +
  xlab(paste0("Log2(",goi, " nCount_RNA)")) + ylab("# of Samples") + theme_bw() +
  geom_vline(xintercept = log2.threshold, col = "blue") +
  annotate("rect", 
           xmin = -Inf,
           xmax = log2.threshold, 
           ymin = 0, 
           ymax=Inf, 
           alpha=0.2, 
           fill="chocolate4") +
  annotate("rect", 
           xmin = log2.threshold,
           xmax = Inf, 
           ymin = 0, 
           ymax=Inf, 
           alpha=0.2, 
           fill="deepskyblue")

# plot
plots1 <- list(hist1,hist2)
layout1 <- rbind(c(1),c(2))
grid1 <- grid.arrange(grobs = plots1, layout_matrix = layout1)

Percent gene

# user define variable
goi <- "Malat1"

# Extract counts data
DefaultAssay(mouse.unannotated) <- "RNA"
Idents(mouse.unannotated) <- "seurat_clusters"
geneData <- FetchData(mouse.unannotated,
                      vars = goi,
                      slot = "counts")
geneData <- geneData > 1
table(geneData)
## geneData
## FALSE  TRUE 
##  3134 39244
mouse.unannotated$Expression <- geneData

FetchData(mouse.unannotated,
          vars = c("ident", "Expression")) %>%
  dplyr::count(ident, Expression) %>%
  tidyr::spread(ident, n)
##   Expression    0    1    2    3    4    5    6    7    8    9   10   11   12
## 1      FALSE   39    5   15    6    9 1304  480  436   90   NA   15  104   25
## 2       TRUE 5959 5262 4685 4085 3440  857 1656 1654 1742 1500 1187 1071 1073
##    13  14  15  16  17  18  19  20  21 22 23
## 1  27  26   1 155 243   7  18  97  29 NA  3
## 2 874 839 836 670 395 615 329 209 210 60 36
# Plot
mouse.unannotated@meta.data %>%
  group_by(seurat_clusters, Expression) %>%
  dplyr::count() %>%
  group_by(seurat_clusters) %>%
  dplyr::mutate(percent = 100*n/sum(n)) %>%
  ungroup() %>%
  ggplot(aes(x=seurat_clusters,y=percent, fill=Expression)) +
  geom_col() +
  ggtitle(paste0("Percentage of cells with > 1 counts for ", goi)) +
  theme(axis.text.x = element_text(angle = 90))

Cluster tree

  • Cluster trees are helpful in deciding what clusters to merge.
mouse.unannotated <- BuildClusterTree(object = mouse.unannotated,
                                     dims = 1:15,
                                     reorder = FALSE,
                                     reorder.numeric = FALSE)
tree <- mouse.unannotated@tools$BuildClusterTree
tree$tip.label <- paste0(tree$tip.label)

ggtree::ggtree(tree, aes(x, y)) +
  scale_y_reverse() +
  ggtree::geom_tree() +
  ggtree::theme_tree() +
  ggtree::geom_tiplab(offset = 1) +
  ggtree::geom_tippoint(color = cluster_colors[1:length(tree$tip.label)], shape = 16, size = 5) +
  coord_cartesian(clip = 'off') +
  theme(plot.margin = unit(c(0,2.5,0,0), 'cm'))

Potential Markers

B-cells / Plasma cells

  • Cd19: expressed in B-cells and follicular dendritic cells
  • Fcrla: a B-cell specific protein in mice
  • Cd79a & Cd79b: together form BCR complex
  • Sdc1: Plasma cells
Idents(mouse.unannotated) <- "seurat_clusters"
VlnPlot(mouse.unannotated,
        features = "Cd19",
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "Fcrla",
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "Cd79a",
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "Cd79b",
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "Sdc1",
        cols = cluster_colors,
        split.by = "seurat_clusters")

T-cells

  • Trac/Cd3d/Cd3e/Cd3g are components of the TCR
VlnPlot(mouse.unannotated,
        features = "Trac",
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "Cd3e",
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "Cd8a",
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "Cd4",
        cols = cluster_colors,
        split.by = "seurat_clusters")

Endothelial cells

VlnPlot(mouse.unannotated,
        features = "Ly6c1",
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "Flt1",
        cols = cluster_colors,
        split.by = "seurat_clusters")

Fibroblasts

VlnPlot(mouse.unannotated,
        features = "Col1a1",
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "Col1a2",
        cols = cluster_colors,
        split.by = "seurat_clusters")

Mast cells

VlnPlot(mouse.unannotated,
        features = "Fcer1a",
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "Kit", # aka Cd117
        cols = cluster_colors,
        split.by = "seurat_clusters")

Macrophage

VlnPlot(mouse.unannotated,
        features = "C1qa",
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "C1qb",
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "Mki67",
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "Mki67",
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "Il7r",
        cols = cluster_colors,
        split.by = "seurat_clusters")

Monocytes/DCs

  • Cd11c/Itgax: Monocytes & DCs
VlnPlot(mouse.unannotated,
        features = "Itgax", # Cd11c
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "Cd209a",
        cols = cluster_colors,
        split.by = "seurat_clusters")

Neutrophils

VlnPlot(mouse.unannotated,
        features = "Ly6g",
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "Retnlg",
        cols = cluster_colors,
        split.by = "seurat_clusters")

Pericytes & SMCs

VlnPlot(mouse.unannotated,
        features = "Acta2",
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "Myl9",
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "Rgs5",
        cols = cluster_colors,
        split.by = "seurat_clusters")

Schwann cells

VlnPlot(mouse.unannotated,
        features = "Cdh19",
        cols = cluster_colors,
        split.by = "seurat_clusters")

VlnPlot(mouse.unannotated,
        features = "Mpz",
        cols = cluster_colors,
        split.by = "seurat_clusters")

Sandro’s markers

Idents(mouse.unannotated) <- "seurat_clusters"
goi1 <- c("Cd3e","Trbc1","Cd4","Cd8a","Foxp3","Tbx21","Gata3","Thy1",
         "Cd19","Ms4a1","Cd27","Ighg1","Ptprc","Ly6g","Itgam","Aif1","Klrb1")
goi2 <- c("Adgre1","Ms4a3","Ly6c2","Mrc1","Lyz2","Cd74","Cd83","Cd14","H2-Aa",
          "H2-Ab1","Sirpa","Xcr1","Siglech","Itgax","Kit","Mcpt4")
goi3 <- c("Pdgfra","Col1a1","Lum","Pdgfrb","Rgs5","Cspg4","Acta2","Tagln",
          "Pecam1","Cd34","Plvap","Stmn2","Slc38a5","Vwf","Mfsd2a","Cldn5")
goi4 <- c("Prox1","Flt4","Pdpn","Lyve1","Sox10","Mbp","Fgf13","Kcnab2","Tubb3",
          "Slc17a6","Shank2","Erbb4","Park7","Kif5b","Slc4a1","Hmbs")
goi5 <- c("Pecam1","Flt4","Itgam","Mrc1","Cd3e","Gata3","Cd19","Ly6g","Pdgfrb",
          "Kit","Col1a1","Pmp22","Hmbs")

v1 <- VlnPlot(mouse.unannotated,
              features = goi1,
              cols = cluster_colors,
              split.by = "seurat_clusters",
              flip = TRUE,
              stack = TRUE)
## Warning in FetchData.Seurat(object = object, vars = features, slot = slot): The
## following requested variables were not found: Ighg1
v1

v2 <- VlnPlot(mouse.unannotated,
              features = goi2,
              cols = cluster_colors,
              split.by = "seurat_clusters",
              flip = TRUE,
              stack = TRUE)
v2

v3 <- VlnPlot(mouse.unannotated,
              features = goi3,
              cols = cluster_colors,
              split.by = "seurat_clusters",
              flip = TRUE,
              stack = TRUE)
v3

v4 <- VlnPlot(mouse.unannotated,
              features = goi4,
              cols = cluster_colors,
              split.by = "seurat_clusters",
              flip = TRUE,
              stack = TRUE)
v4

v5 <- VlnPlot(mouse.unannotated,
              features = goi5,
              cols = cluster_colors,
              split.by = "seurat_clusters",
              flip = TRUE,
              stack = TRUE)
v5

Automatically detect markers

  • This is submitted in a separate script (03a_find_markers.R and 03b_submit_job.sh) due the high amount of memory needed and time taken to run
# Find markers for each cluster
# Compares single cluster vs all other clusters
# Default is logfc.threshold = 0.25, min.pct = 0.5
Idents(mouse.unannotated) <- "seurat_clusters"
all.markers <- FindAllMarkers(object = mouse.unannotated,
                              assay = "RNA",
                              test.use = "MAST",
                              verbose = TRUE)

# add column
all.markers$delta_pct <- abs(all.markers$pct.1 - all.markers$pct.2)

# rename columns and rows
rownames(all.markers) <- 1:nrow(all.markers)
all.markers <- all.markers[,c(6,7,1,5,2:4,8)]
colnames(all.markers)[c(6,7)] <- c("pct_1","pct_2")

# save
saveRDS(all.markers, "../../rObjects/pass1_unannotated_cluster_markers.rds")
# read object
all.markers <- readRDS("../../rObjects/pass1_unannotated_cluster_markers.rds")

# more stringent filtering
all.markers <- all.markers[all.markers$p_val_adj < 0.01,]

# compare 
table(all.markers$cluster)
## 
##    0    1    2    3    4    5    6    7    8    9   10   11   12   13   14   15 
## 3075 3096 3216 3493 3245 3815 2614 3191 2699 2827 5230 3157 2456 2801 2365 3164 
##   16   17   18   19   20   21   22   23 
## 3842 4104 2620 2340 3624 3031  954 1877
# subset
cluster0 <- all.markers[all.markers$cluster == 0,]
cluster1 <- all.markers[all.markers$cluster == 1,]
cluster2 <- all.markers[all.markers$cluster == 2,]
cluster3 <- all.markers[all.markers$cluster == 3,]
cluster4 <- all.markers[all.markers$cluster == 4,]
cluster5 <- all.markers[all.markers$cluster == 5,]
cluster6 <- all.markers[all.markers$cluster == 6,]
cluster7 <- all.markers[all.markers$cluster == 7,]
cluster8 <- all.markers[all.markers$cluster == 8,]
cluster9 <- all.markers[all.markers$cluster == 9,]
cluster10 <- all.markers[all.markers$cluster == 10,]
cluster11 <- all.markers[all.markers$cluster == 11,]
cluster12 <- all.markers[all.markers$cluster == 12,]
cluster13 <- all.markers[all.markers$cluster == 13,]
cluster14 <- all.markers[all.markers$cluster == 14,]
cluster15 <- all.markers[all.markers$cluster == 15,]
cluster16 <- all.markers[all.markers$cluster == 16,]
cluster17 <- all.markers[all.markers$cluster == 17,]
cluster18 <- all.markers[all.markers$cluster == 18,]
cluster19 <- all.markers[all.markers$cluster == 19,]
cluster20 <- all.markers[all.markers$cluster == 20,]
cluster21 <- all.markers[all.markers$cluster == 21,]
cluster22 <- all.markers[all.markers$cluster == 22,]
cluster23 <- all.markers[all.markers$cluster == 23,]

# save
write.table(all.markers,
            "../../results/all_clusters_pass1/markers/unannotated_cluster_markers_pvaladj_0.01.tsv", 
            sep = "\t", quote = FALSE, row.names = FALSE)

Cluster Annotations

Cluster 0: Macrophages

  • Mrc1, C1qb
VlnPlot(mouse.unannotated,
        features = cluster0$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 1: Endothelial

  • Flt1
VlnPlot(mouse.unannotated,
        features = cluster1$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 2: T-cells

  • Cd3e
# no markers
# cluster tree groups with cluster 6
VlnPlot(mouse.unannotated,
        features = "Flt1",
        split.by = "seurat_clusters",
        cols = cluster_colors)

Cluster 3: B-cells

  • Cd19
VlnPlot(mouse.unannotated,
        features = cluster3$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 4: Innate lymphoid cells

  • Gata3, Il7r
VlnPlot(mouse.unannotated,
        features = cluster4$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 5: Macrophages

  • C1qb

Cluster 6: Endothelial

  • Flt1
VlnPlot(mouse.unannotated,
        features = cluster6$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 7: Fibroblasts

  • Col1a1
VlnPlot(mouse.unannotated,
        features = cluster7$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 8: Endothelial

  • Flt1
VlnPlot(mouse.unannotated,
        features = cluster8$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 9: B-cells

-Cd19

VlnPlot(mouse.unannotated,
        features = cluster9$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 10: Neutrophils

  • Retnlg, Ly6g
VlnPlot(mouse.unannotated,
        features = cluster10$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 11: Pericytes & SMCs

  • Rgs5
VlnPlot(mouse.unannotated,
        features = cluster11$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 12: Monocytes/DCs

  • Itgax (Cd11c), Cd209a
VlnPlot(mouse.unannotated,
        features = cluster12$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 13: Endothelial

  • Flt1
VlnPlot(mouse.unannotated,
        features = cluster13$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 14:

  • Siglech
VlnPlot(mouse.unannotated,
        features = cluster14$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 15: T-cells

  • Cd3e
VlnPlot(mouse.unannotated,
        features = cluster15$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 16: B-cells / Mki67 high?

-Cd19, Mki67

VlnPlot(mouse.unannotated,
        features = cluster16$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 17:

VlnPlot(mouse.unannotated,
        features = cluster17$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 18: Mast cells

  • Kit
VlnPlot(mouse.unannotated,
        features = cluster18$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 19:

  • Thy1, Mrc1, Cldn5
  • Prox1, Flt4, Lyve1
VlnPlot(mouse.unannotated,
        features = cluster19$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 20:

  • Cldn5, Stmn2, Sox10, Mbp
VlnPlot(mouse.unannotated,
        features = cluster20$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 21: Scwann cells?

  • Mpz, Sox10, Mbp
VlnPlot(mouse.unannotated,
        features = cluster21$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 22:

  • Itgam
VlnPlot(mouse.unannotated,
        features = cluster22$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Cluster 23:

  • Vwf
VlnPlot(mouse.unannotated,
        features = cluster23$gene[1:20],
        cols = cluster_colors,
        stack = TRUE,
        flip = TRUE,
        split.by = "seurat_clusters")

Merge cluster names

# Rename all identities
mouse.annotated <- RenameIdents(object = mouse.unannotated,
                                "0" = "Macrophages",       # Mrc1
                                "1" = "Endothelial",       # Flt1
                                "2" = "T-cells",           # 
                                "3" = "B-cells",           # 
                                "4" = "Innate Lymphoid Cells", # Gata3 
                                "5" = "Macrophages",       # 
                                "6" = "Endothelial",       # 
                                "7" = "Fibroblasts",       # 
                                "8" = "Endothelial",       #
                                "9" = "B-cells",           # 
                                "10" = "Neutrophils",      # 
                                "11" = "Pericytes & SMCs", # 
                                "12" = "Monocytes and Dendritic cells",
                                "13" = "Endothelial",      # 
                                "14" = "", 
                                "15" = "T-cells",          # 
                                "16" = "B-cells",          #
                                "17" = "",      # 
                                "18" = "Mast cells",       # 
                                "19" = "",      # 
                                "20" = "",          # 
                                "21" = "Schwann cells",    # 
                                "22" = "",     #
                                "23" = "")     # 
mouse.annotated$merged_clusters <- Idents(mouse.annotated)
# set colors
merged_colors <- c("darkred","firebrick1","gold","darkolivegreen2","darkgreen",
                   "cyan","cornflowerblue","blue","darkorchid1","deeppink",
                   "plum1","burlywood3","azure4", "black")

# umap
umap <- DimPlot(object = mouse.annotated, 
        reduction = "umap",
        repel = TRUE,
        group.by = "merged_clusters",
        cols = merged_colors)
umap

Markers

v <- VlnPlot(mouse.annotated,
        features = c("C1qb","Flt1","Col1a2","Cd19","Itgax","Fgr","Retnlg","Cd3e",
                     "Il7r","Rgs5","Kit","Mpz","Sdc1"),
        split.by = "merged_clusters",
        flip = TRUE,
        stack = TRUE,
        cols = merged_colors)
v
v
path <- "../../results/all_clusters_pass1/markers/cluster_markers_violin"
saveToPDF(paste0(path, ".pdf"), width = 10, height = 6)
dev.off()

Shiny App

shiny.obj <- mouse.unannotated
shiny.obj@assays$RNA@var.features <- 
  shiny.obj@assays$SCT@var.features
metadata <- shiny.obj@meta.data
metadata <- metadata[,c(27,1:26)]
shiny.obj@meta.data <- metadata
shiny.obj@assays$SCT@meta.features <- metadata
shiny.obj@assays$RNA@meta.features <- metadata
# make shiny folder
DefaultAssay(shiny.obj) <- "RNA"
Idents(shiny.obj) <- shiny.obj$seurat_clusters
sc.config <- createConfig(shiny.obj)
setwd("../../results/all_clusters_pass1/")
makeShinyApp(shiny.obj, sc.config, gene.mapping = TRUE,
             shiny.title = "All Clusters Pass 1") 

manual edits

setwd("../../results/all_clusters_pass1/shinyApp")
sc1conf <- readRDS("sc1conf.rds")
sc1conf[1,4] <- "red|gold|blue"
sc1conf[2,4] <- "red|gold|blue"
sc1conf[3,4] <- "red|gold|green|blue"
sc1conf[4,4] <- "red|gold|green|blue"
saveRDS(sc1conf, "sc1conf.rds")