Diff of /Fig3_plots_scRNA.R [000000] .. [8e0848]

Switch to unified view

a b/Fig3_plots_scRNA.R
1
GIT_HOME="/research/users/ppolonen/git_home/ImmunogenomicLandscape-BloodCancers/"
2
source(file.path(GIT_HOME, "common_scripts/scRNA/functions.scRNA.analysis.R"))
3
source(file.path(GIT_HOME, "common_scripts/visualisation/plotting_functions.R"))
4
library(Seurat)
5
6
setwd("/research/groups/sysgen/PROJECTS/HEMAP_IMMUNOLOGY/petri_work/HEMAP_IMMUNOLOGY/Published_data_figures")
7
8
load("FIMM_AML_scRNA.Rdata")
9
FIMM=scmat
10
11
load("HCA_scRNA.Rdata")
12
HCA=scmat
13
14
load("AML_Galen_scRNA.Rdata")
15
GALEN=scmat
16
GALEN[["batch"]][,1]=gsub("AML|.D0", "", GALEN[["batch"]][,1])
17
18
colors.group=data.table::fread("colors_lineage.txt", data.table = F, header = F)
19
20
# plot proportion of different T-cell types
21
prop1=data.frame(prop.table(table(FIMM[["SingleR.label"]][,1], FIMM[["batch"]][,1]), margin=2))
22
prop2=data.frame(prop.table(table(GALEN[["SingleR.label"]][,1], GALEN[["batch"]][,1]), margin=2))
23
prop3=data.frame(prop.table(table(HCA[["SingleR.label"]][,1], HCA[["batch"]][,1]), margin=2))
24
prop4=data.frame(prop.table(table(HCA[["SingleR.label"]][,1], rep("HCA", dim(HCA)[2])), margin=2))
25
26
# plot MDS-like samples to map:
27
FIMM[["MDS"]]=ifelse(grepl("5897|3667|5249", FIMM[["batch"]][,1]), "MDS-like", "other")
28
29
plot.scatter.seurat(scmat = FIMM, colors.group = data.frame("V1"=c("MDS-like", "other"), "V2"=c("darkgreen", "orange"), stringsAsFactors = F), seurat.feature = "MDS", name="Figure3G.pdf", cores=1, SIZE = 0.25, rasterize=F, width = 64*6, height = 74*6, text.size=10*6)
30
plot.scatter.seurat(scmat = FIMM, colors.group = colors.group[colors.group[,1]%in%prop1$Var1[prop1$Freq>0.001],],seurat.feature = "SingleR.label", name="Figure3F.pdf", cores=1, SIZE = 0.25, rasterize=F, width = 64*6, height = 74*6, text.size=10*6)
31
32
cells=gsub(":.*.", "", levels(Idents(FIMM)))
33
34
pdf("FigureS3K.pdf", height = 8, width = 9)
35
DimPlot(FIMM, cols = colors.group[match(cells, colors.group[,1]),2], label = T)
36
DimPlot(FIMM, cols = colors.group[match(cells, colors.group[,1]),2], label = F)
37
dev.off()
38
39
plot.proportion=function(proportions, celltype, sample.order=NULL, colors.group, max.y=1){
40
  proportions.cd=proportions[grepl(celltype, proportions$Var1),]
41
  
42
  if(!is.null(sample.order))proportions.cd$Var2=factor(proportions.cd$Var2, levels=sample.order)
43
  proportions.cd$Var1=factor(proportions.cd$Var1, levels=unique(as.character(proportions.cd$Var1)))
44
  myColors=colors.group[match(levels(proportions.cd$Var1), colors.group$V1),2]
45
  names(myColors) <- levels(proportions.cd$Var1)
46
  colScale2 <- scale_fill_manual(values = myColors)
47
  p2=ggplot(data=proportions.cd,
48
            aes(x=Var2, y=Freq, fill=Var1)) + colScale2 +
49
    geom_bar(stat = "identity", inherit.aes = T) +
50
    ggtitle(paste(" ", " ", sep="\n")) +
51
    theme(legend.position = "none", legend.direction = "horizontal",
52
          axis.line.y = element_line(size=1, colour = "black"),
53
          axis.line.x = element_blank(),
54
          panel.grid.major = element_blank(),
55
          panel.grid.minor = element_blank(),
56
          # axis.text.x = element_blank(),
57
          axis.title.x = element_blank(),
58
          axis.title.y = element_blank(),
59
          axis.ticks.x = element_blank(),
60
          axis.text.x = element_text(colour="grey20",size=10,face="plain", family="Helvetica", angle = 90, hjust = 1),  
61
          axis.text.y = element_text(colour="grey20",size=10,face="plain", family="Helvetica"),  
62
          axis.ticks.length = unit(2,"mm"),
63
          panel.border = element_blank(), panel.background = element_blank(),
64
          plot.title = element_text(size = 10, face = "bold", family="Helvetica"),
65
          text=element_text())+
66
    theme(plot.margin=unit(c(1,1,1,1), "mm"))+ coord_cartesian(ylim=c(0,max.y))
67
  return(p2)
68
}
69
70
p1=plot.proportion(proportions = prop1, celltype = "HSC|GMP|CMP|MPP|MEP|Monocyte", 
71
                sample.order=c("5897", "3667","5249", "6333","5238","5750", "6386", "6187"),
72
                colors.group=colors.group)
73
74
p2=plot.proportion(proportions = prop2, celltype = "HSC|GMP|CMP|MPP|MEP|Monocyte", 
75
                   colors.group=colors.group)
76
77
p3=plot.proportion(proportions = prop3, celltype = "HSC|GMP|CMP|MPP|MEP|Monocyte", 
78
                   colors.group=colors.group)
79
80
p4=plot.proportion(proportions = prop4, celltype = "HSC|GMP|CMP|MPP|MEP|Monocyte", 
81
                   colors.group=colors.group)
82
83
ggsave(plot = p1, filename = "Figure3H_blast_proportion.pdf", width = 1.5, height = 2)
84
# ggsave(plot = p2, filename = "Blast_proportion_Galen_AML.pdf", width = 6, height = 2)
85
# ggsave(plot = p3, filename = "Blast_proportion_HCA_samples.pdf", width = 6, height = 2)
86
ggsave(plot = p4, filename = "Figure3H_blast_proportion_HCA.pdf", width = 2, height = 2)
87
88
89
p1=plot.proportion(proportions = prop1, celltype = "NK|CD8. Tem", 
90
                   sample.order=c("5897", "3667","5249", "6333","5238","5750", "6386", "6187"),
91
                   colors.group=colors.group, max.y = 1)
92
93
p2=plot.proportion(proportions = prop2, celltype = "NK|CD8. Tem", 
94
                   colors.group=colors.group, max.y = 1)
95
96
p3=plot.proportion(proportions = prop3, celltype = "NK|CD8. Tem", 
97
                   colors.group=colors.group, max.y = 1)
98
99
p4=plot.proportion(proportions = prop4, celltype = "NK|CD8. Tem", 
100
                   colors.group=colors.group, max.y = 1)
101
102
ggsave(plot = p1, filename = "Figure3H_CTL_NK_proportion.pdf", width = 1.5, height = 2)
103
# ggsave(plot = p2, filename = "TNK_proportion_Galen_AML.pdf", width = 6, height = 2)
104
# ggsave(plot = p3, filename = "TNK_proportion_HCA_samples.pdf", width = 6, height = 2)
105
ggsave(plot = p4, filename = "Figure3H_CTL_NK_proportion_HCA.pdf", width = 2, height = 2)
106
107
#************************* Integrated analysis, these were plotted in the Figure3K *************************
108
load("markers.all.filt.allgenes.Rdata") # from above
109
110
genes.up=fread("TableS3_Significant_genes_MDSlike_bulk.txt", data.table = F)
111
112
MDSup=markers.all.filt[markers.all.filt$gene%in%genes.up&markers.all.filt$avg_logFC>0.25,]
113
114
# interesting candidates from cellphonedb
115
feats=c("KLRF1", "CLEC2B", "NCR3", "BAG6", "HAVCR2", "LGALS9", "TGFBR3", "TGFB1", "IFNGR1", "IFNGR2", "IFNG", "LAG3")
116
117
# Check if significant in different category:
118
blasts=feats%in%markers.all.filt$gene[grepl("MDS-like",markers.all.filt$cluster)&grepl("HSC|MPP|MEP|GMP|CMP|Monocyte",markers.all.filt$cluster)]
119
NK=feats%in%markers.all.filt$gene[grepl("MDS-like",markers.all.filt$cluster)&grepl("CD8|NK",markers.all.filt$cluster)]
120
bulk=feats%in%genes.up$Gene[genes.up$FDR<0.001]
121
data.frame(feats, blasts, NK, bulk)
122
123
pdf("Figure3K_CellPhoneDB.pdf", width = 25, height = 6)
124
FeaturePlot(FIMM, c("KLRF1", "CLEC2B"), blend = T, cols=c("red", "darkblue"), blend.threshold = 0.001, pt.size = 0.01, coord.fixed = F, sort.cell = T)
125
FeaturePlot(FIMM, c("NCR3", "BAG6"), blend = T, cols=c("red", "darkblue"), blend.threshold = 0.001, pt.size = 0.01, coord.fixed = F, sort.cell = T)
126
FeaturePlot(FIMM, c("HAVCR2", "LGALS9"), blend = T, cols=c("red", "darkblue"), blend.threshold = 0.001, pt.size = 0.01, coord.fixed = F, sort.cell = T)
127
FeaturePlot(FIMM, c("TGFBR3", "TGFB1"), blend = T, cols=c("red", "darkblue"), blend.threshold = 0.001, pt.size = 0.01, coord.fixed = F, sort.cell = T)
128
dev.off()
129
130
#************************************** Analysis of IFNG *******************************************
131
load("Combined_pathway_signatures_2017_filtered_robust.Rdata")
132
add.scores=listA[grep("INTERFERON_GAMMA_SIGNALING", names(listA))]
133
134
add.scores=append(add.scores, list("IFNG_Receptor"=c("IFNGR1", "IFNGR2")))
135
136
fm.f=GetAssayData(FIMM)
137
138
gm.objects=do.call(rbind, lapply(seq(add.scores), function(i){
139
  dat3=fm.f[rownames(fm.f)%in%add.scores[[i]],]
140
  gm=log2(t(apply(dat3, 2, gm_mean))) # done to normalized values
141
  rownames(gm)=names(add.scores)[i]
142
  return(gm)
143
}))
144
145
# also add to seurat object:
146
for(i in seq(add.scores)){
147
  FIMM[[names(add.scores)[i]]] <- gm.objects[i,]
148
}
149
150
pdf("Fig3K_IFNG_analysis.pdf", width = 25, height = 6)
151
FeaturePlot(FIMM, c("IFNG", "IFNG_Receptor"), sort.cell = T, pt.size = 0.01, blend = T, cols=c("red", "darkblue"), blend.threshold = 0.001)
152
FeaturePlot(FIMM, c("IFNG_Receptor", "IFNG"), sort.cell = T, pt.size = 0.01, blend = T, cols=c("red", "darkblue"), blend.threshold = 0.001)
153
FeaturePlot(FIMM, c("INTERFERON_GAMMA_SIGNALING-REACTOME_MsigDB_c2", "IFNG"), sort.cell = T, pt.size = 0.01, blend = T, cols=c("red", "darkblue"), blend.threshold = 0.001)
154
plot.DotPlot(FIMM, features = unique(c("IFNGR1", "IFNGR2","IFNG", "IFNG_Receptor", "INTERFERON_GAMMA_SIGNALING-REACTOME_MsigDB_c2", "CytolyticScore")))
155
dev.off()
156
157
pdf("FigS3O_IFNG_analysis_vln.pdf", width = 5, height = 3)
158
FIMM[["MDSlike"]]=ifelse(grepl("5897|3667|5249", FIMM[["batch"]][,1]), "MDS-like", "other")
159
FIMM[["MDSlike"]][grepl("6333|6187", FIMM[["batch"]][,1]),1]="HLAII_CIITA_low"
160
FIMM[["batch2"]]=factor(FIMM[["batch"]][,1], levels=c("5897", "3667", "5249", "5238", "5750", "6187", "6333", "6386"))
161
VlnPlot(FIMM[,grepl("MPP|GMP|CMP|MEP|HSC", FIMM[["SingleR.label"]][,1])], c("IFNG_Receptor"), group.by = "MDSlike", log = F, pt.size = 0.1)
162
VlnPlot(FIMM[,grepl("MPP|GMP|CMP|MEP|HSC", FIMM[["SingleR.label"]][,1])], c("INTERFERON_GAMMA_SIGNALING-REACTOME_MsigDB_c2"), group.by = "MDSlike", log = F, pt.size = 0)
163
VlnPlot(FIMM[,grepl("MPP|GMP|CMP|MEP|HSC", FIMM[["SingleR.label"]][,1])], c("INTERFERON_GAMMA_SIGNALING-REACTOME_MsigDB_c2"), group.by = "batch2",cols = c(rep("darkgreen", 3), rep("orange", 5)), log = F, pt.size = 0)
164
dev.off()