CytoNorm icon indicating copy to clipboard operation
CytoNorm copied to clipboard

Error in rep(NA, (width - length(x))) : invalid 'times' argument

Open SansMorel opened this issue 5 years ago • 4 comments

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.

SansMorel avatar Nov 05 '19 14:11 SansMorel

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 avatar Nov 05 '19 14:11 SansMorel

@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)))) }))

tomashhurst avatar Nov 22 '19 03:11 tomashhurst

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.

tomashhurst avatar Nov 22 '19 04:11 tomashhurst

@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.

SofieVG avatar Nov 22 '19 09:11 SofieVG