inst/shinyEg/ShinyTestPMD/ui.R

library(PMA)
library(TestPMD)
library(ggplot2)
library(ggpubr)
library(cowplot)
library(shiny)
library(textyle)

shinyUI(fluidPage(
  theme = bslib::bs_theme(bootswatch = "flatly"),
  tabsetPanel(
    tabPanel("Welcome",
             mainPanel(
               textyle(tags$p("Welcome to TestPMD!", style = "font-size:3rem;font-weight:900;")),
               tags$p("TestPMD is an R package providing tools of post selection inferences on the singular values and vectors using", tags$a(href = "https://academic.oup.com/biostatistics/article/10/3/515/293026", "Penalized Matrix Decomposition.")),
               tags$p("It supports the hypothesis tests on singular values and vectors of an arbitrary matrix (", tags$a(href = "https://en.wikipedia.org/wiki/Low-rank_approximation", "Low rank approximation"),"), sample covariance (Sparse ",tags$a(href = "https://en.wikipedia.org/wiki/Principal_component_analysis", "PCA"),"),", "sample cross-covariance (Sparse ", tags$a(href= "https://en.wikipedia.org/wiki/Canonical_correlation","CCA"),")"),
               tags$p("Current version only have tests on Sparse CCA, providing significance test on canonical correlations and loadings, facilitate the feature selection and dimension reduction."),
               h4("Workflow"),
               tags$ol(
                 tags$li("Upload your data files, including:"),
                 tags$ul(
                   tags$li("Two csv files with rows are matched samples, columns are features."),
                   tags$li("Two csv files with feature groups information, containing feature name column and group column."),
                   tags$li("One meta files containing sample groups information, should have sample names column and groups column.")
                 ),
                 tags$li("PMD estimation, specify:"),
                 tags$ul(
                   tags$li("Bound on X: penalty for X"),
                   tags$li("Bound on Y: penalty for Y"),
                   tags$li("Number of component to compute."),
                   tags$li("Check scatter plot for: the component for which the canonical variates scatter plot will be plotted " ),
                   tags$li("Check loadings estimation for: the component for which the canonical loadings scatter plot will be plotted " )
                 ),
                 tags$li("Inferences on canonical correlations and loadings, specify:"),
                 tags$ul(
                   tags$li("Bound on X: penalty for X."),
                   tags$li("Bound on Y: penalty for Y."),
                   tags$li("How many canonical correlations you want to test."),
                   tags$li("How many permutations for each canonical correlation." ),
                   tags$li("Which canonical loading you want to test." ),
                   tags$li("This canonical loading is wrt: X or Y."),
                   tags$li("How many permutations for each canonical loading." ),
                   tags$li("Significance level.")

                 ),
                 tags$li("Visualization, including:"),
                 tags$ul(
                   tags$li("PMD Estimation Tab: scatter plots of canonical correlations."),
                   tags$li("PMD Estimation Tab: scatter plots of canonical variates separated by sample groups."),
                   tags$li("PMD Estimation Tab: scatter plots of canonical loadings."),
                   tags$li("Inference Tab: bar scatter plots of canonical correlations and corresponding pvalues."),
                   tags$li("Inference Tab: bar plot of canonical loadings showing significance and/or feature groups (if provided)."),
                   tags$li("Inference Tab: heatmap of pvalues for feature group enrichment analysis.")
                 ),
                 tags$li("Search for papers using keywords on PubMed.")
               )
             )
             ),

    tabPanel("Data Upload",
             sidebarLayout(
               sidebarPanel(
                 selectInput("datamethod", "Data", c("covid multi-omics","upload my data")),
                 wellPanel(
                   conditionalPanel(
                     condition = "input.datamethod == 'upload my data'",
                     fileInput("Xcsv", "X: n*p", buttonLabel = "Upload...", accept = ".csv"),
                     fileInput("Ycsv", "Y: n*p", buttonLabel = "Upload...", accept = ".csv"),
                     selectInput("asksamplegroup", "Do samples have group info?", c("No", "Yes")),
                     wellPanel(
                       conditionalPanel(
                         condition = "input.asksamplegroup == 'Yes'",
                         fileInput("samplecsv", "Samples group: n*2", buttonLabel = "Upload...", accept = ".csv")
                       )
                     ),
                     selectInput("askfeaturegroup", "Do features have group info?", c("No", "Yes")),
                     wellPanel(
                       conditionalPanel(
                         condition = "input.askfeaturegroup == 'Yes'",
                         fileInput("Xfeaturecsv", "Features group wrt X: p*2", buttonLabel = "Upload...", accept = ".csv"),
                         fileInput("Yfeaturecsv", "Features group wrt Y: q*2", buttonLabel = "Upload...", accept = ".csv")
                       )
                     )
                   )
                 )
               ),
               mainPanel(
                 h4("Data format:"),
                 tags$ol(
                   tags$li("X, Y: data matrices, csv format with header, samples in rows, features in columns, matched samples"),
                   tags$li("Samples group: group information of samples, the rows are samples matched with X, Y, one column is sample names/indices , one column is group information, with header. Must present if you want scatter plot."),
                   tags$li("Features group wrt X, or Y: group information of features in X, matched features, one column for feature names, one column for group. Must present if you want colored bar plot and enrichment analysis.")
                 ),
                 tags$div("Example:"),
                 fluidRow(
                   column(4.5,tableOutput("dataXYeg")),
                   column(3,tableOutput("dataSGeg")),
                   column(3,tableOutput("dataFGeg"))

                 ),
                 h4("Data description"),
                 textOutput("dataSUM"),
                 wellPanel(
                   conditionalPanel(
                     condition = "input.asksamplegroup == 'Yes' | input.datamethod == 'covid multi-omics'",
                     plotOutput("dataSGplot", width = "50%")

                   ),
                   conditionalPanel(
                     condition = "input.askfeaturegroup == 'Yes'| input.datamethod == 'covid multi-omics'",
                     plotOutput("dataFGplot", width = "100%")
                   )
                 )
               )
             )

    ),
    tabPanel("PMD Estimation",
             sidebarLayout(
               sidebarPanel(
                 numericInput("rhox", "Bound on X:", 0.9, min = 0.001, max = 0.999),
                 numericInput("rhoy", "Bound on Y:", 0.9, min = 0.001, max = 0.999),
                 numericInput("K", "Number of canonical components to compute:", 3, min = 1, max = 10),
                 selectInput("visKcor", "Check scatterplot for:", 1:10),
                 selectInput("visKloading", "Check loadings estimation for:", 1:10)
               ),
               mainPanel(
                 h4("Parameters:"),
                 tags$ul(
                   tags$li("Bound on X: penalty for X"),
                   tags$li("Bound on Y: penalty for Y"),
                   tags$li("Number of component to compute."),
                   tags$li("Check scatter plot for: the component for which the canonical variates scatter plot will be plotted " ),
                   tags$li("Check loadings estimation for: the component for which the canonical loadings scatter plot will be plotted " )
                 ),
                 fluidRow(
                   column(5,plotOutput("PMDcor")),
                   column(6, plotOutput("PMDscatter"))
                 ),
                 plotOutput("PMDloading", width = "100%", height = "40%")

               )
             )),
    tabPanel("Inferences",
             sidebarLayout(
              sidebarPanel(
                numericInput("rhox", "Bound on X:", 0.9, min = 0.001, max = 0.999),
                numericInput("rhoy", "Bound on Y:", 0.9, min = 0.001, max = 0.999),
                numericInput("valuerange", "How many canonical correlations you want to test:", 3, min = 1, max = 10),
                numericInput("valueperm", "How many permutations for each canonical correlation:", 100, min = 10, max = 1000),
                numericInput("loadingrange", "Which canonical loading you want to test:", 1, min = 1, max = 10),
                selectInput("side", "This canonical loading is wrt:", c("X", "Y")),
                numericInput("loadingperm", "How many permutations for each canonical loading:", 100, min = 10, max = 10000),
                numericInput("loadingsig","Significance level:", 0.05)
                ),
              mainPanel(
                h4("Parameters:"),
                tags$ul(
                  tags$li("Bound on X: penalty for X."),
                  tags$li("Bound on Y: penalty for Y."),
                  tags$li("How many canonical correlations you want to test."),
                  tags$li("How many permutations for each canonical correlation." ),
                  tags$li("Which canonical loading you want to test." ),
                  tags$li("This canonical loading is wrt: X or Y."),
                  tags$li("How many permutations for each canonical loading." ),
                  tags$li("Significance level.")

                ),
                fluidRow(
                  column(6, plotOutput("Infercor")),
                  column(6, plotOutput("Inferfisher"))
                ),
                plotOutput("Inferloading", width = "100%")

              )
             )),
    tabPanel("Searching",
             sidebarLayout(
               sidebarPanel(
                 selectInput("searchside", "Features of:", c("X", "Y")),
                 numericInput("dispnum", "How many features to show:", 6, min = 1),
                 textInput("main", "Key words you want to search using PubMed:", value = "4-O-Methylmelleolide", width = NULL, placeholder = NULL)
               ),
               mainPanel(
                 h4("Significant features:"),
                 tableOutput("Searchsource"),
                 h4("Top related paper on PubMed:"),
                 tableOutput("Searchres")
               )
             )
             )
  )


))
YunhuiQi/TestPMD documentation built on May 5, 2022, 8:23 p.m.