Figure 5 - Marker Genes

Author

Ashok Patowary

library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.3.6      ✔ purrr   0.3.4 
✔ tibble  3.1.8      ✔ dplyr   1.0.10
✔ tidyr   1.2.0      ✔ stringr 1.5.0 
✔ readr   2.1.2      ✔ forcats 0.5.2 
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
library(Seurat)
Attaching SeuratObject
Attaching sp
isoT4k_filter = readRDS("data/working/isoT4k_filter.rds")
levels(isoT4k_filter$orig.ident) = gsub("\\.", "-", levels(isoT4k_filter$orig.ident)) # ExM.U becomes ExM-U
isoT4k_filter
An object of class Seurat 
141112 features across 4167 samples within 2 assays 
Active assay: RNA (87162 features, 0 variable features)
 1 other assay present: SCT
 2 dimensional reductions calculated: pca, umap
new.cluster.ids <- c("ExM", "ExN-ExM", "ExM-U", "ExN-1", "ExN-2", "In",
                     "vRG-ExN", "oRG", "IP", "ExDp", "ExN-3", "vRG", "PgS", "PgG2M", "Mic/Per/End")
names(new.cluster.ids) <- levels(isoT4k_filter)
isoT4k_filter <- RenameIdents(isoT4k_filter, new.cluster.ids)
isoT4k_filter@meta.data$isoCellType <- Idents(isoT4k_filter)
Idents(isoT4k_filter) <- isoT4k_filter$isoCellType

Markers for isoform-based clustering

isoT4k_filter_1<- subset(isoT4k_filter, idents=c("ExM", "ExN-ExM", "ExM-U", "In",
                                                 "oRG", "IP", "ExDp","vRG",
                                                 "ExN-1", "ExN-2", "ExN-3"))
merged.markers.CT <- FindAllMarkers(isoT4k_filter_1, only.pos = TRUE, min.pct = 0.25, logfc.threshold = 0.75)
Calculating cluster ExM
Calculating cluster ExN-ExM
Warning in FindMarkers.default(object = data.use, slot = data.slot, counts =
counts, : No features pass logfc.threshold threshold; returning empty data.frame
Calculating cluster ExM-U
Calculating cluster ExN-1
Calculating cluster ExN-2
Calculating cluster In
Calculating cluster oRG
Calculating cluster IP
Calculating cluster ExDp
Calculating cluster ExN-3
Calculating cluster vRG
merged.markers.CT.padj<- merged.markers.CT[merged.markers.CT$p_val_adj < 0.05,]
top.merged.markers.CT.padj<- merged.markers.CT.padj%>% group_by(cluster) %>% top_n(n = 3, wt = avg_log2FC)
new_order<- c("vRG", "oRG", "IP", "vRG-ExN", "ExN-1", "ExN-2", "ExN-3", "ExN-ExM", "ExM", "ExM-U","ExDp", "In")
top.merged.markers.CT.padj$cluster<- factor( as.character(top.merged.markers.CT.padj$cluster), levels= new_order)
top.merged.markers.CT.padj<- top.merged.markers.CT.padj[order(top.merged.markers.CT.padj$cluster),]
isoT4k_filter_1$isoCellType<- factor(isoT4k_filter_1$isoCellType, levels = c("vRG", "oRG", "IP", "vRG-ExN", "ExN-1", "ExN-2", "ExN-3", "ExN-ExM", "ExM", "ExM-U", "ExDp", "In"))
Idents(isoT4k_filter_1)<- isoT4k_filter_1$isoCellType

mapal <- colorRampPalette(RColorBrewer::brewer.pal(9,"Blues"))(256)

DoHeatmap(subset(isoT4k_filter_1, downsample = 113), group.by = 'isoCellType', features = top.merged.markers.CT.padj$gene, angle = 90, size = 3, disp.max = 7, disp.min=1.5) + 
          scale_fill_gradientn(colours = mapal) + theme(plot.margin = unit(c(0.75,0.25,0.25,0.25), "cm")) +theme(axis.text=element_text(size=10), legend.title = element_text(size = 8), legend.text = element_text(size = 6))
Scale for 'fill' is already present. Adding another scale for 'fill', which
will replace the existing scale.

#ggsave("output/figures/Fig_4G.pdf", device ="pdf", dpi=600, width =754, height = 704, scale = 1/100)
ggsave("output/figures/Fig5/Fig5_Markers_NewCellTypes.pdf", width = 7, height = 7)

Markers for gene-based clustering

Idents(isoT4k_filter)<- isoT4k_filter$orig.ident
head(Idents(isoT4k_filter))
End_ACGGCATAGTAC End_ACTGACTGATCC End_ACTGGCACCGAG End_AGCTAGCCCATG 
             End              End              End              End 
End_AGTTTAGCGGTC End_ATCCGACCATCA 
             End              End 
16 Levels: End ExDp1 ExDp2 ExM ExM-U ExN InCGE InMGE IP Mic OPC oRG ... vRG
isoT4k_filter_2<- subset(isoT4k_filter, idents=c("vRG", "oRG", "IP", "ExN", "ExM", "ExM-U", "ExDp1", "ExDp2", "InCGE", "InMGE"))
isoT4k_filter_2
An object of class Seurat 
141112 features across 3912 samples within 2 assays 
Active assay: RNA (87162 features, 0 variable features)
 1 other assay present: SCT
 2 dimensional reductions calculated: pca, umap
merged.markers.CT <- FindAllMarkers(isoT4k_filter_2, only.pos = TRUE, min.pct = 0.15, logfc.threshold = 0.25)
Calculating cluster ExDp1
Calculating cluster ExDp2
Calculating cluster ExM
Calculating cluster ExM-U
Calculating cluster ExN
Calculating cluster InCGE
Calculating cluster InMGE
Calculating cluster IP
Calculating cluster oRG
Calculating cluster vRG
merged.markers.CT.padj<- merged.markers.CT[merged.markers.CT$p_val_adj < 0.05,]
top.merged.markers.CT.padj<- merged.markers.CT.padj%>% group_by(cluster) %>% top_n(n = 5, wt = avg_log2FC)
min(table(Idents(isoT4k_filter_2)))
[1] 14
DoHeatmap(isoT4k_filter_2, features = top.merged.markers.CT.padj$gene, angle = 90, size = 3, disp.max = 7, disp.min=0.5) + scale_fill_gradientn(colours = mapal) + theme(plot.margin = unit(c(0.75,0.25,0.25,0.25), "cm")) +theme(axis.text=element_text(size=10), legend.title = element_text(size = 8), legend.text = element_text(size = 6))
Scale for 'fill' is already present. Adding another scale for 'fill', which
will replace the existing scale.

#ggsave("Marker_oldCT_v3.pdf", width = 7.54, height = 7.04)
isoT4k_filter_2$orig.ident<- factor(isoT4k_filter_2$orig.ident, levels = c("vRG", "oRG", "IP", "ExN", "ExM", "ExM-U", "ExDp1", "ExDp2", "InCGE", "InMGE"))
new_order<- c("vRG", "oRG", "IP", "ExN", "ExM", "ExM-U", "ExDp1", "ExDp2", "InCGE", "InMGE")
top.merged.markers.CT.padj$cluster<- factor( as.character(top.merged.markers.CT.padj$cluster), levels= new_order)
top.merged.markers.CT.padj<- top.merged.markers.CT.padj[order(top.merged.markers.CT.padj$cluster),]
DoHeatmap(subset(isoT4k_filter_2, downsample = 200), features = top.merged.markers.CT.padj$gene, angle = 90, size = 3, disp.max = 7.5, disp.min=1.5) + scale_fill_gradientn(colours = mapal) + theme(plot.margin = unit(c(0.75,0.25,0.25,0.25), "cm")) +theme(axis.text=element_text(size=10), legend.title = element_text(size = 8), legend.text = element_text(size = 6))
Scale for 'fill' is already present. Adding another scale for 'fill', which
will replace the existing scale.

#ggsave("Marker_oldCT_v3.pdf", width = 7.54, height = 9.5)
Idents(isoT4k_filter_2)<- isoT4k_filter_2$orig.ident
DoHeatmap(subset(isoT4k_filter_2, downsample = 200), features = top.merged.markers.CT.padj$gene, angle = 90, size = 3, disp.max = 7.5, disp.min=1.5) + scale_fill_gradientn(colours = mapal) + theme(plot.margin = unit(c(0.75,0.25,0.25,0.25), "cm")) +theme(axis.text=element_text(size=10), legend.title = element_text(size = 8), legend.text = element_text(size = 6))
Scale for 'fill' is already present. Adding another scale for 'fill', which
will replace the existing scale.

#ggsave("Marker_oldCT_v3.pdf", device ="pdf", dpi=600, width =794, height = 970, scale = 1/100)
ggsave("output/figures/Fig5/Fig5_Markers_oldCellTypes.pdf", width = 7.94, height = 9.70)