Skip to content

Commit

Permalink
fix Error in if: argument is of length zero: input$contrast had inval…
Browse files Browse the repository at this point in the history
…id condition check
  • Loading branch information
mauromiguelm committed Mar 27, 2024
1 parent bb67c0b commit 5ac6067
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion components/board.upload/R/upload_module_makecontrast.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ upload_module_makecontrast_server <- function(
shiny::req(phenoRT(), countsRT())
df <- phenoRT()

print(1)
if ("<samples>" %in% input$param) {
df <- cbind(df, "<samples>" = rownames(df))
}
Expand All @@ -198,6 +199,7 @@ upload_module_makecontrast_server <- function(
df[, i] <- c("low", "high")[1 + 1 * (x >= mean(x, na.rm = TRUE))]
}
}
print(2)

pp <- intersect(input$param, colnames(df))
ss <- colnames(countsRT())
Expand All @@ -208,13 +210,15 @@ upload_module_makecontrast_server <- function(

output$createcomparison <- shiny::renderUI({
shiny::req(input$param)
print(3)

shiny::tagList(
shiny::tags$head(shiny::tags$style(".default-sortable .rank-list-item {padding: 2px 15px;}")),
shiny::tags$head(shiny::tags$style(".default-sortable.bucket-list-container {padding: 0px 0px;margin: 0 0 0 -5px;}")),
sortable::bucket_list(
header = NULL,
sortable::add_rank_list(
input_id = ns("conditions"),
text = "Conditions:",
labels = rv$condition_start,
),
Expand Down Expand Up @@ -245,14 +249,30 @@ upload_module_makecontrast_server <- function(

# make sure group1 and 2 are not NULL or ""
req(input$group1, input$group2)

print(4)

# update rv
rv$condition_group1 <- input$group1
rv$condition_group2 <- input$group2

# # remove selected conditions from the start list
# remove selected conditions from the start list
rv$condition_start <- setdiff(rv$condition_start, c(input$group1, input$group2))
# if length(rv$condition_start) == 0, then set it to NULL

# if (length(rv$condition_start) == 0) {
# rv$condition_start <- NULL
# }

print(5)

# if some input$conditions are not in the start list, add them
if (length(input$conditions) > 0 && !input$conditions %in% rv$condition_start) {
rv$condition_start <- c(rv$condition_start, input$conditions)
}


print(6)
g1 <- gsub("[-_.,<> ]", ".", input$group1)
g2 <- gsub("[-_.,<> ]", ".", input$group2)
g1 <- gsub("[.]+", ".", g1)
Expand All @@ -264,12 +284,15 @@ upload_module_makecontrast_server <- function(
if (is.na(g1)) g1 <- ""
if (is.na(g2)) g2 <- ""
g1 <- substring(g1, 1, 20)
print(7)
g2 <- substring(g2, 1, 20)
prm.name <- paste(input$param, collapse = ".")
prm.name <- gsub("[-_.,<> ]", "", prm.name)
tt <- paste0(prm.name, ":", g1, "_vs_", g2)
if (g1 == "" && g2 == "") tt <- ""
print(8)
shiny::updateTextInput(session, "newname", value = tt)
print(9)
})

shiny::observeEvent(c(input$group1, input$group2), {
Expand Down

0 comments on commit 5ac6067

Please sign in to comment.