2
$\begingroup$

Sorry I just got totally confused conceptually.

If this is my raw count data

Likely, Seurat divides each value by sum of the column afterward times by 10000.

which gives so

                   s1.1        s1.2 s1.3       s1.4 s1.5
DDB_G0267178 0.00000000 0.009263254    0 0.01286397    0
DDB_G0267180 0.00000000 0.000000000    0 0.00000000    0
DDB_G0267182 0.00000000 0.000000000    0 0.03810585    0
DDB_G0267184 0.00000000 0.000000000    0 0.00000000    0
DDB_G0267188 0.02640801 0.000000000    0 0.01286397    0

Literally Seurat claims that final step would be taking natural log of the above matrix as I tested with

library(seurat)
mat <- matrix(data = rbinom(n = 25, size = 5, prob = 0.2), nrow = 5)
mat

    [,1] [,2] [,3] [,4] [,5]
[1,]    1    0    1    1    1
[2,]    1    0    2    2    3
[3,]    1    1    1    1    2
[4,]    1    1    0    1    0
[5,]    0    0    0    1    3
mat_norm <- LogNormalize(data = mat)
mat_norm
[1,] 7.824446 .        7.824446 7.419181 7.014015
[2,] 7.824446 .        8.517393 8.112028 8.112028
[3,] 7.824446 8.517393 7.824446 7.419181 7.706713
[4,] 7.824446 8.517393 .        7.419181 .       
[5,] .        .        .        7.419181 8.112028

My confusion is: seurat@data dose not give me natural log transformed data rather returns only data divided by column sum and scalled by 10000. So when plotting a violin plot if data are log normalised plot should not look as below picture

When I used

VlnPlot(object = y, features.plot = "DDB_G0277853", x.lab.rot = FALSE, y.log = TRUE)

plot changed totally. Could someone please help me in getting idea about seurat@data that is not really log transformed and by which data violin plot is being produced??? So if a gene has 10000 read counts, without log transformation violin plot should be so

This is my seurat object

$\endgroup$
2
$\begingroup$

The normalized and log-transformed values are used for the violin plot. The argument y.log changes only the display of the data (scaling of the y axis).

Seurat has very good documentation. Section 7 in the FAQ explains what data is stored in the object:

  1. How is data stored within the Seurat object? What is the difference between raw.data, data, and scale.data?

raw.data The raw data slot (object@raw.data) represents the original expression matrix, input when creating the Seurat object, and prior to any preprocessing by Seurat.

data The data slot (object@data) stores normalized and log-transformed single cell expression. This maintains the relative abundance levels of all genes, and contains only zeros or positive values. See ?NormalizeData for more information. This data is used for visualizations, such as violin and feature plots, most differential expression tests, finding high-variance genes, and as input to ScaleData (see below).

scale.data The scale.data slot (object@scale.data) represents a cell’s relative expression of each gene, in comparison to all other cells. Therefore this matrix contains both positive and negative values. See ?ScaleData for more information.

$\endgroup$
  • $\begingroup$ Thank you, you are definitely alright. The problem is; when I am normalising values for some genes and compare them with output of seurat@data, some genes are ok, but some genes seems to be without log normalisation and all stored in seurat@data. I guess maybe after calling by 10000, only some especial range of expression values go through the log normalisation, for example seurat@data gives me 0.0026 for a gene in a cell, when I calculated by pen, I noticed this value is just deciding the raw count on column sum multiply by 10000. Please correct me if I am wrong $\endgroup$ – Angel Jun 23 '18 at 16:54
  • 1
    $\begingroup$ In your first example, the last row does not match: DDB_G0267186 vs DDB_G0267188. Note that object@raw.data contains all cells, meanwhile object@data contains only the filtered cells. That might explain the difference. $\endgroup$ – Peter Jun 24 '18 at 12:52
  • $\begingroup$ @FereshTeh look for comparison at the formula Seurat uses: log1p(value/colSums[cell-idx] *scale_factor) (note the implicit +1 and logn in the formula) $\endgroup$ – Tapper Mar 18 at 18:50
2
$\begingroup$

Those two graphs don't look radically different. The y axis is definitely not log scaled on the top one, and it looks like it is scaled in the second one (y.log = TRUE)

$\endgroup$
  • $\begingroup$ Sorry, what you think about logNormalize function in Seurat that does not return log transformed data? $\endgroup$ – Angel Jun 23 '18 at 12:40
  • $\begingroup$ Sorry, for instance, for gene 1 in cell 1 I have 1040 RAW read counts. the sum of raw read counts in cell 1 for all genes is 373762. Based on the seurat documentation for normalisation, I should do so; ln ( 1040/373762 * 10000) that gives me 3.6 that is right. So in top violin plot for this gene seurat has used the natural log transformed data as stated and in seconds violin plot I am just taking another log of y axis. But question is: why seurat@data does not return values as I expect and I called for one gene rather give me only scaled data by 10000. could you help me? $\endgroup$ – Angel Jun 23 '18 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.