|
a |
|
b/Statistical_analysis_scRNA_MDSlike_analysis.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 |
|
|
|
5 |
library(Matrix) |
|
|
6 |
library(Seurat) |
|
|
7 |
library(data.table) |
|
|
8 |
library(ComplexHeatmap) |
|
|
9 |
library(circlize) |
|
|
10 |
library(parallel) |
|
|
11 |
library(ggplot2) |
|
|
12 |
|
|
|
13 |
setwd("/research/groups/sysgen/PROJECTS/HEMAP_IMMUNOLOGY/petri_work/HEMAP_IMMUNOLOGY/Published_data_figures") |
|
|
14 |
|
|
|
15 |
# analyze FIMM and Galen AML and find costim associations to certain clusters. |
|
|
16 |
co.stim=data.table::fread("costim_ligands_final.txt", data.table = F)[,c(1,3,5)] |
|
|
17 |
co.stimR=data.table::fread("costim_ligands_final.txt", data.table = F) |
|
|
18 |
co.stimR.f=c(unlist(strsplit(co.stimR$`Receptor gene`, ", ")), "LAG3") |
|
|
19 |
co.stim=rbind(co.stim, c("FGL1", "LAG3", "Inhibitory")) |
|
|
20 |
|
|
|
21 |
load("AML_Galen_scRNA.Rdata") |
|
|
22 |
galen=scmat |
|
|
23 |
|
|
|
24 |
load("FIMM_AML_scRNA.Rdata") |
|
|
25 |
|
|
|
26 |
# get more detailed annotations for T and NK cells: |
|
|
27 |
NK=get(load("Yang_HCA_AML_cluster_cell.Rdata")) |
|
|
28 |
Tcell=get(load("Szabo_HCA_AML_cluster_cell.Rdata")) |
|
|
29 |
|
|
|
30 |
anno=as.character(Idents(scmat)) |
|
|
31 |
|
|
|
32 |
# add the new annotation: |
|
|
33 |
labels=lapply(unique(NK), function(s)names(NK)[NK%in%s]) |
|
|
34 |
names(labels)=unique(NK) |
|
|
35 |
|
|
|
36 |
anno[names(Idents(scmat))%in%labels[[1]]]=paste("Mature NK cells") |
|
|
37 |
|
|
|
38 |
# add the new annotation: |
|
|
39 |
labels=lapply(unique(Tcell), function(s)names(Tcell)[Tcell%in%s]) |
|
|
40 |
names(labels)=unique(Tcell) |
|
|
41 |
|
|
|
42 |
anno[names(Idents(scmat))%in%labels[[4]]]=paste("Cytotoxic CD8+ Tem") |
|
|
43 |
anno[names(Idents(scmat))%in%labels[[1]]]=paste("Cytokine CD8+ Tem") |
|
|
44 |
|
|
|
45 |
Idents(scmat)=factor(anno, levels=c(levels(Idents(scmat)), "Mature NK cells", "Cytotoxic CD8+ Tem", "Cytokine CD8+ Tem")) |
|
|
46 |
|
|
|
47 |
# only take cells that need to be computed: |
|
|
48 |
scmat2=scmat[,grepl("HSC|MPP|MEP|GMP|CMP|Monocyte|Mature NK cells|Cytotoxic CD8|Cytokine CD8", Idents(scmat))&scmat[["batch"]][,1]%in%c("5897", "3667", "5249")] |
|
|
49 |
|
|
|
50 |
#************************************************** run cellphoneDB using these categories, focusing on interactions between blasts and NK/CD8 cells ************************************************** |
|
|
51 |
samples=unique(scmat2[["batch"]][,1]) |
|
|
52 |
|
|
|
53 |
# cellPhoneDB analysis (TableS3 tab for the results): |
|
|
54 |
run=lapply(samples, function(s){ |
|
|
55 |
results=run.cellphonedb(scmat2[,scmat2[["batch"]][,1]%in%s], celltype = NULL, out=file.path(getwd(),"cellphonedb", paste0(s, "_FIMM_AML_0.1")), threshold = 0.1, cores = 6) |
|
|
56 |
}) |
|
|
57 |
|
|
|
58 |
#****************************************************************************************************************************************************************************************************** |
|
|
59 |
|
|
|
60 |
|
|
|
61 |
#************************************************** run DE analysis for each cluster and above defined NK-CD8 cells ************************************************** |
|
|
62 |
|
|
|
63 |
library(future) |
|
|
64 |
plan("multiprocess", workers = 8) |
|
|
65 |
|
|
|
66 |
# only do the analysis on most abundant clusters |
|
|
67 |
scmat[["MDSlike"]]=ifelse(scmat[["batch"]][,1]%in%c("5897", "3667", "5249"), "MDS-like", "other") |
|
|
68 |
|
|
|
69 |
addname=c(paste("MDS-like", levels(Idents(scmat))), paste("other", levels(Idents(scmat)))) |
|
|
70 |
|
|
|
71 |
Idents(scmat)=factor(paste(scmat[["MDSlike"]][,1], Idents(scmat)), levels=addname[addname%in%paste(scmat[["MDSlike"]][,1], Idents(scmat))]) |
|
|
72 |
|
|
|
73 |
markers.all.up=FindAllMarkers(scmat, features = rownames(scmat),only.pos = T, logfc.threshold = 0.1, min.cells.group = 300) |
|
|
74 |
|
|
|
75 |
markers.all.filt=markers.all.up[markers.all.up$p_val_adj<1e-10,] |
|
|
76 |
markers.all.filt=markers.all.filt[markers.all.filt$avg_logFC>0.25,] |
|
|
77 |
write.table(markers.all.filt[,c(7,6,2,3,4,1,5)], "TableS3_Significant_genes_MDSlike_scRNA_all.txt", quote = F, row.names = F, col.names = T, sep="\t") |
|
|
78 |
save(markers.all.filt, file="markers.all.filt.allgenes.Rdata") |
|
|
79 |
|
|
|
80 |
#****************************************************************************************************************************************************************************************************** |
|
|
81 |
|
|
|
82 |
# pathway analysis |
|
|
83 |
load("Combined_pathway_signatures_2017_filtered_robust.Rdata") |
|
|
84 |
genesets=listA[grepl("HALLMARKS|REACTOME|BIOCARTA|PID|KEGG|WIKIPW", names(listA))] |
|
|
85 |
|
|
|
86 |
group=unique(markers.all.filt$cluster) |
|
|
87 |
|
|
|
88 |
res.pw.up=mclapply(group, function(g){ |
|
|
89 |
up=markers.all.filt$gene[markers.all.filt$cluster%in%g] |
|
|
90 |
|
|
|
91 |
if(!length(up))return(NULL) |
|
|
92 |
|
|
|
93 |
pw.up=do.call(rbind, mclapply(seq(genesets), function(i){ |
|
|
94 |
if(sum(genesets[[i]]%in%rownames(scmat))==0)return(NULL) |
|
|
95 |
r=fisher.2x2(lv1 = rownames(scmat)%in%genesets[[i]], lv2 = rownames(scmat)%in%up, alternative = "greater", usefast = F) |
|
|
96 |
data.frame("Name"=names(genesets)[i], r, "genes.signif"=paste(up[up%in%genesets[[i]]], collapse=","), stringsAsFactors = F) |
|
|
97 |
}, mc.cores=1)) |
|
|
98 |
|
|
|
99 |
pw.up$cluster=g |
|
|
100 |
pw.up$FDR=p.adjust(pw.up$p, "BH") |
|
|
101 |
pw.up=pw.up[order(pw.up$FDR, decreasing = F),] |
|
|
102 |
|
|
|
103 |
pw.up=pw.up[pw.up$FDR<0.05,] |
|
|
104 |
|
|
|
105 |
if(dim(pw.up)[1]==0)return(NULL) |
|
|
106 |
|
|
|
107 |
return(pw.up) |
|
|
108 |
}, mc.cores=8) |
|
|
109 |
|
|
|
110 |
res.pw.all=do.call(rbind, res.pw.up) |
|
|
111 |
|
|
|
112 |
write.table(res.pw.all[,c(1,5,3,2,6,4)], "TableS3_MDSlike_DE_pathways_up.txt", quote = F, row.names = F, sep="\t") |