gagneurlab/OUTRIDER

make normalized counts independent of subsetting

Closed this issue · 1 comments

When computing the normalized counts for the results table or for plotting, we subset to early so that for the calculation of the mean only the outliers are considered. This gives wrong values in the results table when all = FALSE.

The problem is also that the user can subset any time. So we do not have full control over this within the package. One way is that we save those values within the object instead of computing it on the fly each time.

# in normalizationFactors<- function
mcols(ods)[["expectedLogGeomMean"]] <- exp(means(log(pmax(normalizationFactors(ods), minE))))

# count function use cached expected log geom mean values
return(cnts/pmax(normalizationFactors(ods), minE) * mcols(ods)[["expectedLogGeomMean"]])

and use them in the count function. This can be computed each time the normalizationFactors do change. So we can have a hook in the normalizationFactors<- function.

This problem is also present in FRASER.

Any comments on this? @brechtmann @ischeller

I would replace this t(apply(normalizationFactors(object), 1, pmax, minE) by pmax(normalizationFactors(ods), minE) as it is the same.