-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalid_data_combine.R
145 lines (107 loc) · 5.36 KB
/
valid_data_combine.R
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
source("metaAnalyze.R")
source("analysis_addon.R")
library("readxl")
bestGenes = read.csv("./Data_out/bestGEnes_DAS_corr.csv", stringsAsFactors = F)[,1]
sampleMeta = read.csv("./Metadata/sampleMeta.csv", stringsAsFactors = F, row.names = 1)
anno = read_excel("./Metadata/GSM_anno.xlsx", sheet = 1) %>% as.data.frame()
# gpl = getGEO("GPL91")
#
# bestGenes[!bestGenes %in% gpl@dataTable@table$`Gene Symbol`]
# humanSyno(genes = c("DRAM1" , "SAMSN1", "SQOR" )) %>% unlist() %in% gpl@dataTable@table$`Gene Symbol`
## Synovium GSE1919 -------------------------------------------------------------------------------
# Microarray
emat = readRDS("./Data_in/GEO/GSE1919.rds")
emat = exprs(emat)
colnames(emat) = fixGeoSampleNames(colnames(emat))
rownames(emat) = fixCustomCdfGeneIds(rownames(emat))
emat = geneId2Symbol(emat)
bestGenes[!bestGenes %in% rownames(emat)] # "DRAM1" "SAMSN1" "SQOR" missing
emat.GSE1919 = emat
meta.GSE1919 = anno[anno$study == 'GSE1919',]
rownames(meta.GSE1919) = meta.GSE1919$sample
all((rownames(meta.GSE1919) == colnames(emat.GSE1919)))
# gpl = getGEO("GPL91")
#
# bestGenes[!bestGenes %in% gpl@dataTable@table$`Gene Symbol`]
# humanSyno(genes = c("DRAM1" , "SAMSN1", "SQOR" )) %>% unlist() %in% gpl@dataTable@table$`Gene Symbol`
# Synovium GSE3698???? ---------------------------------------------------------------------------
# Microarray
# gpl = getGEO("GPL3050")
# bestGenes[!bestGenes %in% gpl@dataTable@table$GENE_SYMBOL]
# humanSyno(genes = bestGenes[!bestGenes %in% gpl@dataTable@table$GENE_SYMBOL]) %>% unlist() %in% gpl@dataTable@table$GENE_SYMBOL
## Synovium GSE89408 ----------------------------------------------------------------------------
# RNA-seq
load("./Data_out/validSyno.RData")
emat.GSE89408 = validSyno
meta.GSE89408 = sampleSynoValid
all(rownames(meta.GSE89408) == colnames(emat.GSE89408))
# ## Synovial fibroblasts. GSE29746 ----------
# # Microarray
# load(file = "./Data_in/GSE29746.Rdata")
#
# emat.GSE29746 = exprsByGene
# meta.GSE29746 = meta
# Whole Blood. GSE17755 ------------------------------------------------------------------------
# Microarray
eset = readRDS("./Data_in/GEO/GSE17755.rds")
emat.GSE17755 = exprs(eset)
emat.GSE17755 = geneId2Symbol(emat.GSE17755)
meta.GSE17755 = read.csv("./Data_in/GSE17755_meta.csv", stringsAsFactors = F, row.names = 1)
all(rownames(meta.GSE17755) == colnames(emat.GSE17755))
s = intersect(rownames(meta.GSE17755), colnames(emat.GSE17755))
meta.GSE17755 = meta.GSE17755[s,]
emat.GSE17755 = emat.GSE17755[,s]
# PBMC. GSE15573 --------------------------------------------------------------------------------
# Microarray
load(file = "./Data_in/GSE15573.Rdata")
emat.GSE15573 = geneId2Symbol(exprsByGene)
meta.GSE15573 = meta
all((rownames(meta.GSE15573) == colnames(emat.GSE15573)))
# PBMC. GSE90081 --------------------------------------------------------------------------------
# RNA-seq
load("Data_out/validPBMC.RData")
emat.GSE90081 = validPBMC
meta.GSE90081 = samplePBMCValid
all(rownames(meta.GSE90081) == colnames(emat.GSE90081))
# # White Blood Cells. GSE117769 ------------------------------------------------------------------
# # RNAseq
# load("./Data_out/GSE117769.RData")
# emat.GSE117769 = emat
# meta.GSE117769 = meta117769
emat.validList = list(GSE89408 = emat.GSE89408,
GSE1919 = emat.GSE1919,
GSE90081 = emat.GSE90081,
GSE17755 = emat.GSE17755,
GSE15573 = emat.GSE15573)
meta.validList = list(GSE89408 = meta.GSE89408,
GSE1919 = meta.GSE1919,
GSE90081 = meta.GSE90081,
GSE17755 = meta.GSE17755,
GSE15573 = meta.GSE15573)
# Check correct gene symbols
lapply(names(emat.validList), function(x) findGenes(iterGenes, emat.validList[[x]]))
q = findGenes(iterGenes, emat.validList[[1]])
rownames(emat.validList[[1]])[match(q[names(q) != ""], rownames(emat.validList[[1]]))] = names(q[names(q) != ""])
q = findGenes(iterGenes, emat.validList[[3]])
rownames(emat.validList[[3]])[match(q[names(q) != ""], rownames(emat.validList[[3]]))] = names(q[names(q) != ""])
# save(emat.validList, meta.validList, file = "./Data_out/validation_datasets_list.RData")
# load(file = "./Data_out/validation_datasets_list.RData")
plotHeatmap(emat.validList[[4]][rownames(emat.validList[[4]]) %in% bestGenes,], meta.validList[[4]][meta.validList[[4]]$class %in% c("RA", "Healthy"), ], rowNames = T)
############## xCell Analysis ----------------------------------------------------------
library("xCell")
cellList = read.csv("./Data_in/cells_families.csv", stringsAsFactors = F)
cells = cellList[cellList$Type != "Epithelial", "Cells"]
cells = cells[!cells %in% c("Skeletal muscle", "Smooth muscle", "Myocytes", "Mesangial cells")]
rnaseq = c(TRUE, FALSE, TRUE, FALSE, FALSE)#, TRUE, FALSE)
names(rnaseq) = names(emat.validList)
# cellList = read.csv("./Data_in/cells_families.csv", stringsAsFactors = F)
xcell.validList = list()
for (name in names(emat.validList)) {
message("Evaluating ", name, " for cell type scores...\n")
q = xCell::xCellAnalysis(emat.validList[[name]], rnaseq = FALSE, parallel.sz = 3, parallel.type = "FORK")
message("Computing ", name, " p-values...\n")
p = xCellSignifcanceBetaDist(q)
colnames(p) = colnames(q)
xcell.validList[[name]] = list(xcell = q, pval = p)
}
# save(xcell.validList, file = "./Data_out/xcell.validList.RData")