Skip to content

Commit

Permalink
Check for NAs during parameter estimation
Browse files Browse the repository at this point in the history
Avoids errors when running copy number estimation:
```
titan: Parameter estimation
Optimal state path computation: Using 8 cores.
Error in if (objfun[maxFind] >= objfun[i]) { :
  missing value where TRUE/FALSE needed
Calls: outputTitanResults ... runEMclonalCN -> estimateClonalCNParamsMap -> updateParameters
```
I couldn't determine the underlying source of NAs when reading the code but
put in defensive checks which avoids the issue.
  • Loading branch information
chapmanb committed Dec 2, 2018
1 parent 60408ca commit b881b1f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions R/paramEstimation.R
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,15 @@ updateParameters <- function(n_0, s_0, var_0, varR_0, phi_0, corRho_0, chrPos_0,
var_prev <- var
varR_prev <- varR
phi_prev <- phi

if (objfun[maxFind] >= objfun[i]) {

if (is.na(objfun[maxFind]) || is.na(objfun[i])) {
} else if (objfun[maxFind] >= objfun[i]) {
#if (verbose)
#message("Coordinate descent decreases likelihood.")
} else {
} else {
maxFind <- i
}
if ((abs(objfun[i] - objfun[i - 1])/abs(objfun[i])) <= 0.001) {
if (!is.na(objfun[i]) && (abs(objfun[i] - objfun[i - 1])/abs(objfun[i])) <= 0.001) {
converged <- 1
}
}
Expand Down

0 comments on commit b881b1f

Please sign in to comment.