The bioBakery help forum

Log transformation pseudo-count

Does Maaslin2 add a pseduo-count prior to log transformation? I am using relative proportions as inputs, hence I set normalisation to “NONE”, but Maaslin2 throws an error saying that NaNs are produced due to zeros being encountered during the default log transform

Hi @adityabandla!

Thanks for the questions. Yes, the default log transformation incorporated into MaAsLin does add a pseudo-count. As is best-known practice currently, the pseudo-count is half the minimum feature. It does it with the following code:

LOG <- function(x) {
    y <- replace(x, x == 0, min(x[x>0]) / 2)
    return(log2(y))
}

The first thing I would check is for features that have community-level zero abundance, which would throw the error that you are describing. Either doing this on a case by case basis or applying an abundance and prevalence filter are easy solutions for this type of issue. If that is not the case for your data, can you send a minimally reproducible example of data that replicates this error?

Let me know if this helps!
Best,
Kelsey