|
a |
|
b/Fig1_plots.R |
|
|
1 |
GIT_HOME="/research/users/ppolonen/git_home/ImmunogenomicLandscape-BloodCancers/" |
|
|
2 |
source(file.path(GIT_HOME, "common_scripts/featurematrix/functions_generate_fm.R")) |
|
|
3 |
source(file.path(GIT_HOME, "common_scripts/visualisation/plotting_functions.R")) |
|
|
4 |
|
|
|
5 |
# Set working directory |
|
|
6 |
setwd("/research/groups/sysgen/PROJECTS/HEMAP_IMMUNOLOGY/petri_work/HEMAP_IMMUNOLOGY/Published_data_figures") |
|
|
7 |
|
|
|
8 |
# gexp data |
|
|
9 |
data=get(load("data9544_with_gene_symbols.RData")) |
|
|
10 |
|
|
|
11 |
# annotations |
|
|
12 |
annot = get(load("Hemap_immunology_Annotations.Rdata")) |
|
|
13 |
data=data[rownames(data)%in%annot[,1],] |
|
|
14 |
|
|
|
15 |
# make logical vectors |
|
|
16 |
annot$tbLY[annot$tbLY%in%c("Lymphoma_BCL_DLBCL_GCB", "Lymphoma_BCL_DLBCL_ABC")]="Lymphoma_BCL_DLBCL" |
|
|
17 |
tbly=get.logical(list(annot$tbLY), filterv = annot$CELLS_SORTED==0&!grepl("TCL", annot$tbLY)&!annot$CLASS2%in%"Cancer_Lymphoma_BCL_DLBCL_testicular") |
|
|
18 |
testicular=list("DLBCL_testicular"=annot$CLASS2%in%"Cancer_Lymphoma_BCL_DLBCL_testicular") |
|
|
19 |
tbly=tbly[sapply(tbly, sum)>5] |
|
|
20 |
|
|
|
21 |
tbly=append(tbly, testicular) |
|
|
22 |
|
|
|
23 |
lv=get.logical(list(annot$colorClass), filterv = annot$CELLS_SORTED==0&!grepl("TCL|T-ALL", annot$colorClass)&annot$Sample.type%in%c("Cancer", "Prolif")) |
|
|
24 |
names(lv)[3]="MDS" |
|
|
25 |
|
|
|
26 |
# barplots |
|
|
27 |
v=sapply(lv, function(lv2){ |
|
|
28 |
nr.high=sum(annot$CytolyticScore.1[lv2]=="high") |
|
|
29 |
nr_samples=sum(lv2) |
|
|
30 |
nr.high/nr_samples |
|
|
31 |
}) |
|
|
32 |
v=sort(v, decreasing = T) |
|
|
33 |
v=signif(v*100,2) |
|
|
34 |
|
|
|
35 |
df2=data.frame(y=sort(v, decreasing = T), x=factor(names(v), levels = names(v))) |
|
|
36 |
|
|
|
37 |
# barplots Figure1: |
|
|
38 |
|
|
|
39 |
pdf("Fig1F.pdf",width = unit(4, "cm"),height = unit(3.5, "cm")) |
|
|
40 |
plot.boxplot("CytolyticScore", logicalVectors = lv, data = t(data.frame("CytolyticScore"=annot$CytolyticScore)), order.bl = T, intercept.y = 7.76, spread = F,outlier.size = 0.5, color.v = c("#c08e94","#4ec173", "#f9c155", "#cd7bc1", "#266c34","#8a4bac")) |
|
|
41 |
dev.off() |
|
|
42 |
|
|
|
43 |
pdf("Fig1G.pdf", width = unit(3, "cm"),height = unit(2, "cm")) |
|
|
44 |
ggplot(data=df2, aes(x=x, y=v, fill=x)) + |
|
|
45 |
geom_bar(stat="identity", position=position_dodge())+scale_fill_manual(values = c("#8a4bac", "#c08e94","#f9c155", "#266c34", "#4ec173", "#cd7bc1"))+ |
|
|
46 |
geom_text(aes(label=df2$y), vjust=1.6, color="white", |
|
|
47 |
position = position_dodge(0.9), size=3.5)+ |
|
|
48 |
theme_classic() + |
|
|
49 |
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) |
|
|
50 |
dev.off() |
|
|
51 |
|
|
|
52 |
# barplots |
|
|
53 |
v=sapply(tbly, function(lv2){ |
|
|
54 |
nr.high=sum(annot$CytolyticScore.1[lv2]=="high") |
|
|
55 |
nr_samples=sum(lv2) |
|
|
56 |
nr.high/nr_samples |
|
|
57 |
}) |
|
|
58 |
v=sort(v, decreasing = T) |
|
|
59 |
|
|
|
60 |
names(v)=gsub("Lymphoma_BCL_", "", names(v)) |
|
|
61 |
v=signif(v*100,2) |
|
|
62 |
df2=data.frame(y=sort(v, decreasing = T), x=factor(names(v), levels = names(v))) |
|
|
63 |
|
|
|
64 |
pdf("Fig1H.pdf", width = unit(3, "cm"),height = unit(2.5, "cm")) |
|
|
65 |
ggplot(data=df2, aes(x=x, y=y, fill="#c08e94")) +scale_fill_manual(values = c("#c08e94"))+ |
|
|
66 |
geom_bar(stat="identity", position=position_dodge())+ |
|
|
67 |
geom_text(aes(label=df2$y), vjust=1.6, color="white", |
|
|
68 |
position = position_dodge(0.9), size=3.5)+ |
|
|
69 |
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust = 1)) |
|
|
70 |
dev.off() |