-
Notifications
You must be signed in to change notification settings - Fork 1
/
helper_functions.shiny.R
149 lines (132 loc) · 5.24 KB
/
helper_functions.shiny.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
read_maf <- function(session,maf_file_path) {
maf_progress <- shiny::Progress$new(session,max=100)
maf_progress$set(value = 0, message = "Reading MAF file...")
print(maf_file_path)
maf <- read.maf(maf_file_path)
maf_progress$set(value = 100, message = "Upload complete.")
maf_progress$close()
return(maf)
}
withConsoleRedirect <- function(containerId, expr) {
# Change type="output" to type="message" to catch stderr
# (messages, warnings, and errors) instead of stdout.
txt <- capture.output(results <- expr, type = "message")
if (length(txt) > 0) {
insertUI(paste0("#", containerId), where = "beforeEnd",
ui = paste0(txt, "\n", collapse = "")
)
}
results
}
make_gene_ribbon_plot <- function(session, input, plot_values) {
mycoloropt <- NULL
if (input$gene_comut_customribboncolor) {
mycoloropt <- input$gene_comut_ribbon_color
}
plotopts <- list(maf_obj=plot_values$maf_obj,
ribbon_color=mycoloropt,
topN=isolate(input$gene_comut_topN),
pval_low=isolate(input$gene_comut_pvalLow),
pval_high=isolate(input$gene_comut_pvalHigh),
plot_file=isolate(plot_values$gene_interaction_pdf),
plot_frac_mut_axis=TRUE,
scale_ribbon_to_fracmut=TRUE)
ribbon_progress <- shiny::Progress$new(session,max=100)
ribbon_progress$set(value = 5, message = "Making co-mutated gene ribbon plot...")
updateProgress <- function(value = NULL, detail = NULL) {
if (is.null(value)) {
value <- ribbon_progress$getValue()
value <- value + (ribbon_progress$getMax() - value) / 5
}
ribbon_progress$set(value = value, message = detail)
}
make_single_ribbon_plot(plotopts$maf_obj,
ribbon_color=plotopts$ribbon_color,
topN=plotopts$topN,
pval_low=plotopts$pval_low,
pval_high=plotopts$pval_high,
plot_file=plotopts$plot_file,
progress_func=plotopts$progress_func,
plot_frac_mut_axis=plotopts$plot_frac_mut_axis,
scale_ribbon_to_fracmut=plotopts$scale_ribbon_to_fracmut)
ribbon_progress$set(value = 100, message = "Returning plot...")
ribbon_progress$close()
}
callback <- c(
"$.contextMenu({",
" selector: '#maf_clin_dat_table th',",
" trigger: 'right',",
" autoHide: true,",
" zindex: 999999,",
" items: {",
" text: {",
" name: 'Enter column header:',",
" type: 'text',",
" value: ''",
" }",
" },",
" events: {",
" show: function(opts){",
" $.contextMenu.setInputValues(opts, {text: opts.$trigger.text()});",
" },",
" hide: function(opts){",
" var $this = this;",
" var data = $.contextMenu.getInputValues(opts, $this.data());",
" var $th = opts.$trigger;",
" $th.text(data.text);",
" }",
" }",
"});"
)
shinyInput <- function(FUN, len, id, ...) {
inputs <- character(len)
for (i in seq_len(len)) {
inputs[i] <- as.character(FUN(paste0(id, i), ...))
}
inputs
}
TCGA_project_choices=sort(c(
"[TCGA-LAML] Acute Myeloid Leukemia"="TCGA-LAML",
"[TCGA-ACC] Adrenocortical carcinoma"="TCGA-ACC",
"[TCGA-BLCA] Bladder Urothelial Carcinoma"="TCGA-BLCA",
"[TCGA-LGG] Brain Lower Grade Glioma"="TCGA-LGG",
"[TCGA-BRCA] Breast invasive carcinoma"="TCGA-BRCA",
"[TCGA-CESC] Cervical squamous cell carcinoma and endocervical adenocarcinoma"="TCGA-CESC",
"[TCGA-CHOL] Cholangiocarcinoma"="TCGA-CHOL",
"[TCGA-LCML] Chronic Myelogenous Leukemia"="TCGA-LCML",
"[TCGA-COAD] Colon adenocarcinoma"="TCGA-COAD",
# "[TCGA-CNTL] Controls"="TCGA-CNTL",
"[TCGA-ESCA] Esophageal carcinoma"="TCGA-ESCA",
# "[TCGA-FPPP] FFPE Pilot Phase II"="TCGA-FPPP",
"[TCGA-GBM] Glioblastoma multiforme"="TCGA-GBM",
"[TCGA-HNSC] Head and Neck squamous cell carcinoma"="TCGA-HNSC",
"[TCGA-KICH] Kidney Chromophobe"="TCGA-KICH",
"[TCGA-KIRC] Kidney renal clear cell carcinoma"="TCGA-KIRC",
"[TCGA-KIRP] Kidney renal papillary cell carcinoma"="TCGA-KIRP",
"[TCGA-LIHC] Liver hepatocellular carcinoma"="TCGA-LIHC",
"[TCGA-LUAD] Lung adenocarcinoma"="TCGA-LUAD",
"[TCGA-LUSC] Lung squamous cell carcinoma"="TCGA-LUSC",
"[TCGA-DLBC] Lymphoid Neoplasm Diffuse Large B-cell Lymphoma"="TCGA-DLBC",
"[TCGA-MESO] Mesothelioma"="TCGA-MESO",
"[TCGA-MISC] Miscellaneous"="TCGA-MISC",
"[TCGA-OV] Ovarian serous cystadenocarcinoma"="TCGA-OV",
"[TCGA-PAAD] Pancreatic adenocarcinoma"="TCGA-PAAD",
"[TCGA-PCPG] Pheochromocytoma and Paraganglioma"="TCGA-PCPG",
"[TCGA-PRAD] Prostate adenocarcinoma"="TCGA-PRAD",
"[TCGA-READ] Rectum adenocarcinoma"="TCGA-READ",
"[TCGA-SARC] Sarcoma"="TCGA-SARC",
"[TCGA-SKCM] Skin Cutaneous Melanoma"="TCGA-SKCM",
"[TCGA-STAD] Stomach adenocarcinoma"="TCGA-STAD",
"[TCGA-TGCT] Testicular Germ Cell Tumors"="TCGA-TGCT",
"[TCGA-THYM] Thymoma"="TCGA-THYM",
"[TCGA-THCA] Thyroid carcinoma"="TCGA-THCA",
"[TCGA-UCS] Uterine Carcinosarcoma"="TCGA-UCS",
"[TCGA-UCEC] Uterine Corpus Endometrial Carcinoma"="TCGA-UCEC",
"[TCGA-UVM] Uveal Melanoma"="TCGA-UVM"
))
TCGA_pipeline_choices=c(
"muse",
"varscan2",
"somaticsniper",
"mutect2"
)