Skip to content

Commit

Permalink
attempt to rewrite ref$df from counts_log_correction namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
mauromiguelm committed Apr 26, 2024
1 parent e56f931 commit 3191039
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions components/board.upload/R/upload_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ UploadBoard <- function(id,
},
{
## get uploaded counts
check <- NULL
df0 <- uploaded$counts.csv
if (is.null(df0)) {
return(list(status = "Missing counts.csv", matrix = NULL))
Expand All @@ -240,11 +241,14 @@ UploadBoard <- function(id,
write_check_output(res$checks, "COUNTS", raw_dir())

# check if error 29 exists (log2 transform detected), give action to user revert to intensities or skip correction
counts_log_correction <- function() {
counts_log_correction <- function(res) {
if (input$logCorrectCounts) {
res$df <- 2**res$df
if(min(res$df,na.rm=TRUE) > 0) res$df <- res$df - 1
res$df <<- 2**res$df
if(min(res$df,na.rm=TRUE) > 0) res$df <<- res$df - 1
}
# store check and data regardless of it errors (after counts log correction if user accepts it)
write.csv(res$df, file.path(OPG, "user_counts_log_corrected.csv"), row.names = TRUE)
checked <<- res$df
}

if ("e29" %in% names(res$checks)) {
Expand All @@ -259,10 +263,13 @@ UploadBoard <- function(id,
immediate = TRUE,
callbackR = counts_log_correction
)
} else {
checked <- res$df
}

# store check and data regardless of it errors (after counts log correction if user accepts it)
checked <- res$df
# R continues execution after shinyalert, so we need to check if checked is defined.
browser()
req(exists("check"), check)

checklist[["counts.csv"]]$checks <- res$checks
if (res$PASS) {
Expand Down

0 comments on commit 3191039

Please sign in to comment.