-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMethylation_SCC_vs_Adeno_2_edit_data_2.R
49 lines (31 loc) · 1.62 KB
/
Methylation_SCC_vs_Adeno_2_edit_data_2.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
setwd("Z:/Leng/Phil/Methylation_SCC_vs_Adeno_2/output")
filenames <- c("Methylation450K_TCGA_SCCvsAdeno_2_Adeno_2.csv","Methylation450K_TCGA_SCCvsAdeno_2_SCC_2.csv")
histnames <- c("Z:/Leng/Phil/Methylation_SCC_vs_Adeno_2/data/clinical_sample_all_LUAD_1.csv","Z:/Leng/Phil/Methylation_SCC_vs_Adeno_2/data/clinical_sample_all_LUSC_1.csv")
#read in data
data1 <- read.csv(filenames[1],sep=",",header=TRUE)
#read in histology
hist1 <- read.csv(histnames[1],sep=",",header=TRUE)
names(hist1) <- c("sample.name","sample.type")
data.and.hist1 <- merge(hist1,data1)
#read in data
data2 <- read.csv(filenames[2],sep=",",header=TRUE)
#read in histology
hist2 <- read.csv(histnames[2],sep=",",header=TRUE)
names(hist2) <- c("sample.name","sample.type")
#There were 9 files lost here due to some patients having multiple samples
data.and.hist2 <- merge(hist2,data2)
x1 <- sort(names(data.and.hist1), decreasing=TRUE, index.return=TRUE)
permute1 <- x1$ix
data.and.hist1.ordered <- data.and.hist1[,permute1]
x2 <- sort(names(data.and.hist2), decreasing=TRUE, index.return=TRUE)
permute2 <- x2$ix
data.and.hist2.ordered <- data.and.hist2[,permute2]
#check if names match
names(data.and.hist1.ordered) == names(data.and.hist2.ordered)
# => TRUE
#merge Adeno with SCC
merged.data <- rbind(data.and.hist1.ordered, data.and.hist2.ordered)
#create vector designating adeno or SCC
Adeno.or.SCC <- c(rep("Adeno",254), rep("SCC",191))
total.data <- cbind(Adeno.or.SCC, merged.data)
write.csv(total.data,"Z:/Leng/Phil/Methylation_SCC_vs_Adeno_2/output/Methylation450K_TCGA_SCCvsAdeno_2_total.csv", row.names=FALSE)