satijalab / sctransform

R package for modeling single cell UMI expression data using regularized negative binomial regression
GNU General Public License v3.0
206 stars 33 forks source link

NMF on residuals #45

Closed cnk113 closed 4 years ago

cnk113 commented 4 years ago

Hello,

I'm trying to do NMF on the residuals but to get non negative values I would either need to have to square the values or take the absolute value. Do you have any inclination on what might be better in capturing the structure better?

Thanks

ChristophH commented 4 years ago

Hi,

negative residuals show that the observed counts are lower than expected given the NB regression model. It wouldn't make sense to force them to be positive. If you require strictly non-negative values, have a look at the sctransform::correct() function - by default it outputs non-negative integers. You can also have the sctransform::vst function return corrected counts by passing return_corrected_umi = TRUE; the corrected counts are named umi_corrected in the output list.

Best, Christoph

minigel commented 4 years ago

Hello,

I am also interested in using the residuals for downstream analyses, but require non-negative values for NMF. Would the umi_corrected counts produce figures similar to those shown in your paper for scaled Pearson residuals (e.g. Figures 3 and 6)?

Thank you!

ChristophH commented 4 years ago

'umi_corrected' are on the scale of the original counts but corrected for the effect of sequencing depth differences. The correction results in non-integer values in some cases negative values, but by default negative values are set to 0 and all values are rounded to integers.

minigel commented 4 years ago

Great, thank you!