-
Notifications
You must be signed in to change notification settings - Fork 928
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
Transform the residuals from RegressOutNBreg()? #539
Comments
While RegressOutNBreg() takes raw values as input, it outputs Pearson residuals, like you said. By definition this accounts for the expected variance and the result has (approximately) mean 0 and variance 1. The Pearson residuals thus have a meaning: the number of standard deviations that an observed value (UMI count) is above or below the expected value given the model. We only expect to see significant deviation from that model if 1) a gene is highly variable and this variability is driven by a factor that was not regressed out (e.g. a cell population marker), or 2) the NB model does not fit the data at all (not the case for the UMI data we have looked at so far). So, under the NB model there is no need to perform additional transformation. |
Thanks! As far as I understand, there are 3 types of relevant situations:
The distribution of Pearson residuals for GLM is usually not normal but skewed, even though it's zero-mean and unit-variance. This is because the scaling does not change the overall shape of the distribution. In situations (2) and especially (3), for genes with interesting biological variations, we are left with large biological residuals, and their distributions should have similar shapes as raw counts. Using pearson residual for downstream analysis would be similar as using (raw_counts - mean)/std where raw_counts have been previously adjusted for technical variations.
This is true as discussed above. But in for these genes, should we use the long-tailed pearson residuals? |
Deviance residuals of negative binomial are much less skewed, although I'm not sure how to properly interpret it. |
Thanks for the interesting and well-thought out questions. We choose not to scale these residuals because, as you say, this means that genes with 'biological' effects will have higher variance. Therefore they will contribute more to the PCA. We think this is a positive feature, and will drive the dimensional reduction to capture primarily biological effects. This will down-weight the effect of genes whose variance is primarily explained by sequencing depth. Again, we think this is a positive feature, but there may be cases where that is undesirable. You can certainly transform the pearson residuals on your own, prior to performing PCA. If you do experiment with this, we'd be curious to see the results. |
Equality thresholds in FindMarkers
Hi,
The internal
RegressOutNBreg()
function writes the (pearson) residuals to the @scale.data slot. Since it uses raw counts as input, shouldn't the residuals still have very skewed distributions with long tails? Before doing the scaling and PCA step, is it a good idea to transform the residuals to more normally distributed?In the
RegressOutResid()
function, there is the log(x-min) transform for poisson and negbinom regression:But this part is missing in
RegressOutNBreg()
. Is there a reason behind not doing the transform? Thanks!The text was updated successfully, but these errors were encountered: