scRNAseq analysis with logNormCounts (scran/scuttle package) - log transformation with different log base?
1
0
Entering edit mode
5 months ago
joker33 ▴ 60

Hi,

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 https://github.com/LTLA/scuttle/issues/12

scran log logNormCounts scuttle scRNAseq • 519 views
2
Entering edit mode
5 months ago
ATpoint 55k

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 support.bioconductor.org 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.

0
Entering edit mode

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?

1
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.