-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathupdate.R
88 lines (79 loc) · 2.68 KB
/
update.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
## app.R ##
suppressPackageStartupMessages({
library(doqtl2)
library(shiny)
library(shinydashboard)
library(GGally)
})
source(system.file("shiny/setup.R", package="doqtl2"))
#####################################################
ui <- navbarPage("Update",
tabPanel("settings",
textOutput("num_pheno"),
uiOutput("chr_pos")),
tabPanel("window",
shinyWindowUI("window")),
tabPanel("phenos",
shinyPhenosUI("phenos")),
tabPanel("peaks",
shinyPeaksInput("shinypeaks"),
shinyPeaksOutput("shinypeaks"))
)
server <- function(input, output, session) {
## Reactives for testPhenos.
pheno_typer <- reactive({pheno_type})
peaks_tbl <- reactive({peaks})
pmap_obj <- reactive({pmap})
analyses_tblr <- reactive({analyses_tbl})
hot_peak <- callModule(shinyPeaks, "shinypeaks",
pheno_typer, peaks_tbl, pmap_obj)
## Use peaks as input to shinyWindow.
win_par <- callModule(shinyWindow, "window",
pmap_obj, hot_peak)
## Use window as input to shinyPhenos.
pheno_anal <- callModule(shinyPhenos, "phenos",
pheno_typer, peaks_tbl, analyses_tblr,
hot_peak, win_par)
output$chr_pos <- renderText({
cat(file=stderr(), "chr_pos", win_par$chr_id, "pos",
win_par$peak_Mbp, "\n")
chr_id <- win_par$chr_id
if(is.null(chr_id))
chr_id <- "?"
peak_Mbp <- win_par$peak_Mbp
if(is.null(peak_Mbp))
peak_Mbp <- "?"
else
peak_Mbp <- round(peak_Mbp, 2)
window_Mbp <- win_par$window_Mbp
if(is.null(window_Mbp))
window_Mbp <- "?"
paste0("Region: ", chr_id, "@", peak_Mbp,
" ", HTML("±"), " ", window_Mbp, "Mbp")
})
hr_num <- function(x, digits_ct=0) {
x <- gdata::humanReadable(x, digits=digits_ct, sep="",
standard="SI",
justify=c("right","right"))
substring(x, 1, nchar(x) - 1)
}
output$num_pheno <- renderText({
tot_pheno <- nrow(analyses_tbl %>% distinct(pheno))
tot_pheno <- hr_num(tot_pheno, 2)
paste("Phenotypes:", 0, "of", tot_pheno)
})
observeEvent(pheno_anal(), {
output$num_pheno <- renderText({
pheno <- pheno_anal()
if(any(c("all","none") %in% pheno))
return(NULL)
num_pheno <- length(unique(pheno))
tot_pheno <- nrow(analyses_tbl %>% distinct(pheno))
## Put in human-readable format
num_pheno <- hr_num(num_pheno, 0)
tot_pheno <- hr_num(tot_pheno, 2)
paste("Phenotypes:", num_pheno, "of", tot_pheno)
})
})
}
shinyApp(ui, server)