This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Scaled gene expression data and produced negative value

Hi, I have a data table of gene expression which contains TPM value. So here I try to do a heatmap plot. So I scale by gene level at first and produce negative value. So why negative values comes up?

rna-seq gene r

Can you include your code here?

rowScales(data) - Very simple code.

That's not as simple as you claim - which package is rowScales from? Why are you using it instead of scale?

Why don't you share us the package name used in R? Tell us about the function rowScales

What kind of scaling have you done?

If it's log scale or zscore there will be negative values for values less than 1

1 answer

OP mentioned in one of the comments that he is using rowScales functions for scaling and has not mentioned the package, while we guess it might be from scrime package.

The reason for getting negative values is because rowScales scales the row in a way such that the values in each row would have zero mean and a standard deviation of 1, thus producing negative values. As the scaling is being done to plot heatmap, the other way would be to perform log2(TPM) transformation and plot a heatmap and incase there are TPM values less than zero then log2(TPM+1) can be done as for the purpose of the heatmap, it won’t make much difference.

I think you mean rowScales instead of rowSums function.

Thanks for pointing it out. Have made the modifications.

Log in to answer this question.