markers_BM.R 8.68 KB
Newer Older
Ivan Merelli's avatar
Ivan Merelli committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
library(Seurat)
library(dplyr)

BM.combo <- readRDS("/DATA/31/molteni/vexas_bm/results/integration/pc15/BM.combo_anno.rds")

BM.combo@meta.data$mutations <- with(BM.combo@meta.data,
                                     ifelse(BM.combo@meta.data$orig.ident == "BM-01","THR",
                                            ifelse(BM.combo@meta.data$orig.ident == "BM-02","VAL",
                                                   ifelse(BM.combo@meta.data$orig.ident == "BM-03","VAL", 
                                                          ifelse(BM.combo@meta.data$orig.ident == "BM-04","LEU",
                                                                 ifelse(BM.combo@meta.data$orig.ident == "BM-08","VAL",
                                                                        ifelse(BM.combo@meta.data$orig.ident == "BM-09","LEU",
                                                                               ifelse(BM.combo@meta.data$orig.ident == "PT1","VAL",
                                                                                      ifelse(BM.combo@meta.data$orig.ident == "PT2","THR",
                                                                                             ifelse(BM.combo@meta.data$orig.ident == "PT3","THR",
                                                                                                    ifelse(BM.combo@meta.data$orig.ident == "PT4","THR",
                                                                                                           ifelse(BM.combo@meta.data$orig.ident == "PT5","THR",
                                                                                                                  ifelse(BM.combo@meta.data$orig.ident == "PT6","LEU",
                                                                                                                         ifelse(BM.combo@meta.data$orig.ident == "PT7","LEU",
                                                                                                                                ifelse(BM.combo@meta.data$orig.ident == "PT8","THR",
                                                                                                                                       ifelse(BM.combo@meta.data$orig.ident == "PT9","THR",
                                                                                                                                                     ifelse(BM.combo@meta.data$orig.ident == "HD1","CTRL",
                                                                                                                                                            ifelse(BM.combo@meta.data$orig.ident == "HD2","CTRL",
                                                                                                                                                                   ifelse(BM.combo@meta.data$orig.ident == "HD3","CTRL",
                                                                                                                                                                          ifelse(BM.combo@meta.data$orig.ident == "HD4","CTRL","NA"))))))))))))))))))))
#"BM-01","BM-02","BM-03","BM-04", "BM-08","BM-09",

#COMPARISON THR VEXAS PATIENTS vs HEALTHY CONTROLS WU

#select only the subjects involved in the comparison by mutations
Idents(BM.combo) <- "orig.ident"
BM.combo_subset <- subset(BM.combo, idents = c("BM-01","HD1", "HD2", "HD3", "HD4"))
clusters <- unique(BM.combo_subset$celltypes_annot)
Idents(BM.combo_subset) <- "celltypes_annot"

setwd("/DATA/31/molteni/vexas_bm/results/integration/DE_markers_OSR_Wu/Thr_CTRL/")

for(i in clusters) {
  cells_group1 = sum(BM.combo_subset$mutations == "THR" & BM.combo_subset$celltypes_annot == i)
  cells_group2 = sum(BM.combo_subset$mutations == "CTRL" & BM.combo_subset$celltypes_annot == i)
  if(cells_group1 >= 3 & cells_group2 >= 3 ) {
    markers <- FindMarkers(BM.combo_subset, ident.1 = "THR", group.by = "mutations", subset.ident = i)
    markers['cluster'] <- i
    filename=paste("markers_cluster_",i,".csv", sep="")
    write.csv(markers, file=filename)
  }
  else {
    print(paste("Skipping comparison for", i, "due to insufficient cell count in one or both groups."))
  }
}

setwd("/DATA/31/molteni/vexas_bm/results/integration/DE_markers/Thr_CTRL")

df <- list.files(path="/DATA/31/molteni/vexas_bm/results/integration/DE_markers/Thr_CTRL") %>% 
  lapply(read.csv) %>% 
  bind_rows

df <- df[df$p_val_adj<0.05,]
setwd("/DATA/31/molteni/vexas_bm/results/integration/DE_markers_OSR_Wu/summary")
write.csv(df, file="THRvsCTRL_sigMarkers.csv")

#COMPARISON VAL VEXAS PATIENTS vs HEALTHY CONTROLS WU

#select only the subjects involved in the comparison
Idents(BM.combo) <- "orig.ident"
BM.combo_subset <- subset(BM.combo, idents = c("BM-02","BM-03","BM-08","HD1", "HD2", "HD3", "HD4"))
clusters <- unique(BM.combo_subset$celltypes_annot)
Idents(BM.combo_subset) <- "celltypes_annot"
setwd("/DATA/31/molteni/vexas_bm/results/integration/DE_markers_OSR_Wu/Val_CTRL/")

for(i in clusters) {
  cells_group1 = sum(BM.combo_subset$mutations == "VAL" & BM.combo_subset$celltypes_annot == i)
  cells_group2 = sum(BM.combo_subset$mutations == "CTRL" & BM.combo_subset$celltypes_annot == i)
  if(cells_group1 >= 3 & cells_group2 >= 3 ) {
    markers <- FindMarkers(BM.combo_subset, ident.1 = "VAL", group.by = "mutations", subset.ident = i)
    markers['cluster'] <- i
    filename=paste("markers_cluster_",i,".csv", sep="")
    write.csv(markers, file=filename)
  }
  else {
    print(paste("Skipping comparison for", i, "due to insufficient cell count in one or both groups."))
  }
}

setwd("/DATA/31/molteni/vexas_bm/results/integration/DE_markers_OSR_Wu/Val_CTRL")

df <- list.files(path="/DATA/31/molteni/vexas_bm/results/integration/DE_markers_OSR_Wu/Val_CTRL") %>% 
  lapply(read.csv) %>% 
  bind_rows

df <- df[df$p_val_adj<0.05,]
setwd("/DATA/31/molteni/vexas_bm/results/integration/DE_markers_OSR_Wu/summary")
write.csv(df, file="VALvsCTRL_sigMarkers.csv")

#COMPARISON LEU VEXAS PATIENTS vs HEALTHY CONTROLS WU

#select only the subjects involved in the comparison
Idents(BM.combo) <- "orig.ident"
BM.combo_subset <- subset(BM.combo, idents = c("BM-04", "BM-09","HD1", "HD2", "HD3", "HD4"))
clusters <- unique(BM.combo_subset$celltypes_annot)
Idents(BM.combo_subset) <- "celltypes_annot"

setwd("/DATA/31/molteni/vexas_bm/results/integration/DE_markers_OSR_Wu/Leu_CTRL/")

for(i in clusters) {
  cells_group1 = sum(BM.combo_subset$mutations == "LEU" & BM.combo_subset$celltypes_annot == i)
  cells_group2 = sum(BM.combo_subset$mutations == "CTRL" & BM.combo_subset$celltypes_annot == i)
  if(cells_group1 >= 3 & cells_group2 >= 3 ) {
    markers <- FindMarkers(BM.combo_subset, ident.1 = "LEU", group.by = "mutations", subset.ident = i)
    markers['cluster'] <- i
    filename=paste("markers_cluster_",i,".csv", sep="")
    write.csv(markers, file=filename)
  }
  else {
    print(paste("Skipping comparison for", i, "due to insufficient cell count in one or both groups."))
  }
}

setwd("/DATA/31/molteni/vexas_bm/results/integration/DE_markers_OSR_Wu/Leu_CTRL")


df <- list.files(path="/DATA/31/molteni/vexas_bm/results/integration/DE_markers_OSR_Wu/Leu_CTRL") %>% 
  lapply(read.csv) %>% 
  bind_rows

df <- df[df$p_val_adj<0.05,]
setwd("/DATA/31/molteni/vexas_bm/results/integration/DE_markers_OSR_Wu/summary")
write.csv(df, file="LEUvsCTRL_sigMarkers.csv")


#COMPARISON VEXAS PATIENTS vs HEALTHY CONTROLS WU

#select only the subjects involved in the comparison
Idents(BM.combo) <- "orig.ident"
BM.combo_subset <- subset(BM.combo, idents = c("BM-01", "BM-02", "BM-03", "BM-04", "BM-08","BM-09","HD1", "HD2", "HD3", "HD4"))
                          
clusters <- unique(BM.combo_subset$celltypes_annot)
Idents(BM.combo_subset) <- "celltypes_annot"
setwd("/DATA/31/molteni/vexas_bm/results/integration/DE_markers_OSR_Wu/Pz_CTRL/")

for(i in clusters) {
  cells_group1 = sum(BM.combo_subset$condition == "PZ" & BM.combo_subset$celltypes_annot == i)
  cells_group2 = sum(BM.combo_subset$condition == "HD" & BM.combo_subset$celltypes_annot == i)
  if(cells_group1 >= 3 & cells_group2 >= 3 ) {
    markers <- FindMarkers(BM.combo_subset, ident.1 = "PZ", group.by = "condition", subset.ident = i)
    markers['cluster'] <- i
    filename=paste("markers_cluster_",i,".csv", sep="")
    write.csv(markers, file=filename)
  }
  else {
    print(paste("Skipping comparison for", i, "due to insufficient cell count in one or both groups."))
  }
}

setwd("/DATA/31/molteni/vexas_bm/results/integration/DE_markers_OSR_Wu/Pz_CTRL")
df <- list.files(path="/DATA/31/molteni/vexas_bm/results/integration/DE_markers_OSR_Wu/Pz_CTRL") %>% 
  lapply(read.csv) %>% 
  bind_rows

df <- df[df$p_val_adj<0.05,]

setwd("/DATA/31/molteni/vexas_bm/results/integration/DE_markers_OSR_Wu/summary")

write.csv(df, file="PZvsCTRL_sigMarkers.csv")