I'm trying to get a better idea of what happens when calling estimateSizeFactors with a type of "poscounts". I assumed from the help description that Geometric mean would still be used after the modified zero-handling. However, I found the source code below that I think is calculating the Arithmetic mean after zero-handling. I may have looked at the wrong source code however. Can you please verify that Geometric mean is still used?
On a related note, when using the default type of "ratio" instead - what library is the rowMeans () function coming from?
Found this in DESeq2/methods.R in function estimateSizeFactorsForMatrix:
if (type == "poscounts") {
geoMeanNZ <- function(x) {
if (all(x == 0)) { 0 } else { exp( sum(log(x[x > 0])) / length(x) ) }
}
geoMeans <- apply(counts(object), 1, geoMeanNZ)
From help: The "poscounts" estimator deals with a gene with some zeros, by calculating a modified geometric mean by taking the n-th root of the product of the non-zero counts.
Thank you, Phillipe Loher
Thank you for the fast reply. Yes you are indeed correct, I forgot you can replace the nth-root calculations by logging first. Thanks for the sanity check.