Switch to unified view

a b/Statistical_analysis_DE_analysis_MDSlike.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
7
setwd("/research/groups/sysgen/PROJECTS/HEMAP_IMMUNOLOGY/petri_work/HEMAP_IMMUNOLOGY/Published_data_figures")
8
9
files=list.files(path = ".", "AML_subtypes.Rdata")
10
names(files)=gsub("_subtypes.Rdata", "", files)
11
12
wrapper.de.analysis=function(i, files){
13
  load(files[i])
14
  
15
  if(!is.null(dim(coordinates.subtype))){
16
    subtype=coordinates.subtype$subtype
17
  }else{
18
    subtype=coordinates.subtype
19
  }
20
  
21
  # make lv of the subtype:
22
  lv=get.logical(list(subtype))
23
  
24
  res=wrapper.wilcoxtest(rownames(gexp), data = gexp, logicalVectors = list("MDS-like"=lv$`MDS-like`), ALTERNATIVE = "greater", adj.method = "BH", CORES = 8, prettynum = F)
25
  
26
  res$Name=names(files)[i]
27
  res=res[res$FDR<0.05,]
28
  
29
}
30
31
res=lapply(seq(files), wrapper.de.analysis, files)
32
33
AML.res=do.call(rbind, res)
34
35
genes.signif=names(table(AML.res$Gene))[table(AML.res$Gene)>1] # at least 2 data sets support
36
37
# find for each subtype genes that are upregulated/downregulated:
38
find=AML.res$FDR<0.001&abs(AML.res$FC)>1&AML.res$Gene%in%genes.signif
39
AML.res=AML.res[find,]
40
41
AML.res=AML.res[order(AML.res$Name, AML.res$FDR, AML.res$FC, decreasing = F),]
42
43
write.table(AML.res, "TableS3_Significant_genes_MDSlike_bulk.txt", quote = F, row.names = F, col.names = T, sep="\t")