-
Notifications
You must be signed in to change notification settings - Fork 922
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect/Inconsistent Fold Change Calculation #6654
Comments
Is this the reason for the discrepancy between the fold change calculated in FoldChange and FindMarkers? Is there a recommendation on how to proceed? |
@nathanhaigh, thank you for the explanation.
I found the code above within the |
@coralzhang just tagging these other issues...in case they are related: #6701, #6773 and #6976 |
@nathanhaigh @coralzhang @lucygarner @longmanz |
Thanks for the bug report @nathanhaigh and thanks everyone for the patience. The fix for this and related issues is in the develop branch. You should be able to pull latest changes from the develop branch: remotes::install_github("satijalab/seurat", ref="develop") Please feel free to create a new issue if you still notice issues. |
@saketkc I don't think the recent commits on the
For return(log(x = rowMeans(x = expm1(x = x)) + pseudocount.use, base = base)) They should be changed so the log transform is done before taking the means: return(rowMeans(log(expm1(x = x) + pseudocount.use, base = base))) |
I think the fold changes are being calculated incorrectly in most places but not all. In essence, the log of the means is calculated instead of the mean of the logs. Or at least there is inconsistency in the way it is calculated.
In several places in the
FoldChange()
methods you have things like this:This shows the means are calculated on the non log-transformed data and then the mean values are subsequently logged. The means should be taken on the log-transformed data. The code in
FoldChange.default()
seems to do this correctly since the fold change is calculated by subtracting the mean expression of one group from another. That would only make sense if those values were already log-transformed otherwise I'd expect a division:The consequence of calculating means before the log-transformation is that fold changes will be systematically over-estimated. For example, see: https://rpubs.com/hrlai/meanlog_logmean
The text was updated successfully, but these errors were encountered: