ArtPoon / iupmBayes

Bayesian estimation of infectious units per million (IUPM) from viral outgrowth assay-based sequence data
GNU Affero General Public License v3.0
0 stars 0 forks source link

Default parameter settings fail #3

Open RouxCil opened 4 years ago

RouxCil commented 4 years ago

When running the Metropolis-Hastings sampling the code fails with the following error:

Error in mh(data, max.steps = 1e+05, skip.console = 1000, skip.log = 100) : (list) object cannot be coerced to type 'integer'

The issue is in determining the number of variants per region here:

m <- lapply(data, function(sub) ncol(sub$wells)) and, regions <- names(m)

The first level of this list is the Patient ID so above code returns NULL.

Fixing code to:

m <- lapply(data[[1]], function(sub) ncol(sub$wells))

RouxCil commented 4 years ago

Similar issue in the log-likelihood function LL:

Error in 1:nrow(rdat$wells) : argument of length 0

The code causing the issue:

res <- sapply(1:length(data), function(i) { region <- names(data)[i] rdat <- data[[region]]

Changed to:

res <- sapply(1:length(data[[1]]), function(i) { region <- names(data[[1]])[i] rdat <- data[[1]][[region]]