Error with the Geometric Bayesian multiplicative replacement of count zeros with "cmultRepl" I'm new with the treatment of compositional data and I'm working with a microbiome dataset which contains 107 observations and 3246 variables.
I'm trying to use the cmultRepl function of the zCompositions package in R to impute zeros in the dataset.
There are no missing values in the dataset and all columns contain at least one non-zero data.
I tried using the function with the default settings and I get this error:
zcomp <- cmultRepl(data_dist)

Error in if (any(X2[i, z] > colmins[z])) { : 
  missing value where TRUE/FALSE needed

I tried using the Bayes-Laplace method instead and it worked well.
zcomp <- cmultRepl(data_dist, method = "BL")

No. corrected values:  9227

Does anyone know why I get an error with the Geometric Bayesian multiplicative (default) method, but not with the Bayes-Laplace method?
Here is my dataset : https://drive.google.com/open?id=1awS9xew241JsPABUc4NH9sY-YW2-_a23
 A: The issue is that there are columns/variables (actually many) containing only 1 positive count across the 107 samples. The default GBM method does not work in this case because there is not enough information in those variables to compute the hyper-parameters involved. E.g. variable #339 is all zeros but for sample #23. The other methods use different formulas that are not affected by this.
Beyond the technical issue, it might be worth considering if these variables are actually providing any relevant information for the data analysis.
You can check columns containing only 1 non-zero count using e.g. the following raw lines:
# Check columns with only 1 non-zero in the given data set.
checkNumZerosCol <- apply(data_dist,2,function(x) sum(x==0))
cases <- which(checkNumZerosCol == (nrow(data_dist) - 1))
length(cases) # 1797 columns are all zeros but one positive value
zcomp <- cmultRepl(data_dist[,-cases]) # GBM imputation without them works

I have edited the cmultRepl function to produce an error when GBM is used in this case, and also a general warning to the user when the proportion of zeros in a variables exceeds a threshold set by the user. This revised version will be available with the next release of zCompositions on CRAN in the next weeks.
Thanks!
