-
Notifications
You must be signed in to change notification settings - Fork 20
/
immune_infiltration.R
executable file
·75 lines (61 loc) · 3.06 KB
/
immune_infiltration.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
#############################Script to process immune infiltration #####################
suppressMessages(library(rlang))
suppressMessages(library(R.utils))
suppressMessages(library(dplyr))
suppressMessages(library(immunedeconv))
suppressMessages(library(optparse))
# make option list and parse command line
library(optparse)
option_list <- list(
make_option(c("-e", "--expression_dat"), type="character",
help="Input path of expression file. [Required]"),
make_option(c("-o", "--output_dat"), type="character",
help="Ouput path of corresponding tables. [Required]"),
make_option(c("-p", "--permutation"), type="numeric", default=NULL,
help="permutation for cibersort", metavar="character"),
make_option(c("-q", "--quantile_normalization"), type="character", default=NULL,
help="whether enable quantile normalization for cibersort", metavar="character"),
make_option(c("-a", "--absolute"), type="character", default=NULL,
help="absolute mode for cibersort", metavar="character"),
make_option(c("-m", "--abs_method"), type="character", default=NULL,
help="absolute method for cibersort", metavar="character"),
make_option(c("-t", "--cancer_type"), type="character",
help="cancer type used in timer. [Required]")
)
opt_parser <- OptionParser(option_list=option_list,add_help_option = FALSE);
opts <- parse_args(opt_parser);
# paramenter checking
if(is.null(opts$expression_dat)) stop('Expression file required.')
input <- opts$expression_dat
output <- opts$output_dat
cancertype <- opts$cancer_type
cibersort_perm <- opts$permutation
cibersort_qn <- opts$quantile_normalization
cibersort_abs <- opts$absolute
cibersort_abs_method <- opts$abs_method
###read in data
df <- read.table(input, sep = ",", row.names = 1,header = TRUE, check.names = FALSE)
df <- 2^df -1
print(head(df))
#quantiseq
res_quant = as.data.frame(deconvolute(df, "quantiseq"))
write.table(res_quant,paste0(output,'quantiseq.txt'),sep='\t',row.names=FALSE, quote = FALSE)
print("run quantiseq")
#xcell
res_xcell = as.data.frame(deconvolute(df, "xcell"))
write.table(res_xcell,paste0(output,'xcell.txt'),sep='\t',row.names=FALSE, quote = FALSE)
print("run xcell")
#epic
res_epic = as.data.frame(deconvolute(df, "epic"))
write.table(res_epic,paste0(output,'epic.txt'),sep='\t',row.names=FALSE, quote = FALSE)
print("run epic")
#mcp_counter
res_mcp = as.data.frame(deconvolute(df, "mcp_counter"))
write.table(res_mcp,paste0(output,'mcp_counter.txt'),sep='\t',row.names=FALSE, quote = FALSE)
print('run mcp_counter')
source('src/immune_infiltration/CIBERSORT.R')
res_ciber <- CIBERSORT("static/cibersort/LM22.txt",input,perm = cibersort_perm, QN = cibersort_qn, absolute = cibersort_abs, abs_method = cibersort_abs_method)
write.table(res_ciber, file = paste0(output,'cibersort_abs.txt'), sep="\t", quote = FALSE)
print("run cibersort absolution mode")
res_timer = as.data.frame(deconvolute(df, "timer",indications=rep(tolower(cancertype),ncol(df))))
write.table(res_timer,paste0(output,'timer.txt'),sep='\t', row.names=FALSE, quote = FALSE)