-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tumor_purity.R
97 lines (67 loc) · 2.24 KB
/
Tumor_purity.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
library(utils)
rforge <- "http://r-forge.r-project.org"
install.packages("estimate", repos=rforge, dependencies=TRUE)
library(estimate)
filterCommonGenes1 <- function (input.f, output.f, id = c("GeneSymbol", "EntrezID"))
{
id <- match.arg(id)
input.df <- input.f
merged.df <- merge(common_genes, input.df, by.x = id, by.y = "row.names")
rownames(merged.df) <- merged.df$GeneSymbol
merged.df <- merged.df[, -1:-ncol(common_genes)]
print(sprintf("Merged dataset includes %d genes (%d mismatched).",
nrow(merged.df), nrow(common_genes) - nrow(merged.df)))
outputGCT(merged.df, output.f)
}
www <- list(ACC_unique,
BLCA_unique,
BRCA_unique,
CESC_unique,
CHOL_unique,
COAD_unique,
DLBC_unique,
ESCA_unique,
GBM_unique,
HNSC_unique,
KICH_unique,
KIRC_unique,
KIRP_unique,
LAML_unique,
LGG_unique,
LIHC_unique,
LUAD_unique,
LUSC_unique,
MESO_unique,
OV_unique,
PAAD_unique,
PCPG_unique,
PRAD_unique,
READ_unique,
SARC_unique,
SKCM_unique,
STAD_unique,
TGCT_unique,
THCA_unique,
THYM_unique,
UCEC_unique,
UCS_unique,
UVM_unique)
saveRDS(www,'alltumor.RData')
www <- readRDS('alltumor.RData')
purity_tumor <- list()
for (i in 1:33) {
print(paste('trying for',i))
filterCommonGenes1(input.f=www[[i]], output.f=paste0("unique_tumor_purity",i,".gct"), id="GeneSymbol")
estimateScore(paste0("unique_tumor_purity",i,".gct"),output.ds = paste0("unique_tumor_purity",i,".csv"),
platform = 'illumina')
aa <- read.csv(paste0("unique_tumor_purity",i,".csv"),sep = '\t',skip = 1)
aa <- as.data.frame(t(aa))
colnames(aa) <- aa[1,]
aa <- aa[c(-1,-2),]
aa$ESTIMATEScore <- as.numeric(aa$ESTIMATEScore)
aa$purity <- cos(0.6049872018 + 0.0001467884*aa$ESTIMATEScore)
aa$NAME <- str_replace_all(aa$NAME,"[.]","-")
row.names(aa) <- aa$NAME
purity_tumor[[i]] <- aa
}
saveRDS(purity_tumor,'tumor_purity.RData')