scRNAseq analysis with logNormCounts (scran/scuttle package) - log transformation with different log base?
Entering edit mode
15 months ago
joker33 ▴ 70


I am using scran / scuttle for scRNAseq normalization.

clusters <- scran::quickCluster(sce)
sce <- scran::computeSumFactors(sce, cluster = clusters)
sce <- scuttle::logNormCounts(sce)

As far as I could find out, this code will log2 transform data. I was wondering if there is any option to specify log transformation to another log base, particularly natural log?

Or would it be possible to reverse log2 transformation after the normalization and then manually transform to natural log?

Thank you very much in advance!

PS: Cross posted on

scran log logNormCounts scuttle scRNAseq • 1.3k views
Entering edit mode
15 months ago
ATpoint 65k

Sure, technically it is possible by using log=FALSE and then transform the normalized counts using any method you want. See ?scuttle::logNormCounts on log option.

By the way, GitHub issues are mainly for bug reports and feature requests, maybe consider to ask in a forum first, and not opening issues, at least not right away. Just a suggestion. For technical questions that require the package developers expertise the support forum at is a good place to ask.

Edit: I quote here the answer from Aaron Lun from the GitHub issue:

Internally, if pseudo.count=1, the logNormCounts() function will use log1p. This has the advantage of preserving sparsity compared to the naive log(x + 1) method, which goes through a non-sparse intermediate x + 1. For all other settings of pseudo.count, we go through the usual log(x + pseudo.count), because we're going to lose sparsity anyway.

Now, log(x + 1) is a natural log, so we divide the result by log(2) to obtain log2-transformed values. One could just as easily undo that division outside of the function, or change the base as desired. It's just a division so it's pretty cheap.

Entering edit mode

Thanks for your prompt response!

So if I set log=FALSE, the code would normalize the data but not log-transform, yet. Then I can log-transform it manually afterwards? Is that correct?

And thanks for your advice regarding GitHub!

Entering edit mode

Yes, that is my understanding of the function.

It uses the either the size factors from the deconvolution method (computeSumFactors) if these are present in the SingleCellExperiment or (if not present) then normalizes based on library size alone. In any case, this normalization is done first, and then the log transformation is being applied if log=TRUE.


Login before adding your answer.

Traffic: 1892 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6