sctransform icon indicating copy to clipboard operation
sctransform copied to clipboard

Question: Is it possible to reverse the scaling done by vst()?

Open TeodoraTockovska opened this issue 2 years ago • 4 comments

I understand that vst() performs normalization, transformation, and scaling as it replaces a few functions in the Seurat workflow for normalizing data. Is it possible to reverse the scaling?

TeodoraTockovska avatar Jan 06 '22 18:01 TeodoraTockovska

Hi @TeodoraTockovska, while in principle you can reverse the regression model, there are caveats. Can you elaborate on your use case?

saketkc avatar Jan 07 '22 17:01 saketkc

Hi @saketkc, thanks for getting back to me.

I am trying to compare normalization techniques using Single Cell Overview of Normalized Expression (SCONE, R package tool) in which the user provides normalization functions (without scaling) such that the SCONE algorithm can run several metrics to assess the qualities of normalization. The user-defined functions are required to only normalize expression data as SCONE performs its own scaling.

I ran into errors when I tried to create a user-defined function using vst() so I was wondering if it is possible to reverse the scaling so that I can incorporate it into the SCONE algorithm.

TeodoraTockovska avatar Jan 07 '22 18:01 TeodoraTockovska

I see. The pearson residuals that are returned are not scaled, so you should be able to use them as it is, unless I ams misunderstanding the interpretation of scaling here.

saketkc avatar Jan 07 '22 19:01 saketkc

I see. The pearson residuals that are returned are not scaled, so you should be able to use them as it is, unless I ams misunderstanding the interpretation of scaling here.

Hm, that is interesting. I will investigate this more to try to figure out the issue. Just in case you need it, below, I provided some extra information on the function and the errors.

The user-defined function is simple:

SCT_VST_FN <- function(expression_data){
  return(sctransform::vst(expression_data)$y)
}

This is the error I get when running SCONE using SCT_VST_FN(). I believe it is due to the scaling on the normalized matrix. I don't receive this error from any other method that I use. I don't receive this error when running SCT_VST_FN() on my expression data outside of SCONE.

Error: BiocParallel errors
  element index: 2, 3, 4, 5, 6
  first error: NA/Inf/NaN Expression Values.

TeodoraTockovska avatar Jan 07 '22 19:01 TeodoraTockovska