6 Cell type annotation with singleR

6.1 Load up the MMR atlas as a singleR reference

6.2 Reference dataset is from this paper: https://doi.org/10.1016/j.cell.2021.08.003

mmr_atlas <- qread("./data/GSE178341_lognorm_annotated.qs")

6.3 Read in the fetal gut atlas as well https://www.gutcellatlas.org/

gut_atlas <- qread("./data/Gut_Atlas_Seurat.qs")

6.4 Key gut atlas annotations

table(gut_atlas$Integrated_05)
table(gut_atlas$category)
table(gut_atlas$Age_group)

6.5 Keep only the adult tissues and mesenteric lymph nodes (MLNs)

gut_atlas_adult <- gut_atlas[,gut_atlas$Age_group %in% c("Adult", "Adult_MLN")]

gut_groups<- gut_atlas_adult@meta.data%>%
  select(Integrated_05, category)

6.6 Add on the annotations for the MMR atlas and gut cell atlas

predictions <- SingleR(test=cropped.obj@assays$Xenium$counts, 
                       ref=mmr_atlas@assays$RNA@counts, labels=mmr_atlas$clMidwayPr,
                       aggr.ref = T, num.threads = 10)

cropped.obj$MMR_atlas_midlevel_pred <- predictions$labels 

predictions <- SingleR(test=cropped.obj@assays$Xenium$counts, 
                       ref=mmr_atlas@assays$RNA@counts, labels=mmr_atlas$cl295v11SubFull,
                       aggr.ref = T, num.threads = 10)

cropped.obj$MMR_atlas_lowlevel_pred <- predictions$labels 

# Add on the annotations for the gut cell atlas lowlevel
predictions_gut <- SingleR(test=cropped.obj@assays$Xenium$counts, 
                           ref=gut_atlas_adult@assays$RNA$counts, labels=gut_atlas_adult$Integrated_05,
                           aggr.ref = T, num.threads = 10)

cropped.obj$Pred_gut_atlas <- predictions_gut$labels 

# Add on the annotations for the gut cell atlas high level
predictions_gut_midlevel <- SingleR(test=cropped.obj@assays$Xenium$counts, 
                           ref=gut_atlas_adult@assays$RNA$counts, labels=gut_atlas_adult$category,
                           aggr.ref = T, num.threads = 10)

cropped.obj$Pred_gut_midlevel <- predictions_gut_midlevel$labels 

6.7 Visualise the annotations on the UMAP

DimPlot(cropped.obj,label = T)+ NoLegend()
DimPlot(cropped.obj, group.by = "MMR_atlas_midlevel_pred", label = T, cols = cell_type_colors)
DimPlot(cropped.obj, group.by = "MMR_atlas_lowlevel_pred", label = T)+ NoLegend()

6.8 I think the gut cell atlas has worked the best here

DimPlot(cropped.obj, group.by = "Pred_gut_atlas", label = T)+ NoLegend()
DimPlot(cropped.obj, group.by = "Pred_gut_midlevel", label = T)+ NoLegend()

6.9 Plot some key marker genes of CRC and braod celltype markers

FeaturePlot(cropped.obj, features = c("PIGR", "LGR5", "OLFM4", "TGFBI", "MMP3", "REG1A", "REG3A", "BEST4", "MMP3"))
FeaturePlot(cropped.obj, features = c("CD8A", "CD3E", "SPP1", "C1QA", "CD79A", "MZB1"))

6.10 Summarise cell type annotations

cell_type_summary <- table(cropped.obj$Pred_gut_atlas, cropped.obj$Pred_gut_midlevel)%>%
  data.frame()

6.11 Make the object a lot smaller by dropping the full fov

cropped.obj[['fov']] <- NULL

plot <- ImageDimPlot(cropped.obj,fov = "zoom", group.by = "Pred_gut_atlas", 
                     size = 0.3, 
                     dark.background = T, boundaries = "segmentation",border.size = 0.1,
                     molecules = c("PIGR", "LGR5", "OLFM4", "TGFBI", "MMP3", "REG1A", "REG3A"), 
                     nmols = 20000) + 
  ggtitle("Cell type")

plot

plot <- ImageDimPlot(cropped.obj,fov = "zoom", group.by = "Pred_gut_midlevel", 
                     size = 0.3, 
                     dark.background = T, boundaries = "segmentation",border.size = 0.1,
                     molecules = c("PIGR", "LGR5"), 
                     nmols = 20000) + 
  ggtitle("Cell type")

plot