forked from hongpeijian/PCa_ceRNA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path101-expression_data_clean.R
172 lines (109 loc) · 5.4 KB
/
101-expression_data_clean.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
############
#### 从TCGA直接下载下载表达数据
query <- GDCquery(project = "TCGA-PRAD",
data.category = "Transcriptome Profiling",
data.type = "Gene Expression Quantification",
workflow.type = "HTSeq - Counts"
)
GDCdownload(query)
data <- GDCprepare(query,
save = TRUE,
save.filename = "HTSeq_coutn_exp.rds",
summarizedExperiment = TRUE)
load("HTSeq_coutn_exp.rds")
lihc_ranexp2 <- assay(data)
clinical2 <- colData(data) %>%
as.data.frame() %>%
dplyr::select(sample, patient, barcode, shortLetterCode)
save(lihc_ranexp2, clinical2, file = "PRAD_RNA_and_clinical.RData")
load("PRAD_RNA_and_clinical.RData")
########## 下载miRNA数据
library(GDCRNATools)
gdcRNADownload(project.id = 'TCGA-PRAD',
data.type = 'miRNAs',
write.manifest = FALSE,
directory = 'data/',
method = "gdc-client")
metaMatrix.MIR <- gdcParseMetadata(project.id = 'TCGA-PRAD',
data.type = 'miRNAs',
write.meta = FALSE)
metaMatrix.MIR <- gdcFilterDuplicate(metaMatrix.MIR)
mirMatrix <- gdcRNAMerge(metadata = metaMatrix.MIR,
path = 'data',
data.type = 'miRNAs',
organized = F)
mirExpr <- gdcVoomNormalization(counts = mirMatrix, filter = FALSE)
save(mirMatrix, mirExpr, file = "rawdata/mirexpr.RData")
############################### GEO 数据
####### GEO 数据预处理 GSE104131
library(GEOquery)
library(viper)
library(annotables)
data("grch37")
annotiondata <- dplyr::select(grch37, ensgene, symbol)
fpkm1 <- read_tsv("rawdata/mRNA/GSE104131/GSE104131_batch1.cufflinks.fpkms_tracking.TableFormatted.txt/GSE104131_batch1.cufflinks.fpkms_tracking.TableFormatted.txt")
fpkm2 <- read_tsv("rawdata/mRNA/GSE104131/GSE104131_batch2.cufflinks.fpkms_tracking.TableFormatted.txt/GSE104131_batch2.cufflinks.fpkms_tracking.TableFormatted.txt")
genenames <- fpkm1$GID
fpkm1 <- dplyr::select(fpkm1, -GENESYMBOL, -Locus) %>%
group_by(GID) %>%
summarise_all(mean)
rownames(fpkm1) <- fpkm1$GID
fpkm1 <- dplyr::select(fpkm1, -GID)
names(fpkm1) <- str_c("Sample_", names(fpkm1), sep = "")
gse1 <- getGEO(filename="rawdata/mRNA/GSE104131/GSE104131_series_matrix.txt.gz", getGPL = F)
temp <- gse1@phenoData@data %>%
dplyr::select(title, geo_accession, characteristics_ch1) %>%
data.frame(stringsAsFactors = F)
temp$title <- as.character(temp$title)
temp$title[11] <- "Sample_881_B19"
temp$title[12] <- "Sample_881_B26"
intersect(temp$title, names(fpkm1))
sampleldescript <- mutate(temp,
type = ifelse(grepl("normal",characteristics_ch1), "Normal", "Tumor")) %>%
dplyr::select(title, type)
save(fpkm1,sampleldescript, file = "rawdata/mRNA_GSE104131_clinin.RData")
load("rawdata/mRNA_GSE104131_clinin.RData")
####### GEO 数据预处理GSE89223
filenames <- list.files("rawdata/mRNA/GSE89223/GSE89223_RAW (2)/")
allpaths <- paste("rawdata/mRNA/GSE89223/GSE89223_RAW (2)/", filenames, sep = "")
explist <- list()
for (i in 1:length(filenames )) {
explist[[i]] <- read_tsv(allpaths[i], col_names = F)
}
neexplist <- lapply(explist, function(x){x[2]})
exprdata <- as.matrix(bind_cols(neexplist))
colnames(exprdata) <- str_remove(filenames, "_.*")
rownames(exprdata) <- explist[[1]]$X1
gsepath <- paste("rawdata/mRNA/GSE89223/GSE89223_series_matrix.txt.gz")
gse1 <- getGEO(filename = gsepath, getGPL = F)
temp <- gse1@phenoData@data %>%
dplyr::select(geo_accession, characteristics_ch1.1) %>%
data.frame(stringsAsFactors = F)
sampleldescript <- mutate(temp,
type = ifelse(grepl("normal",characteristics_ch1.1), "Normal", "Tumor")) %>%
dplyr::select(title = geo_accession, type)
save(exprdata, sampleldescript, file = "rawdata/mRNA_GSE89223_clinin.RData")
load("rawdata/mRNA_GSE89223_clinin.RData")
####### GEO 数据miRNA处理GSE21036
gsepath <- paste("rawdata/miRNA/GSE21036/GSE21036_series_matrix.txt.gz")
#gplpath <- paste("rawdata/miRNA/GSE21036/")
gse1 <- getGEO(filename = gsepath, getGPL = F)
#gpldata1 <- getGEO(filename=gplpath, getGPL = F)
exprdata <-gse1@assayData[["exprs"]] %>%
as.data.frame() %>%
dplyr::select(-GSM526532)
sampleldescript <- gse1@phenoData@data %>%
filter(geo_accession %in% names(exprdata)) %>%
mutate( type = ifelse(grepl("normal",title), "Normal", "Tumor")) %>%
dplyr::select(title = geo_accession, type)
save(exprdata, sampleldescript, file = "rawdata/miRNA_GSE21036_cline.RData")
####### GEO 数据miRNA处理GSE76260
gsepath <- paste("rawdata/miRNA/GSE76260/GSE76260_series_matrix.txt.gz")
gplpath <- read_tsv("rawdata/miRNA/GSE76260/GPL8179_humanMI_V2_R0_XS0000124-MAP.txt/GPL8179_humanMI_V2_R0_XS0000124-MAP.txt")
gse1 <- getGEO(filename = gsepath, getGPL = F)
exprdata <-gse1@assayData[["exprs"]]
sampleldescript <- gse1@phenoData@data %>%
mutate( type = ifelse(grepl("normal",title), "Normal", "Tumor")) %>%
dplyr::select(title = geo_accession, type)
save(exprdata, sampleldescript, file = "rawdata/miRNA_GSE76260_clinic.RData")
load("rawdata/geo_lich_featureANDexp.RData")