Repository navigation
fix bug that caused inf estimates for Ri or Ci ranges #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -174,7 +174,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||
| #' x is a vector containing first the RiLog values and then the Ci values | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' (length 2*m if no Ci are fixed). | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' For the equality constraint (eqfun with corresponding bound eqB), the | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' For the equality constraint (eqfun with corresponding bound eqB), the | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' difference of the sum of the Ci values and 1 is calculated. The bound is set | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' to 0, i.e. forcing the sum of the Ci to be 1. In case of fixed Ci values, the | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' sum of the fixed and the free Ci values is considered. | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -460,8 +460,8 @@ | |||||||||||||||||||||||||||||||||||||||||||||||
| #' G <- graphs$sample1_sample2[[2]] | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' # small example with a small grid size | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' iterateOverCi(G, gridSize = 100) | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' @importFrom checkmate assertClass assertFlag assertIntegerish assertList | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' @importFrom checkmate assertClass assertFlag assertIntegerish assertList | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' assertNumeric checkTRUE | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' @importFrom igraph is_bipartite V | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' @importFrom pbapply pbmapply pboptions | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -524,12 +524,12 @@ iterateOverCi <- function(G, | |||||||||||||||||||||||||||||||||||||||||||||||
| #' The data.frame resulting from the | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' [bppg::iterateOverCi()] function, | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' filtered for a specific protein. | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' @param error_tol \strong{numeric(1)} \cr | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' @param error_tol \strong{numeric(1)} \cr | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' tolerance for the error term. | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' @param ratioLog_tol \strong{numeric(1)} \cr | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' @param ratioLog_tol \strong{numeric(1)} \cr | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' tolerance for the log protein ratios. | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' @returns Vector with minimal error, estimate for Ri (single value | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' @returns Vector with minimal error, estimate for Ri (single value | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' or min/max), estimate for Ci (single value or min/max). | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' | ||||||||||||||||||||||||||||||||||||||||||||||||
| .analyseResultSingleProt <- function(protNr, resProt, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -553,7 +553,7 @@ iterateOverCi <- function(G, | |||||||||||||||||||||||||||||||||||||||||||||||
| res_tmp <- c(mean(e_tmp), RLog_tmp_mean_rounded, NA, NA, NA, | ||||||||||||||||||||||||||||||||||||||||||||||||
| min(C_tmp), max(C_tmp), NA) | ||||||||||||||||||||||||||||||||||||||||||||||||
| # all(R[ind_min_tol] == 0) |??? | ||||||||||||||||||||||||||||||||||||||||||||||||
| res_tmp[8] <- ifelse(length(indMinError) == nrow(resProt), 1, 4) | ||||||||||||||||||||||||||||||||||||||||||||||||
| res_tmp[8] <- ifelse(length(indMinError) == nrow(resProt), 1, 4) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| # case 2 and 5: range solution for Rlog | ||||||||||||||||||||||||||||||||||||||||||||||||
| res_tmp <- c(mean(e_tmp), NA, min(RLog_tmp), max(RLog_tmp), NA, | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -604,7 +604,7 @@ iterateOverCi <- function(G, | |||||||||||||||||||||||||||||||||||||||||||||||
| #' Tolerance for a constant log2 protein | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' ratios. The default is 1e-6. | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' @return A SummarizedExperiment object with one row for each protein in the | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' @return A SummarizedExperiment object with one row for each protein in the | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' assay. | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' @export | ||||||||||||||||||||||||||||||||||||||||||||||||
| #' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -638,7 +638,18 @@ automatedAnalysisIteratedCi <- function(G, | |||||||||||||||||||||||||||||||||||||||||||||||
| job.id <- NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| f <- function(x, res, error_tol, ratioLog_tol, | ||||||||||||||||||||||||||||||||||||||||||||||||
| # filter res for potential NaNs in the error column (could occur if a Ci | ||||||||||||||||||||||||||||||||||||||||||||||||
| # is estimated as 0) | ||||||||||||||||||||||||||||||||||||||||||||||||
| ind_error_NA <- which(is.na(res$error)) | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (length(ind_error_NA) > 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| if (verbose) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| message(paste0(length(ind_error_NA), | ||||||||||||||||||||||||||||||||||||||||||||||||
| " grid points with NA or NaN error term were removed.")) | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| res <- res[-ind_error_NA,] | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
KarinSchork marked this conversation as resolved.
Outdated
|
||||||||||||||||||||||||||||||||||||||||||||||||
| # filter res for potential NaNs in the error column (could occur if a Ci | |
| # is estimated as 0) | |
| ind_error_NA <- which(is.na(res$error)) | |
| if (length(ind_error_NA) > 0) { | |
| if (verbose) { | |
| message(paste0(length(ind_error_NA), | |
| " grid points with NA or NaN error term were removed.")) | |
| } | |
| res <- res[-ind_error_NA,] | |
| } | |
| # filter res for non-finite values in the error column (NA, NaN, Inf, | |
| # -Inf; could occur if a Ci is estimated as 0) | |
| ind_error_non_finite <- which(!is.finite(res$error)) | |
| if (length(ind_error_non_finite) > 0) { | |
| if (verbose) { | |
| message(paste0(length(ind_error_non_finite), | |
| " grid points with non-finite error term were removed.")) | |
| } | |
| res <- res[-ind_error_non_finite,] | |
| } | |
| if (nrow(res) == 0) { | |
| stop("All grid points were removed because the error term was non-finite.") | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather like to keep the results instead of stopping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New behavior is introduced to drop grid points with non-usable error values before analysis; there are existing testthat snapshots for
automatedAnalysisIteratedCi(), but nothing here asserts correct handling whenres$errorcontainsNA/NaN/Inf. Please add a test case that injects non-finite errors into a smallresinput and verifies the function returns finite outputs (and behaves sensibly if all grid points are filtered).