xref: /aosp_15_r20/external/rappor/apps/rappor-analysis/ui.R (revision 2abb31345f6c95944768b5222a9a5ed3fc68cc00)
1*2abb3134SXin Lilibrary(shiny)
2*2abb3134SXin Li
3*2abb3134SXin LishinyUI(pageWithSidebar(
4*2abb3134SXin Li                        headerPanel("RAPPOR Analysis"),
5*2abb3134SXin Li                        sidebarPanel(
6*2abb3134SXin Li                                     tabsetPanel(tabPanel("Input",
7*2abb3134SXin Li                                                          fileInput('params', 'Select Params File (optional)',
8*2abb3134SXin Li                                                                    accept=c('txt/csv', 'text/comma-separated-values,text/plain', '.csv')),
9*2abb3134SXin Li                                                          fileInput('counts', 'Select Counts File',
10*2abb3134SXin Li                                                                    accept=c('txt/csv', 'text/comma-separated-values,text/plain', '.csv')),
11*2abb3134SXin Li                                                          fileInput('map', 'Select Map File',
12*2abb3134SXin Li                                                                    accept=c('txt/csv', 'text/comma-separated-values,text/plain', '.csv')),
13*2abb3134SXin Li                                                          br(),
14*2abb3134SXin Li                                                          br()
15*2abb3134SXin Li                                                          ),
16*2abb3134SXin Li                                                 tabPanel("RAPPOR",
17*2abb3134SXin Li                                                          selectInput("size", "Bloom filter size:",
18*2abb3134SXin Li                                                                      c(64, 128, 256, 512, 1024, 2048, 4096),
19*2abb3134SXin Li                                                                      selected = 128),
20*2abb3134SXin Li                                                          selectInput("hashes", "Number of hash functions:",
21*2abb3134SXin Li                                                                      c(1, 2, 4, 8, 16, 32),
22*2abb3134SXin Li                                                                      selected = 2),
23*2abb3134SXin Li                                                          selectInput("instances", "Number of cohorts:",
24*2abb3134SXin Li                                                                      c(1, 2, 4, 8, 16, 32, 64),
25*2abb3134SXin Li                                                                      selected = 8),
26*2abb3134SXin Li                                                          numericInput("N", "Number of reports", 0),
27*2abb3134SXin Li                                                          br(),
28*2abb3134SXin Li                                                          br(),
29*2abb3134SXin Li                                                          br()
30*2abb3134SXin Li                                                          ),
31*2abb3134SXin Li                                                 tabPanel("Privacy",
32*2abb3134SXin Li                                                          sliderInput("p", "Probability of reporting noise (p):",
33*2abb3134SXin Li                                                                      min = .01, max = .99, value = .5, step = .01),
34*2abb3134SXin Li                                                          sliderInput("q", "Probability of reporting signal (q):",
35*2abb3134SXin Li                                                                      min = .01, max = .99, value = .75, step = .01),
36*2abb3134SXin Li                                                          sliderInput("f", "Probability of lies (f):",
37*2abb3134SXin Li                                                                      min = 0, max = .99, value = .5, step = .01),
38*2abb3134SXin Li                                                          br(),
39*2abb3134SXin Li                                                          htmlOutput("epsilon"),
40*2abb3134SXin Li                                                          br(),
41*2abb3134SXin Li                                                          helpText("* In addition to p, q and f, the number of hash functions (set in the RAPPOR tab) also effects privacy guarantees."),
42*2abb3134SXin Li                                                          br(),
43*2abb3134SXin Li                                                          br(),
44*2abb3134SXin Li                                                          br()
45*2abb3134SXin Li                                                          ),
46*2abb3134SXin Li                                                 tabPanel("Decoding",
47*2abb3134SXin Li                                                          sliderInput("alpha", "Alpha - probability of false positive:",
48*2abb3134SXin Li                                                                      min = .01, max = 1, value = .05, step = .01),
49*2abb3134SXin Li                                                          br(),
50*2abb3134SXin Li                                                          selectInput("correction", "Multiple testing correction",
51*2abb3134SXin Li                                                                      c("None", "Bonferroni", "FDR"),
52*2abb3134SXin Li                                                                      selected = "FDR"),
53*2abb3134SXin Li                                                          br(),
54*2abb3134SXin Li                                                          br()
55*2abb3134SXin Li                                                          )
56*2abb3134SXin Li                                     ),
57*2abb3134SXin Li                                     conditionalPanel(
58*2abb3134SXin Li                                                      condition = "output.countsUploaded && output.mapUploaded",
59*2abb3134SXin Li                                                      helpText(actionButton("run", "Run Analysis"), align = "center")
60*2abb3134SXin Li                                                      ),
61*2abb3134SXin Li                                     br(),
62*2abb3134SXin Li                                     br(),
63*2abb3134SXin Li                                     helpText("Version 0.1", align = "center"),
64*2abb3134SXin Li                                     helpText(a("RAPPOR Paper", href="http://arxiv.org/abs/1407.6981"), align = "center")),
65*2abb3134SXin Li                        mainPanel(
66*2abb3134SXin Li                                  conditionalPanel(
67*2abb3134SXin Li                                                   condition = "!output.countsUploaded || !output.mapUploaded",
68*2abb3134SXin Li                                                   helpText(h2("Welcome to the RAPPOR Analysis Tool")),
69*2abb3134SXin Li                                                   helpText("To analyze a RAPPOR collection, please upload three files:"),
70*2abb3134SXin Li                                                   helpText(h3("1. Params file"), "This file specifies the 6 parameters that were used to encode RAPPOR reports. An example is shown below. It must have column names in the header line, 6 columns in this order, and 1 row. "),
71*2abb3134SXin Li                                                   htmlOutput("example_params"),
72*2abb3134SXin Li                                                   helpText(h3("2. Counts file"), "Required.  This file must have as many rows as cohorts. The first column contains the number of reports in the cohort.  The remaining k columns specify the number of times the corresponding bit was set in all reports (in the corresponding cohort). This file cannot have a CSV header line."),
73*2abb3134SXin Li                                                   htmlOutput("example_counts"),
74*2abb3134SXin Li                                                   helpText(h3("3. Map file"), "Required.  The first column contains candidate strings. The remaining columns show which bit each string is hashed to within each cohort. Indices are specified in the extended format, starting with index 1 (not 0!). Because we do not specify a cohort in the map file, indices must be adjusted in the following way. For example, if bits i and j are set in cohort 2, then their corresponding indices are i + k and j + k in the map file. The number of columns is equal to (h * m). This file cannot have a CSV header line."),
75*2abb3134SXin Li                                                   htmlOutput("example_map")
76*2abb3134SXin Li                                                   ),
77*2abb3134SXin Li                                  conditionalPanel(
78*2abb3134SXin Li                                                   condition = "output.countsUploaded && output.mapUploaded",
79*2abb3134SXin Li                                                   tabsetPanel(
80*2abb3134SXin Li                                                               tabPanel("Results",
81*2abb3134SXin Li                                                                        helpText(h3("Summary")), htmlOutput("pr"), br(),
82*2abb3134SXin Li                                                                        downloadButton('download_summary', 'Download Summary'),
83*2abb3134SXin Li                                                                        downloadButton('download_fit', 'Download Results'),
84*2abb3134SXin Li                                                                        br(), br(), dataTableOutput("tab")),
85*2abb3134SXin Li                                                               tabPanel("Distribution", plotOutput("res_barplot", height = "800px")),
86*2abb3134SXin Li                                                               tabPanel("Observed Counts",
87*2abb3134SXin Li                                                                        selectInput("selected_string", "Select String",
88*2abb3134SXin Li                                                                                    ""),
89*2abb3134SXin Li                                                                        plotOutput("counts", height = "800px")),
90*2abb3134SXin Li                                                               tabPanel("Estimated Counts", plotOutput("ests", height = "800px")),
91*2abb3134SXin Li                                                               tabPanel("Collision Counts", plotOutput("collisions", height = "800px")),
92*2abb3134SXin Li                                                               tabPanel("Map", plotOutput("map", height = "800px"))
93*2abb3134SXin Li                                                               )
94*2abb3134SXin Li                                                   )
95*2abb3134SXin Li                                  )
96*2abb3134SXin Li                        ))
97