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

Switch to unified view

a b/Fig3_FigS3_MDSsignature.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
# cancermap coordinates:
10
library(reshape2)
11
library(gridExtra)
12
library(GSVA)
13
library(RColorBrewer)
14
library(ggplot2)
15
library(Rtsne)
16
library(LPCM)
17
18
# plotting function
19
Plot_GSVA_scores=function(feat, data_plot, VALUE, SIZE, CLUSTER_CENTRE, coord, peaks){
20
  
21
  # Find specified feature(feat) from data_plot
22
  data=data_plot[rownames(data_plot)%in%feat,]
23
  
24
  # Transform matrix to numeric. 
25
  data=as.numeric(data)
26
  
27
  # Color vector for gradient colors from blue to red.
28
  rbPal <- colorRampPalette(c('blue','red'))
29
  
30
  # Adjust data for gradient colors.
31
  data=c(data, 2, -2) # adjust range
32
  datCol <- rbPal(10)[as.numeric(cut(data,breaks = 10))]
33
  datCol=datCol[-c(length(datCol)-1, length(datCol))]
34
  data=data[-c(length(data)-1, length(data))]
35
  
36
  # Samples below cutoff colored grey.
37
  datCol[abs(data)<VALUE]="grey75"
38
  front=abs(data)>VALUE
39
  
40
  # Prepare coordinate data for plotting.
41
  dat2show <- cbind(coord$x, coord$y)
42
  df=as.data.frame(dat2show)
43
  colnames(df) = c("X1","X2")
44
  
45
  # Generate plot title. 
46
  cutoff=paste("GSVA score >", VALUE)
47
  plotname=paste(feat, cutoff, sep="\n")
48
  
49
  # Call actual plotting function.
50
  drawFig(df, CLUSTER_CENTRE, datCol, front, plotname, SIZE, peaks) 
51
}
52
53
load("MDS_genesets.Rdata")
54
geneset=list("MDS_signature"=geneset$MDS_signature_all_filt)
55
56
# go through each cohort and plot GSVA score:
57
setwd("/research/groups/sysgen/PROJECTS/HEMAP_IMMUNOLOGY/petri_work/HEMAP_IMMUNOLOGY/Published_data_figures")
58
59
files=list.files(path = ".", "subtypes.Rdata")
60
names(files)=gsub("_subtypes.Rdata", "", files)
61
62
files=files[grepl("AML", names(files))]
63
64
p.all=lapply(files, function(f){
65
  load(f)
66
  
67
  score=gsva(data.matrix(gexp), geneset, mx.diff=F, tau=0.25, parallel.sz=4)
68
  
69
  plot.val=t(scale(t(score)))
70
  
71
  a=Plot_GSVA_scores(feat = "MDS_signature", data_plot = t(scale(t(score))), VALUE = 0.5,SIZE = 1, coord = coordinates.subtype, peaks = NULL, CLUSTER_CENTRE = F)
72
  
73
})
74
75
# Save PDF figure (A4) with multiple panels
76
ggsave("Figure3E_FigureS3D.pdf", do.call(marrangeGrob, list(grobs=p.all, nrow=4, ncol=3)), width = 210, height = 297, units = "mm", dpi=150)