|
a |
|
b/Fig5_DE_analysis_costim.R |
|
|
1 |
GIT_HOME="/research/users/ppolonen/git_home/ImmunogenomicLandscape-BloodCancers/" |
|
|
2 |
source(file.path(GIT_HOME, "common_scripts/visualisation/plotting_functions.R")) |
|
|
3 |
source(file.path(GIT_HOME, "common_scripts/statistics/functions_statistics.R")) |
|
|
4 |
source(file.path(GIT_HOME, "common_scripts/statistics/statistics_wrappers.R")) |
|
|
5 |
source(file.path(GIT_HOME, "common_scripts/pathway_analysis/functions.GSEA.R")) |
|
|
6 |
source(file.path(GIT_HOME, "common_scripts/scRNA/functions.scRNA.analysis.R")) |
|
|
7 |
source(file.path(GIT_HOME, "common_scripts/statistics/useful_functions.R")) |
|
|
8 |
|
|
|
9 |
setwd("/research/groups/sysgen/PROJECTS/HEMAP_IMMUNOLOGY/petri_work/HEMAP_IMMUNOLOGY/Published_data_figures") |
|
|
10 |
|
|
|
11 |
# analyze FIMM and Galen AML and find costim associations to certain clusters. |
|
|
12 |
co.stim=data.table::fread("costim_ligands_final.txt", data.table = F)[,c(1,3,5)] |
|
|
13 |
co.stim=rbind(co.stim, c("FGL1", "LAG3", "Inhibitory")) |
|
|
14 |
co.stimR.f=unlist(strsplit(co.stim$`Receptor gene`, ", ")) |
|
|
15 |
|
|
|
16 |
co.stim.all=data.table::fread("costim_ligands_final.txt", data.table = F) |
|
|
17 |
ligand.name=gsub(" \\(\\)", "", paste0(co.stim.all$Gene, " (", co.stim.all$`Common name`, ")")) |
|
|
18 |
Receptor.name=gsub(" \\(\\)", "", paste0(co.stim.all$`Receptor gene`, " (", co.stim.all$`Receptor common name`, ")")) |
|
|
19 |
Receptor.name[co.stim.all$`Receptor gene`==co.stim.all$`Receptor common name`]=co.stim.all$`Receptor gene`[co.stim.all$`Receptor gene`==co.stim.all$`Receptor common name`] |
|
|
20 |
|
|
|
21 |
rec=strsplit(co.stim$`Receptor gene`, ", ") |
|
|
22 |
co.stimR.func=unique(do.call(rbind, lapply(seq(rec), function(i)cbind(rec[[i]], co.stim$`Immune checkpoint function`[i])))) |
|
|
23 |
|
|
|
24 |
files=list.files(path = ".", "subtypes.Rdata") |
|
|
25 |
names(files)=gsub("_subtypes.Rdata", "", files) |
|
|
26 |
|
|
|
27 |
# plot subtypes |
|
|
28 |
wrapper.de.analysis=function(i, files){ |
|
|
29 |
load(files[i]) |
|
|
30 |
library(ggplot2) |
|
|
31 |
|
|
|
32 |
if(!is.null(dim(coordinates.subtype))){ |
|
|
33 |
subtype=factor(coordinates.subtype$subtype) |
|
|
34 |
|
|
|
35 |
coordinates.subtype=coordinates.subtype[order(subtype),] |
|
|
36 |
subtype=subtype[order(subtype)] |
|
|
37 |
|
|
|
38 |
SIZE=ifelse(dim(gexp)[2]>500, 0.5, 2) |
|
|
39 |
|
|
|
40 |
# # plot colorv for all: |
|
|
41 |
# colorv = data.frame("subtype"=c("PML-RARA", "CBFB-MYH11", "Progenitor-like", "MDS-like", "CEBPA", "Monocyte-like","Monocyte-like-MLL", "RUNX1-RUNX1T1"), "color"=c("#aff558", "#dfe4c3", "#d3c684", "#fac75d", "#8a9979", "#d4bcc5", "brown", "#edb2c6")) |
|
|
42 |
# |
|
|
43 |
# colorv=colorv[match(unique(subtype), colorv[,1]),2] |
|
|
44 |
# |
|
|
45 |
# plot.scatter(x=coordinates.subtype$x, y = coordinates.subtype$y, group = subtype, namev = subtype, main = names(files)[i],colorv =as.character(colorv), rasterize = F, width = 70*2, height = 74*2, SIZE = SIZE) |
|
|
46 |
|
|
|
47 |
# plot colorv for all: |
|
|
48 |
# filt=as.character(subtype)%in%c("Ph", "KMT2A", "TCF3-PBX1","Hyperdiploid","ETV6-RUNX1", "PAX5 P80R", "PAX5alt","DUX4", "ZNF384", "MEF2D", "Other") |
|
|
49 |
# |
|
|
50 |
# coordinates.subtype=coordinates.subtype[filt,] |
|
|
51 |
# subtype=subtype[filt] |
|
|
52 |
|
|
|
53 |
plot.scatter(x=coordinates.subtype$x, y = coordinates.subtype$y, group = subtype, namev = subtype, main = names(files)[i], rasterize = F, width = 70*2, height = 74*2, SIZE = SIZE) |
|
|
54 |
|
|
|
55 |
}else{ |
|
|
56 |
return(NULL) |
|
|
57 |
} |
|
|
58 |
} |
|
|
59 |
plot.list=lapply(seq(files), wrapper.de.analysis, files) |
|
|
60 |
plot.list=plot.list[!sapply(plot.list, is.null)] |
|
|
61 |
# 74mm * 99mm per panelwidth = 77, height = 74 |
|
|
62 |
figure <-multipanelfigure:: multi_panel_figure(width = 170*2, height = ceiling(length(plot.list)/2)*75*2+175, rows = ceiling(length(plot.list)/2)+1, columns = 2, panel_label_type = "none", unit = "mm", row_spacing = unit(1, "mm"), column_spacing = unit(4, "mm")) |
|
|
63 |
|
|
|
64 |
for(i in seq(plot.list)){ |
|
|
65 |
figure <- multipanelfigure::fill_panel(figure, plot.list[[i]]) |
|
|
66 |
} |
|
|
67 |
|
|
|
68 |
name="FigS5A_FigS3D_Fig6E_FigS6F_subtypes" |
|
|
69 |
multipanelfigure::save_multi_panel_figure(figure, filename=paste0(name, "_scatterplot.pdf"), limitsize = FALSE) |
|
|
70 |
|
|
|
71 |
files=files[!files%in%"PecanALL_subtypes.Rdata"] |
|
|
72 |
|
|
|
73 |
#************************************** Differential expression **************************************** |
|
|
74 |
|
|
|
75 |
wrapper.de.analysis=function(i, files, genelist){ |
|
|
76 |
load(files[i]) |
|
|
77 |
|
|
|
78 |
if(!is.null(dim(coordinates.subtype))){ |
|
|
79 |
subtype=coordinates.subtype$subtype |
|
|
80 |
}else{ |
|
|
81 |
subtype=coordinates.subtype |
|
|
82 |
} |
|
|
83 |
|
|
|
84 |
# make lv of the subtype: |
|
|
85 |
lv=get.logical(list(subtype)) |
|
|
86 |
|
|
|
87 |
res=wrapper.wilcoxtest(genelist[genelist%in%rownames(gexp)], data = gexp, logicalVectors = lv, ALTERNATIVE = "two.sided", adj.method = "BH", CORES = 8, prettynum = F) |
|
|
88 |
|
|
|
89 |
res$Name=names(files)[i] |
|
|
90 |
# res=res[res$FDR<0.05,] |
|
|
91 |
return(res) |
|
|
92 |
} |
|
|
93 |
|
|
|
94 |
genelist=co.stim[,1] |
|
|
95 |
|
|
|
96 |
res=lapply(seq(files), wrapper.de.analysis, files, genelist) |
|
|
97 |
|
|
|
98 |
genelist=co.stimR.f |
|
|
99 |
|
|
|
100 |
resR=lapply(seq(files), wrapper.de.analysis, files, genelist) |
|
|
101 |
|
|
|
102 |
wrapper.immunoscore.analysis=function(i, files, genesets){ |
|
|
103 |
load(files[i]) |
|
|
104 |
|
|
|
105 |
if(!is.null(dim(coordinates.subtype))){ |
|
|
106 |
subtype=coordinates.subtype$subtype |
|
|
107 |
}else{ |
|
|
108 |
subtype=coordinates.subtype |
|
|
109 |
} |
|
|
110 |
|
|
|
111 |
# make lv of the subtype: |
|
|
112 |
lv=get.logical(list(subtype)) |
|
|
113 |
|
|
|
114 |
# scores |
|
|
115 |
gm.objects=do.call(rbind, lapply(seq(genesets), function(i){ |
|
|
116 |
dat3=2^gexp[rownames(gexp)%in%genesets[[i]],,drop=F]+0.01 |
|
|
117 |
gm=log2(t(apply(dat3, 2, gm_mean))) # done to normalized values |
|
|
118 |
rownames(gm)=names(genesets)[i] |
|
|
119 |
return(gm) |
|
|
120 |
})) |
|
|
121 |
|
|
|
122 |
|
|
|
123 |
res=wrapper.wilcoxtest(rownames(gm.objects), data = gm.objects, logicalVectors = lv, ALTERNATIVE = "two.sided", adj.method = "BH", CORES = 8, prettynum = F) |
|
|
124 |
|
|
|
125 |
res$Name=names(files)[i] |
|
|
126 |
# res=res[res$FDR<0.05,] |
|
|
127 |
return(res) |
|
|
128 |
} |
|
|
129 |
# compute cytolytic and HLA scores |
|
|
130 |
genesets=list(HLAIScore=c("B2M", "HLA-A", "HLA-B","HLA-C"), HLAIIScore=c("HLA-DMA","HLA-DMB","HLA-DPA1","HLA-DPB1","HLA-DRA","HLA-DRB1"), CytolyticScore=c("GZMA", "PRF1", "GNLY", "GZMH", "GZMM")) |
|
|
131 |
|
|
|
132 |
res.immunoscores=lapply(seq(files), wrapper.immunoscore.analysis, files, genesets) |
|
|
133 |
|
|
|
134 |
# diseases to test: |
|
|
135 |
AML=grep("AML", files) |
|
|
136 |
ALL=grep("ALL", files) |
|
|
137 |
MM=grep("MM", files) |
|
|
138 |
DLBCL=grep("DLBCL", files) |
|
|
139 |
|
|
|
140 |
# all results |
|
|
141 |
AML.res=do.call(rbind, res[AML]) |
|
|
142 |
ALL.res=do.call(rbind, res[ALL]) |
|
|
143 |
ALL.res$Gene[ALL.res$Gene=="VSIR"]="C10orf54" |
|
|
144 |
MM.res=do.call(rbind, res[MM]) |
|
|
145 |
DLBCL.res=do.call(rbind, res[DLBCL]) |
|
|
146 |
|
|
|
147 |
# all results |
|
|
148 |
AML.resR=do.call(rbind, resR[AML]) |
|
|
149 |
ALL.resR=do.call(rbind, resR[ALL]) |
|
|
150 |
MM.resR=do.call(rbind, resR[MM]) |
|
|
151 |
DLBCL.resR=do.call(rbind, resR[DLBCL]) |
|
|
152 |
|
|
|
153 |
# all results |
|
|
154 |
AML.res.immunoscores=do.call(rbind, res.immunoscores[AML]) |
|
|
155 |
ALL.res.immunoscores=do.call(rbind, res.immunoscores[ALL]) |
|
|
156 |
MM.res.immunoscores=do.call(rbind, res.immunoscores[MM]) |
|
|
157 |
DLBCL.res.immunoscores=do.call(rbind, res.immunoscores[DLBCL]) |
|
|
158 |
|
|
|
159 |
get.summary.df=function(gene, res.df, stars=T){ |
|
|
160 |
a=sapply(unique(res.df$Group1), function(subtype){ |
|
|
161 |
mean(res.df$FC[res.df$Gene%in%gene&res.df$Group1%in%subtype]) |
|
|
162 |
}) |
|
|
163 |
b=sapply(unique(res.df$Group1), function(subtype){ |
|
|
164 |
survcomp::combine.test(res.df$FDR[res.df$Gene%in%gene&res.df$Group1%in%subtype], method = "z.transform") |
|
|
165 |
}) |
|
|
166 |
|
|
|
167 |
pval=-log10(b) |
|
|
168 |
if(stars){ |
|
|
169 |
pval[b>0.05]=0 |
|
|
170 |
pval[b<0.05]=1 |
|
|
171 |
pval[b<0.01]=2 |
|
|
172 |
pval[b<0.001]=3 |
|
|
173 |
pval[b<1e-5]=4 |
|
|
174 |
pval[b<1e-16]=6 |
|
|
175 |
} |
|
|
176 |
|
|
|
177 |
data.frame("variable.1"=log2(a), "variable.2"=pval, "features"=gene, "id"=unique(res.df$Group1)) |
|
|
178 |
} |
|
|
179 |
|
|
|
180 |
genes.costim=c('CD80', 'CD86', 'CD274', 'PDCD1LG2', 'CD276','C10orf54', 'ICOSLG', 'TNFRSF14', 'PVR','PVRL2', 'PVRL3', 'LGALS9', 'CD48', 'CD58', 'SLAMF6', 'SLAMF7', 'CD84', 'LY9', 'TNFSF4', 'TNFSF8', 'TNFSF9', 'TNFSF18', 'TNFSF15', 'CD70', 'BTN1A1', 'BTN2A2', 'BTN3A1', 'BTNL2', 'BTNL8', 'CD72', 'CD200', 'MICA', 'MICB', 'ULBP1', 'ULBP2', 'ULBP3','RAET1E', 'CLEC2B', 'CLEC2D', 'VTCN1', 'HHLA2', 'IDO1', 'IDO2', 'TDO2', 'NT5E', 'ENTPD1', 'ARG1') |
|
|
181 |
|
|
|
182 |
cat(ligand.name[match(genes.costim, co.stim$Gene)], sep="\n") |
|
|
183 |
cat(Receptor.name[match(genes.costim, co.stim$Gene)], sep="\n") |
|
|
184 |
cat(co.stim$`Immune checkpoint function`[match(genes.costim, co.stim$Gene)], sep="\n") |
|
|
185 |
|
|
|
186 |
# summarize all the values costim: |
|
|
187 |
df.AML=do.call(rbind, lapply(genes.costim, get.summary.df, AML.res)) |
|
|
188 |
df.ALL=do.call(rbind, lapply(genes.costim, get.summary.df, ALL.res)) |
|
|
189 |
df.MM=do.call(rbind, lapply(genes.costim, get.summary.df, MM.res)) |
|
|
190 |
df.DLBCL=do.call(rbind, lapply(genes.costim, get.summary.df, DLBCL.res)) |
|
|
191 |
|
|
|
192 |
# all together: |
|
|
193 |
all.subtypes=c(c("MDS-like", "Progenitor-like", "Monocyte-like", "Monocyte-like-MLL", "CEBPA", "RUNX1-RUNX1T1", "CBFB-MYH11", "PML-RARA"),c("Ph", "KMT2A", "TCF3-PBX1","Hyperdiploid","ETV6-RUNX1", "PAX5 P80R", "PAX5alt","DUX4", "ZNF384", "MEF2D", "Other"), c("ABC", "GCB"), c("Hyperdiploid_gain1q", "Hyperdiploid_gain11q", "CCND1_Ig", "MAF_Ig", "WHSC1_FGFR3_Ig", "TRAF3_Aberrated")) |
|
|
194 |
all.df=rbind(df.AML, df.ALL, df.MM, df.DLBCL) |
|
|
195 |
all.df=all.df[all.df$id%in%all.subtypes,] |
|
|
196 |
all.df=all.df[order(match(as.character(all.df$id), all.subtypes)),] |
|
|
197 |
|
|
|
198 |
# summarize all the values, costim R: |
|
|
199 |
df.AML.R=do.call(rbind, lapply(unique(co.stimR.f), get.summary.df, AML.resR)) |
|
|
200 |
df.ALL.R=do.call(rbind, lapply(unique(co.stimR.f), get.summary.df, ALL.resR)) |
|
|
201 |
df.MM.R=do.call(rbind, lapply(unique(co.stimR.f), get.summary.df, MM.resR)) |
|
|
202 |
df.DLBCL.R=do.call(rbind, lapply(unique(co.stimR.f), get.summary.df, DLBCL.resR)) |
|
|
203 |
|
|
|
204 |
# summarize all the values, immunoscores: |
|
|
205 |
df.AML.immunoscores=do.call(rbind, lapply(rev(unique(AML.res.immunoscores[,1])), get.summary.df, AML.res.immunoscores)) |
|
|
206 |
df.ALL.immunoscores=do.call(rbind, lapply(rev(unique(AML.res.immunoscores[,1])), get.summary.df, ALL.res.immunoscores)) |
|
|
207 |
df.MM.immunoscores=do.call(rbind, lapply(rev(unique(AML.res.immunoscores[,1])), get.summary.df, MM.res.immunoscores)) |
|
|
208 |
df.DLBCL.immunoscores=do.call(rbind, lapply(rev(unique(AML.res.immunoscores[,1])), get.summary.df, DLBCL.res.immunoscores)) |
|
|
209 |
|
|
|
210 |
all.df.immunoscores=rbind(df.AML.immunoscores, df.ALL.immunoscores, df.MM.immunoscores, df.DLBCL.immunoscores) |
|
|
211 |
all.df.immunoscores=all.df.immunoscores[all.df.immunoscores$id%in%all.subtypes,] |
|
|
212 |
all.df.immunoscores=all.df.immunoscores[order(match(as.character(all.df.immunoscores$id), all.subtypes)),] |
|
|
213 |
|
|
|
214 |
all.df$features=factor(all.df$features, levels=unique(all.df$features)) |
|
|
215 |
all.df$id=factor(all.df$id, levels=unique(all.df$id)) |
|
|
216 |
all.df.immunoscores$features=factor(all.df.immunoscores$features, levels=unique(all.df.immunoscores$features)) |
|
|
217 |
all.df.immunoscores$id=factor(all.df.immunoscores$id, levels=unique(all.df.immunoscores$id)) |
|
|
218 |
|
|
|
219 |
plot.dat=rbind(all.df.immunoscores, all.df) |
|
|
220 |
|
|
|
221 |
# Final: |
|
|
222 |
pdf("FigS5B_dotplot.pdf", width = 6, height = 6) |
|
|
223 |
plot.DotPlot.df(data.plot = plot.dat, name.variable.1 = "Fold-Change (log2)", name.variable.2 = "FDR (-log10)", cols = c("blue", "white","red"), col.min = -2, col.max = 2, scale.min = 1, scale.max = 6, dot.scale = 2.5, number.legend.points = 6, fontsize = 7) |
|
|
224 |
dev.off() |
|
|
225 |
|
|
|
226 |
|
|
|
227 |
df.AML=df.AML[order(-df.AML$variable.2, df.AML$id),] |
|
|
228 |
df.AML$features=factor(df.AML$features, levels = unique(as.character(df.AML$features))[order(df.AML$variable.1)]) |
|
|
229 |
df.AML$id=factor(df.AML$id, levels = unique(as.character(df.AML$id))) |
|
|
230 |
|
|
|
231 |
# find for each subtype genes that are upregulated/downregulated: |
|
|
232 |
find=ALL.res$FDR<0.05&abs(log2(ALL.res$FC))>0.15 |
|
|
233 |
ALL.res=ALL.res[find,] |
|
|
234 |
|
|
|
235 |
# find for each subtype genes that are upregulated/downregulated: |
|
|
236 |
find=MM.res$FDR<0.05&abs(log2(MM.res$FC))>0.15 |
|
|
237 |
MM.res=MM.res[find,] |
|
|
238 |
|
|
|
239 |
# find for each subtype genes that are upregulated/downregulated: |
|
|
240 |
find=DLBCL.res$FDR<0.05&abs(log2(DLBCL.res$FC))>0.15 |
|
|
241 |
DLBCL.res=DLBCL.res[find,] |
|
|
242 |
|
|
|
243 |
# write tables for supplement: |
|
|
244 |
write.table(AML.res, file = "TableS5_AML_costim_DEgenes.txt", col.names = T, row.names = F, quote = F, sep="\t") |
|
|
245 |
write.table(ALL.res, file = "TableS5_ALL_costim_DEgenes.txt", col.names = T, row.names = F, quote = F, sep="\t") |
|
|
246 |
write.table(MM.res, file = "TableS5_MM_costim_DEgenes.txt", col.names = T, row.names = F, quote = F, sep="\t") |
|
|
247 |
write.table(DLBCL.res, file = "TableS5_DLBCL_costim_DEgenes.txt", col.names = T, row.names = F, quote = F, sep="\t") |
|
|
248 |
|
|
|
249 |
|
|
|
250 |
# diseases to test: |
|
|
251 |
AML=grep("AML", files) |
|
|
252 |
ALL=grep("ALL", files) |
|
|
253 |
MM=grep("MM", files) |
|
|
254 |
DLBCL=grep("DLBCL", files) |
|
|
255 |
|
|
|
256 |
# find for each subtype genes that are upregulated/downregulated: |
|
|
257 |
find=AML.resR$FDR<0.05&abs(log2(AML.resR$FC))>0.15 |
|
|
258 |
AML.resR=AML.resR[find,] |
|
|
259 |
|
|
|
260 |
# find for each subtype genes that are upregulated/downregulated: |
|
|
261 |
find=ALL.resR$FDR<0.05&abs(log2(ALL.resR$FC))>0.15 |
|
|
262 |
ALL.resR=ALL.resR[find,] |
|
|
263 |
|
|
|
264 |
# find for each subtype genes that are upregulated/downregulated: |
|
|
265 |
find=MM.resR$FDR<0.05&abs(log2(MM.resR$FC))>0.15 |
|
|
266 |
MM.resR=MM.resR[find,] |
|
|
267 |
|
|
|
268 |
# find for each subtype genes that are upregulated/downregulated: |
|
|
269 |
find=DLBCL.resR$FDR<0.05&abs(log2(DLBCL.resR$FC))>0.15 |
|
|
270 |
DLBCL.resR=DLBCL.resR[find,] |
|
|
271 |
|
|
|
272 |
# write tables for supplement: |
|
|
273 |
# write.table(AML.resR, file = "AML_costimR_DEgenes.txt", col.names = T, row.names = F, quote = F, sep="\t") |
|
|
274 |
# write.table(ALL.resR, file = "ALL_costimR_DEgenes.txt", col.names = T, row.names = F, quote = F, sep="\t") |
|
|
275 |
# write.table(MM.resR, file = "MM_costimR_DEgenes.txt", col.names = T, row.names = F, quote = F, sep="\t") |
|
|
276 |
# write.table(DLBCL.resR, file = "DLBCL_costimR_DEgenes.txt", col.names = T, row.names = F, quote = F, sep="\t") |
|
|
277 |
|
|
|
278 |
|
|
|
279 |
|
|
|
280 |
# similar analysis to immunoscores: |
|
|
281 |
# find for each subtype genes that are upregulated/downregulated: |
|
|
282 |
find=AML.res.immunoscores$FDR<0.05&abs(log2(AML.res.immunoscores$FC))>0.15 |
|
|
283 |
AML.res.immunoscores=AML.res.immunoscores[find,] |
|
|
284 |
|
|
|
285 |
# find for each subtype genes that are upregulated/downregulated: |
|
|
286 |
find=ALL.res.immunoscores$FDR<0.05&abs(log2(ALL.res.immunoscores$FC))>0.15 |
|
|
287 |
ALL.res.immunoscores=ALL.res.immunoscores[find,] |
|
|
288 |
|
|
|
289 |
# find for each subtype genes that are upregulated/downregulated: |
|
|
290 |
find=MM.res.immunoscores$FDR<0.05&abs(log2(MM.res.immunoscores$FC))>0.15 |
|
|
291 |
MM.res.immunoscores=MM.res.immunoscores[find,] |
|
|
292 |
|
|
|
293 |
# find for each subtype genes that are upregulated/downregulated: |
|
|
294 |
find=DLBCL.res.immunoscores$FDR<0.05&abs(log2(DLBCL.res.immunoscores$FC))>0.15 |
|
|
295 |
DLBCL.res.immunoscores=DLBCL.res.immunoscores[find,] |
|
|
296 |
|
|
|
297 |
# write tables for supplement: |
|
|
298 |
# write.table(AML.res.immunoscores, file = "AML_immunoscores_DEgenes.txt", col.names = T, row.names = F, quote = F, sep="\t") |
|
|
299 |
# write.table(ALL.res.immunoscores, file = "ALL_immunoscores_DEgenes.txt", col.names = T, row.names = F, quote = F, sep="\t") |
|
|
300 |
# write.table(MM.res.immunoscores, file = "MM_immunoscores_DEgenes.txt", col.names = T, row.names = F, quote = F, sep="\t") |
|
|
301 |
# write.table(DLBCL.res.immunoscores, file = "DLBCL_immunoscores_DEgenes.txt", col.names = T, row.names = F, quote = F, sep="\t") |
|
|
302 |
|
|
|
303 |
extract.res=function(de.genes, geneannot){ |
|
|
304 |
subtypes=de.genes$Group1 |
|
|
305 |
|
|
|
306 |
de.genes.up=de.genes$FC>1 |
|
|
307 |
de.genes.down=de.genes$FC<1 |
|
|
308 |
|
|
|
309 |
res=lapply(unique(subtypes), function(type){ |
|
|
310 |
|
|
|
311 |
counts.up=table(de.genes$Gene[subtypes%in%type&de.genes.up]) |
|
|
312 |
counts.down=table(de.genes$Gene[subtypes%in%type&de.genes.down]) |
|
|
313 |
|
|
|
314 |
res.up=list() |
|
|
315 |
res.down=list() |
|
|
316 |
|
|
|
317 |
# up |
|
|
318 |
if(sum(counts.up>1)>0){ |
|
|
319 |
significant=names(counts.up)[counts.up>1] |
|
|
320 |
funct=geneannot[match(significant, geneannot[,1]),2] |
|
|
321 |
|
|
|
322 |
res.up=data.frame(significant, funct, direction="upregulated", stringsAsFactors = F) |
|
|
323 |
res.up=res.up[order(res.up$funct),] |
|
|
324 |
} |
|
|
325 |
|
|
|
326 |
# down |
|
|
327 |
if(sum(counts.down>1)>0){ |
|
|
328 |
significant=names(counts.down)[counts.down>1] |
|
|
329 |
funct=geneannot[match(significant, geneannot[,1]),2] |
|
|
330 |
|
|
|
331 |
res.down=data.frame(significant, funct, direction="downregulated", stringsAsFactors = F) |
|
|
332 |
res.down=res.down[order(res.down$funct),] |
|
|
333 |
} |
|
|
334 |
|
|
|
335 |
res=rbind(res.up, res.down) |
|
|
336 |
}) |
|
|
337 |
|
|
|
338 |
names(res)=unique(subtypes) |
|
|
339 |
|
|
|
340 |
return(res) |
|
|
341 |
} |
|
|
342 |
|
|
|
343 |
# all results: |
|
|
344 |
data.AML=extract.res(AML.res[AML.res$FDR<0.05&abs(log2(AML.res$FC))>0.15,], co.stim[,c(1,3)]) |
|
|
345 |
# sapply(names(data.AML),function (x) write.table(data[[x]], file=paste(x, "_AML_costim.txt", sep=""), quote = F, sep="\t", col.names = T, row.names = F)) |
|
|
346 |
|
|
|
347 |
data.ALL=extract.res(ALL.res[ALL.res$FDR<0.05&abs(log2(ALL.res$FC))>0.15,], co.stim[,c(1,3)]) |
|
|
348 |
# sapply(names(data.ALL)[!sapply(data.ALL, length)==0],function (x) write.table(data[[x]], file=paste(x, "_ALL_costim.txt", sep=""), quote = F, sep="\t", col.names = T, row.names = F)) |
|
|
349 |
|
|
|
350 |
data.MM=extract.res(MM.res, co.stim[,c(1,3)]) |
|
|
351 |
# sapply(names(data.MM),function (x) write.table(data[[x]], file=paste(x, "_MM_costim.txt", sep=""), quote = F, sep="\t", col.names = T, row.names = F)) |
|
|
352 |
|
|
|
353 |
data.DLBCL=extract.res(DLBCL.res[DLBCL.res$FDR<0.05&abs(log2(DLBCL.res$FC))>0.15,], co.stim[,c(1,3)]) |
|
|
354 |
# sapply(names(data.DLBCL),function (x) write.table(data[[x]], file=paste(x, "_DLBCL_costim.txt", sep=""), quote = F, sep="\t", col.names = T, row.names = F)) |
|
|
355 |
|
|
|
356 |
data.AML.R=extract.res(AML.resR, co.stimR.func) |
|
|
357 |
# sapply(names(data.AML.R)[names(data.AML.R)%in%"MDS-like"],function (x) write.table(data[[x]], file=paste(x, "_AML_costimR.txt", sep=""), quote = F, sep="\t", col.names = T, row.names = F)) |
|
|
358 |
|
|
|
359 |
data.ALL.R=extract.res(ALL.resR[ALL.resR$FDR<0.05&abs(log2(ALL.resR$FC))>0.15,], co.stimR.func) |
|
|
360 |
# sapply(names(data)[-15],function (x) write.table(data[[x]], file=paste(x, "_ALL_costimR.txt", sep=""), quote = F, sep="\t", col.names = T, row.names = F)) |
|
|
361 |
|
|
|
362 |
data=extract.res(MM.resR, co.stimR.func) |
|
|
363 |
# sapply(names(data),function (x) write.table(data[[x]], file=paste(x, "_MM_costimR.txt", sep=""), quote = F, sep="\t", col.names = T, row.names = F)) |
|
|
364 |
|
|
|
365 |
data.DLBCL.R=extract.res(DLBCL.resR, co.stimR.func) |
|
|
366 |
# sapply(names(data.DLBCL.R),function (x) write.table(data[[x]], file=paste(x, "_DLBCL_costimR.txt", sep=""), quote = F, sep="\t", col.names = T, row.names = F)) |
|
|
367 |
|
|
|
368 |
data=extract.res(AML.res.immunoscores, co.stim) |
|
|
369 |
# sapply(names(data),function (x) write.table(data[[x]], file=paste(x, "_AML_immunoscores.txt", sep=""), quote = F, sep="\t", col.names = T, row.names = F)) |
|
|
370 |
|
|
|
371 |
data=extract.res(ALL.res.immunoscores, co.stim) |
|
|
372 |
# sapply(names(data),function (x) write.table(data[[x]], file=paste(x, "_ALL_immunoscores.txt", sep=""), quote = F, sep="\t", col.names = T, row.names = F)) |
|
|
373 |
|
|
|
374 |
data=extract.res(MM.res.immunoscores, co.stim) |
|
|
375 |
# sapply(names(data),function (x) write.table(data[[x]], file=paste(x, "_MM_immunoscores.txt", sep=""), quote = F, sep="\t", col.names = T, row.names = F)) |
|
|
376 |
|
|
|
377 |
data=extract.res(DLBCL.res.immunoscores, co.stim) |
|
|
378 |
# sapply(names(data),function (x) write.table(data[[x]], file=paste(x, "_DLBCL_immunoscores.txt", sep=""), quote = F, sep="\t", col.names = T, row.names = F)) |
|
|
379 |
|
|
|
380 |
|
|
|
381 |
inhibitory=c("CytolyticScore", "HLAIIScore","HLAIScore", co.stim[grepl("Inhibitory|unknown", co.stim$`Immune checkpoint function`),1], co.stimR.func[grepl("Inhibitory|unknown", co.stimR.func[,2]),1]) |
|
|
382 |
stimulatory=c("CytolyticScore", "HLAIIScore","HLAIScore", co.stim[grepl("Stimulatory", co.stim$`Immune checkpoint function`),1], co.stimR.func[grepl("Stimulatory", co.stimR.func[,2]),1]) |
|
|
383 |
stimulatory=stimulatory[!stimulatory%in%"CTLA4"] |
|
|
384 |
|
|
|
385 |
# AML.interesting: |
|
|
386 |
subtype.order=c("MDS-like", "Progenitor-like", "Monocyte-like", "Monocyte-like-MLL", "CEBPA", "RUNX1-RUNX1T1", "CBFB-MYH11", "PML-RARA") |
|
|
387 |
df.AML.pick=rbind(df.AML,df.AML.R, df.AML.immunoscores) |
|
|
388 |
df.AML.pick$features=as.character(df.AML.pick$features) |
|
|
389 |
df.AML.pick$id=as.character(df.AML.pick$id) |
|
|
390 |
interesting.feats=unique(c("CytolyticScore", "HLAIIScore","PVRL3", "SLAMF7","HHLA2","CD274", "TNFRSF14", "ARG1","PVR","CD86", "C10orf54", "CD276","ENTPD1","NT5E", "CD48", "ICOSLG","TNFSF8", "LY9", "BTN3A1","CD200", "ULBP1", "LGALS9", "CD70", "MICB", "TNFSF9", "ULBP1", "ULBP3","CLEC2D","TNFSF9","CD84","LY9","CD58","CD72","LGALS9", "CD86", "CD48", "CLEC2B", "LY9", "TNFSF15", "TNFSF8","CD276", "PVR", "BTNL8", "CD58", |
|
|
391 |
"LAG3", "SLAMF7","TIGIT","TMIGD2", "PDCD1", "CD160")) |
|
|
392 |
|
|
|
393 |
# take all |
|
|
394 |
interesting.feats.L=unlist(sapply(data.AML[subtype.order], function(d)d$significant[d$direction=="upregulated"])) |
|
|
395 |
interesting.feats.R=unlist(sapply(data.AML.R[names(data.AML.R)%in%"MDS-like"], function(d)d$significant[d$direction=="upregulated"])) |
|
|
396 |
|
|
|
397 |
interesting.feats=c("CytolyticScore", "HLAIIScore", interesting.feats.L, interesting.feats.R) |
|
|
398 |
|
|
|
399 |
df.AML.pick=df.AML.pick[df.AML.pick$features%in%interesting.feats,] |
|
|
400 |
df.AML.pick=df.AML.pick[order(match(df.AML.pick$id, subtype.order)),] |
|
|
401 |
df.AML.pick=df.AML.pick[order(match(df.AML.pick$features, interesting.feats)),] |
|
|
402 |
df.AML.pick$features=factor(df.AML.pick$features, levels=unique(df.AML.pick$features)) |
|
|
403 |
df.AML.pick$id=factor(df.AML.pick$id, levels=unique(df.AML.pick$id)) |
|
|
404 |
|
|
|
405 |
# ALL.interesting: |
|
|
406 |
subtype.order=c("Ph", "KMT2A", "TCF3-PBX1","Hyperdiploid","ETV6-RUNX1", "PAX5 P80R", "PAX5alt","DUX4", "ZNF384", "MEF2D", "Other") |
|
|
407 |
df.ALL.pick=rbind(df.ALL,df.ALL.R, df.ALL.immunoscores) |
|
|
408 |
df.ALL.pick=df.ALL.pick[df.ALL.pick$id%in%subtype.order,] |
|
|
409 |
df.ALL.pick$features=as.character(df.ALL.pick$features) |
|
|
410 |
df.ALL.pick$id=as.character(df.ALL.pick$id) |
|
|
411 |
interesting.feats=unique(c("CytolyticScore", "HLAIIScore","HLAIScore", |
|
|
412 |
"CD200", "NT5E", "TNFRSF14", "BTN3A1", "CLEC2B", "TNFSF4", "TNFSF8", |
|
|
413 |
"CLEC2D", "CD58", "CD72","TNFSF8", "TNFSF9", |
|
|
414 |
"CLEC2D","CD48", "CD58", "CD72","CD84", |
|
|
415 |
"CD200", "CD86", "ICOSLG", "MICA", |
|
|
416 |
"BTN2A2", "CD200", "NT5E", "BTN3A1", "TNFSF4", |
|
|
417 |
"TNFRSF14", "CD48", "LY9", "TNFSF4", |
|
|
418 |
"NT5E", "TNFRSF14", "CLEC2D", "CD48", "CD70", "CLEC2B", "LY9", |
|
|
419 |
"BTN2A2", "LGALS9", "TNFRSF14", "CD84", "LY9", "TNFSF4", "TNFSF9", |
|
|
420 |
"ENTPD1", "LGALS9", "TNFRSF14", "CD84", "CLEC2B", "TNFSF9", |
|
|
421 |
"NT5E", "CLEC2D", "CD48", "CD72", "CD84", |
|
|
422 |
"CD274", "CD80" |
|
|
423 |
)) |
|
|
424 |
|
|
|
425 |
interesting.feats.L=unlist(sapply(data.ALL[subtype.order], function(d)d$significant[d$direction=="upregulated"])) |
|
|
426 |
interesting.feats.R=unlist(sapply(data.ALL.R[subtype.order], function(d)d$significant[d$direction=="upregulated"])) |
|
|
427 |
interesting.feats=c("CytolyticScore", "HLAIIScore","HLAIScore", interesting.feats.L, interesting.feats.R) |
|
|
428 |
|
|
|
429 |
df.ALL.pick=df.ALL.pick[df.ALL.pick$features%in%interesting.feats,] |
|
|
430 |
df.ALL.pick=df.ALL.pick[order(match(df.ALL.pick$id, subtype.order)),] |
|
|
431 |
df.ALL.pick=df.ALL.pick[order(match(df.ALL.pick$features, interesting.feats)),] |
|
|
432 |
df.ALL.pick$features=factor(df.ALL.pick$features, levels=unique(df.ALL.pick$features)) |
|
|
433 |
df.ALL.pick$id=factor(df.ALL.pick$id, levels=unique(df.ALL.pick$id)) |
|
|
434 |
|
|
|
435 |
# MM.interesting: |
|
|
436 |
subtype.order=c("Hyperdiploid_gain1q", "Hyperdiploid_gain11q", "MAF_Ig", "WHSC1_FGFR3_Ig", "TRAF3_Aberrated", "CCND1_Ig") |
|
|
437 |
df.MM.pick=rbind(df.MM,df.MM.R, df.MM.immunoscores) |
|
|
438 |
df.MM.pick$features=as.character(df.MM.pick$features) |
|
|
439 |
df.MM.pick$id=as.character(df.MM.pick$id) |
|
|
440 |
interesting.feats=unique(c("HLAIIScore","HLAIScore", "MICA", "MICB", |
|
|
441 |
"CD274","LGALS9", "CD200", "CD48", "CD86", "ICOSLG", "PVRL3")) |
|
|
442 |
interesting.feats=unlist(sapply(data.MM[subtype.order], function(d)d$significant[d$direction=="upregulated"])) |
|
|
443 |
interesting.feats=c("HLAIIScore","HLAIScore", interesting.feats) |
|
|
444 |
|
|
|
445 |
df.MM.pick=df.MM.pick[df.MM.pick$features%in%interesting.feats,] |
|
|
446 |
df.MM.pick=df.MM.pick[order(match(df.MM.pick$id, subtype.order)),] |
|
|
447 |
df.MM.pick=df.MM.pick[order(match(df.MM.pick$features, interesting.feats)),] |
|
|
448 |
df.MM.pick$features=factor(df.MM.pick$features, levels=unique(df.MM.pick$features)) |
|
|
449 |
df.MM.pick$id=factor(df.MM.pick$id, levels=unique(df.MM.pick$id)) |
|
|
450 |
|
|
|
451 |
# DLBCL.interesting: |
|
|
452 |
df.DLBCL.pick=rbind(df.DLBCL,df.DLBCL.R, df.DLBCL.immunoscores) |
|
|
453 |
df.DLBCL.pick$features=as.character(df.DLBCL.pick$features) |
|
|
454 |
df.DLBCL.pick$id=as.character(df.DLBCL.pick$id) |
|
|
455 |
interesting.feats=unique(c("CytolyticScore", "HLAIIScore","HLAIScore","CD274","TNFRSF14", "ENTPD1","SLAMF7", "ICOSLG", "LY9","CD86", |
|
|
456 |
"PDCD1", "BTLA","CD160", "SLAMF7", "LAG3")) |
|
|
457 |
# take all |
|
|
458 |
interesting.feats.L=unlist(sapply(data.DLBCL[c("ABC", "GCB")], function(d)d$significant[d$direction=="upregulated"])) |
|
|
459 |
interesting.feats.R=unlist(sapply(data.DLBCL.R[c("ABC", "GCB")], function(d)d$significant[d$direction=="upregulated"])) |
|
|
460 |
|
|
|
461 |
interesting.feats=c("CytolyticScore", "HLAIIScore", interesting.feats.L, interesting.feats.R) |
|
|
462 |
|
|
|
463 |
df.DLBCL.pick=df.DLBCL.pick[df.DLBCL.pick$features%in%interesting.feats&df.DLBCL.pick$id%in%c("ABC", "GCB"),] |
|
|
464 |
df.DLBCL.pick=df.DLBCL.pick[order(match(df.DLBCL.pick$id, c("ABC", "GCB"))),] |
|
|
465 |
df.DLBCL.pick=df.DLBCL.pick[order(match(df.DLBCL.pick$features, interesting.feats)),] |
|
|
466 |
df.DLBCL.pick$features=factor(df.DLBCL.pick$features, levels=unique(df.DLBCL.pick$features)) |
|
|
467 |
df.DLBCL.pick$id=factor(df.DLBCL.pick$id, levels=unique(df.DLBCL.pick$id)) |
|
|
468 |
|
|
|
469 |
# Most interesting shown in main figure, rest in FigS5B. These were significant in at least 2 data sets. Also checked expression in scRNA for various targets. |
|
|
470 |
pdf("Fig5B_AML.pdf", height = 3.5, width = 4.25) |
|
|
471 |
plot.DotPlot.df(data.plot = df.AML.pick[df.AML.pick$features%in%c("CytolyticScore", "HLAIIScore", "PVRL3", "SLAMF7", "HHLA2", "CD274", "TNFRSF14", "ARG1", "PVR", "CD86", "C10orf54", "CD276", "ENTPD1", "NT5E", "CLEC2B", "CD84", "CD48", "LAG3", "TIGIT", "SLAMF7", "TMIGD2", "PDCD1", "CD160", "CD2", "KLRF1"),], name.variable.1 = "Fold-Change (log2)", name.variable.2 = "FDR (-log10)", cols = c("blue", "white","red"), col.min = -2, col.max = 2, scale.min = 1, scale.max = 6, dot.scale = 2.5, number.legend.points = 6, fontsize = 8) |
|
|
472 |
dev.off() |
|
|
473 |
|
|
|
474 |
pdf("Fig5B_ALL.pdf", height = 1.5, width = 4.25) |
|
|
475 |
plot.DotPlot.df(data.plot = df.ALL.pick[df.ALL.pick$features%in%c("CD274", "C10orf54", "NT5E"),], name.variable.1 = "Fold-Change (log2)", name.variable.2 = "FDR (-log10)", cols = c("blue", "white","red"), col.min = -2, col.max = 2, scale.min = 1, scale.max = 6, dot.scale = 2.5, number.legend.points = 6, fontsize = 8) |
|
|
476 |
dev.off() |
|
|
477 |
|
|
|
478 |
pdf("Fig5B_MM.pdf", height = 2.25, width = 3.8) |
|
|
479 |
plot.DotPlot.df(data.plot = df.MM.pick[df.MM.pick$features%in%c("CytolyticScore", "HLAIIScore","MICA", "MICB","CD274","LGALS9", "CD48", "CD86", "ICOSLG", "PVRL3"),], name.variable.1 = "Fold-Change (log2)", name.variable.2 = "FDR (-log10)", cols = c("blue", "white","red"), col.min = -2, col.max = 2, scale.min = 1, scale.max = 6, dot.scale = 2.5, number.legend.points = 6, fontsize = 8) |
|
|
480 |
dev.off() |
|
|
481 |
|
|
|
482 |
pdf("Fig5B_DLBCL.pdf", height = 3.5, width = 3.5) |
|
|
483 |
# all interesting: |
|
|
484 |
plot.DotPlot.df(data.plot = df.DLBCL.pick, name.variable.1 = "Fold-Change (log2)", name.variable.2 = "FDR (-log10)", cols = c("blue", "white","red"), col.min = -2, col.max = 2, scale.min = 1, scale.max = 6, dot.scale = 3, number.legend.points = 6) |
|
|
485 |
plot.DotPlot.df(data.plot = df.DLBCL.pick, name.variable.1 = "Fold-Change (log2)", name.variable.2 = "FDR (-log10)", cols = c("blue", "white","red"), dot.scale = 3) |
|
|
486 |
dev.off() |