Skip to content
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.Rhistory
.RData
.Ruserdata
rsconnect/
rsconnect/
.idea
40 changes: 15 additions & 25 deletions R/QBMS.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,42 @@
#'
#' @return a list
#' @noRd
qbmsbrapi <- function(url = "https://bms.ciat.cgiar.org/ibpworkbench/controller/auth/login",
engine = c("bms", "breedbase"),
path = ifelse(engine == "bms", "bmsapi", ""),
time_out = ifelse(engine == "bms", 120, 300),
qbmsbrapi <- function(url = "https://qa-test.breedinginsight.net/v1/programs/8397cfd7-7d28-4441-964d-4d5567f67e9e",
engine = '',
path = '',
time_out = 300,
no_auth = FALSE,
brapi_ver = 'v2',
username = NULL,
password = NULL) {
if (is.null(url) | url == "") {
return()
}

bmsbase <- QBMS::set_qbms_config(
url = url,
path = path,
time_out = time_out,
no_auth = no_auth,
engine = engine,
page_size = 5000
page_size = 100000,
brapi_ver = 'v2',
engine = engine
)

if (!no_auth) {
if (is.null(username) | username == "") {
return()
}
if (is.null(password) | password == "") {
return()
}
bmslogin <- QBMS::login_bms(username = username, password = password)
} else {
bmslogin <- NULL
if (is.null(password) | password == "") {
return()
}
QBMS::set_token(password)

crops <- QBMS::list_crops()
return(list(bmsbase = bmsbase, bmslogin = bmslogin, crops = crops))
return(list(bmsbase = bmsbase, crops = crops))
}


#' Get Programs
#'
#' @param crop crop
#'
#' @return a list with programs
#' @noRd
qbmsprograms <- function(crop = NULL) {
if (is.null(crop)) {
return()
}
QBMS::set_crop(crop)
programs <- QBMS::list_programs()
return(programs)
}
Expand Down Expand Up @@ -125,7 +115,7 @@ dataqbms <- function(studies = NULL, dt_studies = NULL) {
) %>%
as.data.frame()
} else {
names(mult_dt) <- dt_studies$trial
names(mult_dt) <- dplyr::filter(dt_studies, trimws(studyName) %in% trimws(studies))$trial
mult_dt <- data.table::rbindlist(
l = mult_dt,
fill = TRUE,
Expand Down
1 change: 1 addition & 0 deletions R/app_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#' @import shiny
#' @noRd
app_server <- function(input, output, session) {

sever::sever()
# Home
callModule(mod_home_module1_server, "home_module1_ui_1")
Expand Down
142 changes: 79 additions & 63 deletions R/app_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
#' @import shiny
#' @noRd
app_ui <- function(request) {

# Read configuration
app_directory <- system.file("", package = "MrBean")
config_path <- file.path(app_directory, "", "config.yml")
config <- yaml::read_yaml(config_path)

tagList(
# Leave this function for adding external resources
golem_add_external_resources(),
Expand Down Expand Up @@ -125,71 +131,81 @@ app_ui <- function(request) {
icon = shiny::icon("circle", verify_fa = FALSE)
)
),
bs4SidebarHeader("ASReml"),
# Single spatial analysis ASReml
bs4SidebarMenuItem(
text = "Single-Site",
icon = shiny::icon("braille"),
startExpanded = F,
bs4SidebarMenuSubItem(
text = "Model Specs",
tabName = "spats_asreml",
icon = shiny::icon("circle", verify_fa = FALSE)
),
bs4SidebarMenuSubItem(
text = "BLUPs/BLUEs",
tabName = "spats_asreml_effects",
icon = shiny::icon("circle", verify_fa = FALSE)
)
),
# Un-replicated analysis
bs4SidebarMenuItem(
"Unreplicated",
icon = shiny::icon("crosshairs"),
startExpanded = F,
bs4SidebarMenuSubItem(
text = "Model Specs",
tabName = "aug_model",
icon = shiny::icon("circle", verify_fa = FALSE)
),
bs4SidebarMenuSubItem(
text = "BLUPs/BLUEs",
tabName = "aug_result",
icon = shiny::icon("circle", verify_fa = FALSE)
)
),
# Model selector
bs4SidebarMenuItem(
text = "Model Selector",
icon = shiny::icon("hand-pointer"),
startExpanded = F,
bs4SidebarMenuSubItem(
HTML(
paste(
"Model Specs",
bs4Badge("new",
position = "right",
color = "success"
)

# Conditionally include ASReml features
if (config$enable_asreml_features) {
bs4SidebarHeader("ASReml")
},
if (config$enable_asreml_features){
# Single spatial analysis ASReml
bs4SidebarMenuItem(
text = "Single-Site",
icon = shiny::icon("braille"),
startExpanded = F,
bs4SidebarMenuSubItem(
text = "Model Specs",
tabName = "spats_asreml",
icon = shiny::icon("circle", verify_fa = FALSE)
),
bs4SidebarMenuSubItem(
text = "BLUPs/BLUEs",
tabName = "spats_asreml_effects",
icon = shiny::icon("circle", verify_fa = FALSE)
)
),
tabName = "asreml_selector",
icon = shiny::icon("circle", verify_fa = FALSE)
),
bs4SidebarMenuSubItem(
HTML(
paste(
"BLUPs/BLUEs",
bs4Badge("new",
position = "right",
color = "success"
)
)
},
if (config$enable_asreml_features){
# Un-replicated analysis
bs4SidebarMenuItem(
"Unreplicated",
icon = shiny::icon("crosshairs"),
startExpanded = F,
bs4SidebarMenuSubItem(
text = "Model Specs",
tabName = "aug_model",
icon = shiny::icon("circle", verify_fa = FALSE)
),
bs4SidebarMenuSubItem(
text = "BLUPs/BLUEs",
tabName = "aug_result",
icon = shiny::icon("circle", verify_fa = FALSE)
)
),
tabName = "asr_sel_selected",
icon = shiny::icon("circle", verify_fa = FALSE)
)
),
)
},
if (config$enable_asreml_features){
# Model selector
bs4SidebarMenuItem(
text = "Model Selector",
icon = shiny::icon("hand-pointer"),
startExpanded = F,
bs4SidebarMenuSubItem(
HTML(
paste(
"Model Specs",
bs4Badge("new",
position = "right",
color = "success"
)
)
),
tabName = "asreml_selector",
icon = shiny::icon("circle", verify_fa = FALSE)
),
bs4SidebarMenuSubItem(
HTML(
paste(
"BLUPs/BLUEs",
bs4Badge("new",
position = "right",
color = "success"
)
)
),
tabName = "asr_sel_selected",
icon = shiny::icon("circle", verify_fa = FALSE)
)
)
},
bs4SidebarHeader("Two-Stage Analysis"),
# Two-Stage MET
bs4SidebarMenuItem(
Expand Down
81 changes: 45 additions & 36 deletions R/mod_home_module1.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
#'
#' @importFrom shiny NS tagList
mod_home_module1_ui <- function(id) {

# Read configuration
app_directory <- system.file("", package = "MrBean")
config_path <- file.path(app_directory, "", "config.yml")
config <- yaml::read_yaml(config_path)

ns <- NS(id)
tagList(
fluidRow(
Expand Down Expand Up @@ -39,15 +45,17 @@ mod_home_module1_ui <- function(id) {
href = "https://cran.r-project.org/web/packages/SpATS/SpATS.pdf",
icon = shiny::icon("braille")
),
bs4Dash::valueBox(
value = "ASReml-R",
subtitle = "AR1xAR1 Correlation",
width = 12,
color = "danger",
elevation = 3,
href = "https://asreml.kb.vsni.co.uk/wp-content/uploads/sites/3/2018/02/ASReml-R-Reference-Manual-4.pdf",
icon = shiny::icon("braille")
),
if (config$enable_asreml_features) {
bs4Dash::valueBox(
value = "ASReml-R",
subtitle = "AR1xAR1 Correlation",
width = 12,
color = "danger",
elevation = 3,
href = "https://asreml.kb.vsni.co.uk/wp-content/uploads/sites/3/2018/02/ASReml-R-Reference-Manual-4.pdf",
icon = shiny::icon("braille")
)
},
bs4Dash::valueBox(
value = "Lme4",
subtitle = "lmer",
Expand All @@ -66,33 +74,34 @@ mod_home_module1_ui <- function(id) {
elevation = 3,
href = "https://www.frontiersin.org/articles/10.3389/fpls.2018.01511/full"
),
bs4Card(
title = "Jump",
status = "danger",
width = 12,
solidHeader = TRUE,
actionLink(
inputId = ns("toAwesome1"),
label = "Data",
icon = icon("database"),
style = "color: #d9534f"
),
br(),
actionLink(
inputId = ns("toAwesome2"),
label = "Spatial",
icon = icon("braille"),
style = "color: #d9534f"
),
br(),
actionLink(
inputId = ns("toAwesome3"),
label = "Lme4",
icon = icon("chart-column", verify_fa = FALSE),
style = "color: #d9534f"
),
br()
)
#remove Jump Card
# bs4Card(
# title = "Jump",
# status = "danger",
# width = 12,
# solidHeader = TRUE,
# actionLink(
# inputId = ns("toAwesome1"),
# label = "Data",
# icon = icon("database"),
# style = "color: #d9534f"
# ),
# br(),
# actionLink(
# inputId = ns("toAwesome2"),
# label = "Spatial",
# icon = icon("braille"),
# style = "color: #d9534f"
# ),
# br(),
# actionLink(
# inputId = ns("toAwesome3"),
# label = "Lme4",
# icon = icon("chart-column", verify_fa = FALSE),
# style = "color: #d9534f"
# ),
# br()
# )
)
)
)
Expand Down
Loading