CytoNorm
CytoNorm copied to clipboard
Error in rep(NA, (width - length(x))) : invalid 'times' argument
Hi, I am having a problem running testCV. After running prepareFlowSOM on my reference samples I try to run testCV but get the error in the title.
I believe the error originates from this line: https://github.com/saeyslab/CytoNorm/blob/ab58f29f29812a9f0b0bc721787c41cf2b75426e/R/evaluation.R#L211 Perhaps because length(x)>width.
I think the error might be caused by the default value of cluster_values parameter in testCV. If cluster_values is set to a cluster that doesn't exist (for example through using the default parameter) the error seems to occur. Perhaps an error message could be displayed if cluster_values is set to a nonexistent cluster?
@SansMorel I came up with the same error. After pulling the function apart, the first problem comes up in this part of testCV
, at the end of the function:
res <- named.list(pctgs, cvs, meta_cl) if(plot){ PlotOverviewCV(fsom, res) }
and specifically: PlotOverviewCV(fsom, res)
returns:
Error in rep(NA, (width - length(x))) : invalid 'times' argument
So the issues is in the PlotOverviewCV
function, which is defined just below it. The issue comes up here:
cv_matrix <- do.call(rbind, lapply(cvs[as.character(cluster_values)], function (x) { c(x, rep(NA, (width - length(x)))) }))
So yes, it carries the cluster_values
value the whole way through to that point. If you change it fro c(5, 10, 15)
to c(5, 10)
then it works fine.
@SansMorel @tomashhurst I just pushed a fix for this issue, thanks for pointing it out and figuring out where it went wrong! Let me know if you still run into any related problems.