РЕДАКТИРОВАТЬ: Обновлено с немного лучшим кодом.
Я работаю над очень неуклюжим пользовательским интерфейсом, который имеет ветви входов .... но я мне интересно, если я должен делать это по-другому, возможно, на стороне сервера? Я хочу перемещаться вниз по входам, поскольку каждый из них выбран, и , чтобы не показывать следующий вход, пока не будет установлен предыдущий. В конечном итоге каждое дерево решений приводит к отображению таблицы данных с помощью функции SQL на стороне сервера. (Я создал две аналогичные функции: одну для рендеринга таблицы с одним выделением, а другую для рендеринга с множественным выбором. Затем выбранные строки таблицы будут отправлены обратно на сервер вместе с входными данными с помощью кнопки отправки.
В конечном итоге я пытаюсь дополнить это приложение: https://shiny.rstudio.com/gallery/phylo-tree-view-subset.html, чтобы иметь ветку, которая позволяет пользователю манипулировать пользовательскими данными, а затем передавать их обратно в функцию построения дерева.
Должен ли я пытаться сделать такую структуру ввода на сервере вместо пользовательского интерфейса? Если так, есть ли где-нибудь достойный пример? Я изо всех сил пытаюсь увидеть, как различные демки будут работать с этим.
У меня есть дерево входных данных примерно так:
1) Do you have a file to upload? (yes/no)
a)Yes
1)File type (list)
2)Choose file (file explorer)
b)No
1)Choose single sample or multiple sample: (single/multiple)
a)Single
1)choose type: (otu/sequence)
a)anychoice
1)Abundance or Incidence? (abundance/incidence)
a)abundance
1)Slider for value between 0-10,000
2)Distance method (list of options)
3) Display datatable (select single row)
4) Submit button
a)Multiple
1)choose type: (otu/sequence)
a)anychoice
1)Abundance or Incidence? (abundance/incidence)
a)abundance
1)Slider for value between 0-10,000
2)Cluster method (list of options)
3)Distance method (list of options)
4) Display datatable (select multiple rows)
5) Submit button
Текущий код, он не дает всех функций, которые я хочу, но я все еще отрываюсь от него.
ui.R
library(shiny)
library(shinyjs)
library(shinyalert)
ui <- shinyUI(tagList(
useShinyalert(),
useShinyjs(),
navbarPage(
title = "Phylogenetic Tree Subsetting",
tabPanel(
title = "Explore Tree",
fluidRow(
class = "inputs",
column(
4,
selectInput(
inputId = "own_file",
label = "Do you already have a tree file to upload?",
choices = c("No" = "no",
"Yes" = "yes",
" " = " "),
selected = " "
)
),
conditionalPanel(condition = "input.own_file == 'yes'",
column(
4,
selectInput(
inputId = "file_type",
label = "Select Tree File Type:",
choices = c(
"Tree" = "tree",
"Beast" = "beast",
# "CodeML" = "codeml",
"CodeML mlc" = "mlc",
# "HYPHY" = "hyphy",
"jplace" = "jplace",
"MrBayes" = "mrbayes",
"NHX" = "nhx",
"rst (CODEML/BASEML)" = "rst",
"phylip" = "phylip",
# "r8s" = "r8s",
"RAxML" = "raxml"
),
selected = "tree"
)
),
column(
4,
fileInput(inputId = "upload_tree",
label = "Select Tree File:")
)),
conditionalPanel(
condition = "input.own_file == 'no'",
column(
4,
selectInput(
inputId = "tree_type",
label = "Would you like to view a single sample, or cluster multiple samples?",
choices = c(
"Single" = "single",
"Multiple" = "multiple",
" " = " "
),
selected = " "
)
),
conditionalPanel(
condition = "input.tree_type == 'single'",
column(
4,
selectInput(
inputId = "cluster_type1",
label = "View by Organism, or by Sequence?",
choices = c(
Choose = '',
OTU = 'otu',
Sequence = 'sequence'
),
selectize = FALSE
)
),
conditionalPanel(
condition = "input.cluster_type1 == 'sequence'|input.cluster_type1 == 'otu'",
column(
4,
selectInput(
inputId = "presence_type1",
label = "Generate tree from Presence/Absence, or Relative Abundance?",
choices = c(
Choose = '',
Incidence = 'incidence',
Abundance = 'abundance'
),
selectize = FALSE
)
),
conditionalPanel(condition = "input.presence_type1 == 'abundance'",
column(
4,
sliderInput(
"norm_value1",
"Choose normalization value: (Use keyboard arrows to fine tune value.)",
min = 0,
max = 10000,
value = 3999
)
)),
conditionalPanel(
condition = "input.presence_type1 == 'incidence'|input.presence_type1 == 'abundance'",
column(
4,
selectInput(
inputId = "distance_method1",
label = "Which distance method would you like to use for the distance matrix?",
choices = c(
"Manhattan" = "manhattan",
"Canberra" = "canberra",
"Bray" = "bray",
"Kulczynski" = "kulczynski",
"Jaccard" = "jaccard",
"Gower" = "gower",
"AltGower" = "altGower",
"Morisita" = "morisita",
"Horn" = "horn",
"Mountford" = "mountford",
"Raup" = "raup",
"Binomial" = "binomial",
"Chao" = "chao",
"Cao" = "cao",
"Mahalanobis" = "mahalanobis"
),
selected = "gower"
)
),
conditionalPanel(condition = "input.distance_method1 == 'bray'|input.norm_value1 == '4000'",
column(
4,
DT::dataTableOutput("tbl1"),
actionButton(
"button",
"SUBMIT",
style = "background-color:#221B70;
color:#E0EB15;
border-color:#E61029;
border-style:double;
border-width:4px;
border-radius:50%;
font-size:19px;"
)
))
)
)
)
),
conditionalPanel(
condition = "input.tree_type == 'multiple'",
column(
4,
selectInput(
inputId = "cluster_type2",
label = "View by Organism, or by Sequence?",
choices = c(
Choose = '',
OTU = 'otu',
Sequence = 'sequence'
),
selectize = FALSE
)
),
conditionalPanel(
condition = "input.cluster_type2 == 'sequence'|input.cluster_type2 == 'otu'",
column(
4,
selectInput(
inputId = "presence_type2",
label = "Generate tree from Presence/Absence, or Relative Abundance?",
c(
Choose = '',
Incidence = 'incidence',
Abundance = 'abundance'
),
selectize = FALSE
)
),
conditionalPanel(condition = "input.presence_type2 == 'abundance'",
column(
4,
sliderInput(
"norm_value2",
"Choose normalization value: (Use keyboard arrows to fine tune value.)",
min = 0,
max = 10000,
value = 3999
)
)),
conditionalPanel(
condition = "input.presence_type2 == 'incidence'|input.presence_type2 == 'abundance'",
column(
4,
selectInput(
inputId = "cluster_method",
label = "Which clustering method would you like to use?",
choices = c(
"Ward.D" = "ward.D",
"Ward.D2" = "ward.D2",
"Single" = "single",
"Complete" = "complete",
"Average (= UPGMA)" = "average",
"Mcquitty (= WPGMA)" = "mcquitty",
"Median (= WPGMC)" = "median",
"Centroid (= UPGMC)" = "centroid"
),
selected = "single"
)
),
conditionalPanel(
condition = "input.cluster_method == 'ward.D2'",
column(
4,
selectInput(
inputId = "distance_method2",
label = "Which distance method would you like to use for the distance matrix?",
choices = c(
"Manhattan" = "manhattan",
"Canberra" = "canberra",
"Bray" = "bray",
"Kulczynski" = "kulczynski",
"Jaccard" = "jaccard",
"Gower" = "gower",
"AltGower" = "altGower",
"Morisita" = "morisita",
"Horn" = "horn",
"Mountford" = "mountford",
"Raup" = "raup",
"Binomial" = "binomial",
"Chao" = "chao",
"Cao" = "cao",
"Mahalanobis" = "mahalanobis"
),
selected = "gower"
)
),
conditionalPanel(
condition = "input.distance_method2 == 'bray'|input.norm_value2 == '4000'",
DT::dataTableOutput("tbl2"),
actionButton(
"button",
"SUBMIT",
style = "background-color:#221B70;
color:#E0EB15;
border-color:#E61029;
border-style:double;
border-width:4px;
border-radius:50%;
font-size:19px;"
)
)
)
)
)
)
),
uiOutput("select_node_render"),
fluidRow(uiOutput("subtree_render"))
)
)
))
server <- function(input, output){
}
shinyApp(ui, server)