Skip to content

Commit fedb3e7

Browse files
committed
first commit
1 parent 391c513 commit fedb3e7

File tree

5 files changed

+171
-0
lines changed

5 files changed

+171
-0
lines changed

Diff for: Dockerfile

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
FROM rocker/shiny:4.2.0
2+
3+
RUN apt-get update \
4+
&& apt-get install -y \
5+
apt-utils \
6+
manpages-dev \
7+
libnetcdf-dev \
8+
libxml2-dev \
9+
libglpk-dev \
10+
libnode-dev \
11+
libz-dev
12+
13+
RUN R -e "install.packages('BiocManager')"
14+
# RUN R -e "BiocManager::install('omicsViewer')"
15+
RUN R -e "BiocManager::install('xcms')"
16+
RUN R -e "BiocManager::install('MAIT')"
17+
RUN R -e "install.packages('devtools')"
18+
RUN R -e 'BiocManager::install(c("survminer", "survival","fastmatch","reshape2","beeswarm","grDevices","shinycssloaders","shinythemes","networkD3","httr","RColorBrewer","psych","stringr","shiny","shinydashboard","shinyWidgets","shinybusy","matrixStats","flatxml","excelR","shinyjs","shinyFiles","DT","plotly","openxlsx","yaml","curl","sortable","BiocManager","password","ggseqlogo","devtools","Matrix","RSQLite"))'
19+
RUN R -e 'BiocManager::install(c("Biobase", "fgsea", "S4Vectors", "SummarizedExperiment"), update = FALSE)'
20+
RUN R -e 'devtools::install_github("mengchen18/omicsViewer", dependencies = TRUE)'
21+
RUN R -e "devtools::install_github('mengchen18/xcmsViewer', upgrade='never')"
22+
23+
24+
RUN mkdir /home/shiny/data && \
25+
mkdir /home/shiny/app
26+
27+
COPY . /home/shiny/app/
28+
29+
ENV PORT 3838
30+
31+
ENV HOST "0.0.0.0"
32+
33+
CMD ["R", "-e", "shiny::runApp('/home/shiny/app', host = Sys.getenv(\"HOST\"), port = strtoi(Sys.getenv(\"PORT\")))"]
34+

Diff for: landingPage.R

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
landingPage_ui <- function(id) {
3+
ns <- NS(id)
4+
tagList(
5+
tags$style("#landingpageid{margin: auto;}"),
6+
h1("Welcome to BayBioMS xcmsViewer for untargeted metabolomics data!"),
7+
absolutePanel(id = "landingpageid", class = "myClass", fixed = TRUE
8+
,draggable = FALSE, left = 0, right = 0, top = "35%"
9+
,width = 500, height = "auto",
10+
wellPanel(
11+
uiOutput(ns("error.ui")),
12+
fluidRow(
13+
column(10, passwordInput(ns("id"), "Your passcode", placeholder = "Enter your passcode here!")),
14+
column(2, actionButton(ns("go"), "Go!"), style = "padding-top:25px")
15+
)
16+
)
17+
)
18+
)
19+
}
20+
21+
landingPage_module <- function(input, output, session) {
22+
23+
ns <- session$ns
24+
25+
# hashTab <- read.delim(
26+
# "/dss/ga52cib/xcmsViewer/passcodeList.tsv", header = TRUE,
27+
# "/home/shiny/data/xcmsViewer/passcodeList.tsv", header = TRUE, stringsAsFactors = FALSE
28+
# "/media/share_LRZCC/xcmsViewer/passcodeList_debug.tsv", header = TRUE, stringsAsFactors = FALSE
29+
# )
30+
31+
hashTab <- data.frame(
32+
code = "metabohub",
33+
path = "/home/shiny/data/", #Data will be loaded from here in the Docker container
34+
#path = "~/xcmsViewerDBs/",
35+
stringsAsFactors = FALSE
36+
)
37+
38+
m0 <- eventReactive(input$go, {
39+
id <- trimws(input$id)
40+
i <- which(hashTab[, 1] %in% id)
41+
if (length(i) != 1)
42+
return(NULL)
43+
i
44+
})
45+
46+
output$error <- renderUI({
47+
HTML("There was an error with your passcode, please try again! <br><hr>")
48+
})
49+
50+
output$error.ui <- renderUI({
51+
req(is.null(m0()))
52+
uiOutput(ns("error"))
53+
})
54+
55+
reactive({
56+
req(m0())
57+
hashTab[m0(), 2]
58+
})
59+
}

Diff for: res.RDS

7.38 MB
Binary file not shown.

Diff for: server.R

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
library(xcmsViewer)
2+
library(omicsViewer)
3+
source("/home/shiny/app/landingPage.R")
4+
# source("landingPage.R")
5+
6+
ll <- list(
7+
list(
8+
tabName = "Annotation",
9+
moduleName = "xcmsannot",
10+
moduleUi = xcmsViewer:::xcmsAnnotationTab_ui,
11+
moduleServer = xcmsViewer:::xcmsAnnotationTab_module
12+
)
13+
)
14+
15+
returnValueOrNULL <- function(x, v) {
16+
r <- x$header[x$axis == v]
17+
if (is.na(r))
18+
return(NULL)
19+
r
20+
}
21+
22+
server <- function(input, output, session) {
23+
24+
ns <- session$ns
25+
26+
v <- callModule(landingPage_module, id = "test")
27+
showLanding <- reactiveVal(TRUE)
28+
29+
observe({
30+
showLanding ( length(v()) != 1 )
31+
})
32+
33+
output$uis <- renderUI({
34+
req(showLanding())
35+
landingPage_ui("test")
36+
})
37+
38+
observe(print(v()))
39+
40+
callModule(
41+
omicsViewer:::app_module, id = "app", .dir = v,
42+
filePattern = ".RDS$|.DB$",
43+
esetLoader = function(x) {
44+
if (grepl(".db$", x, ignore.case = TRUE)) {
45+
obj <- RSQLite::dbConnect(RSQLite::SQLite(), x)
46+
x <- RSQLite::dbGetQuery(obj, 'SELECT * FROM defaultVis;')
47+
attr(obj, "fx") <- returnValueOrNULL(x, "fx")
48+
attr(obj, "fy") <- returnValueOrNULL(x, "fy")
49+
attr(obj, "sx") <- returnValueOrNULL(x, "sx")
50+
attr(obj, "sy") <- returnValueOrNULL(x, "sy")
51+
} else if (grepl("RDS", x, ignore.case = TRUE)) {
52+
obj <- readRDS(x)
53+
}
54+
obj
55+
},
56+
exprsGetter = getFeatureExprs,
57+
pDataGetter = getPheno,
58+
fDataGetter = getFeatureMeta,
59+
defaultAxisGetter = function(x, what) attr(x, what),
60+
additionalTabs = ll,
61+
appName = "XcmsViewer",
62+
appVersion = packageVersion("xcmsViewer")
63+
)
64+
65+
output$aout <- renderUI({
66+
req(!showLanding())
67+
omicsViewer:::app_ui("app")
68+
})
69+
}

Diff for: ui.R

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
library(xcmsViewer)
2+
library(omicsViewer)
3+
source("/home/shiny/app/landingPage.R")
4+
# source("landingPage.R")
5+
6+
ui <- fluidPage(
7+
uiOutput("uis"),
8+
uiOutput("aout")
9+
)

0 commit comments

Comments
 (0)