Answers.Body: <p>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)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-23T12:40:40.737Z
Answers.Text: Sorry, what you think about logNormalize function in Seurat that does not return log  transformed data?
Answers.UserDisplayName: Zizogolu
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-23T13:03:41.900Z
Answers.Text: 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?
Answers.UserDisplayName: Zizogolu
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-22T22:22:32.790Z
Answers.LastActivityDate: 2018-06-22T22:22:32.790Z
Answers.UserDisplayName: swbarnes2
Answers.Body: <p>The normalized and log-transformed values are used for the violin plot.
  The argument <code>y.log</code> changes only the display of the data (scaling of the y axis).</p>
  <p>Seurat has very good documentation. <a href="https://satijalab.org/seurat/faq" rel="nofollow noreferrer">Section 7 in the FAQ</a> explains what data is stored in the object:</p>
  <blockquote>
  <ol start="7">
  <li>How is data stored within the Seurat object? What is the difference between raw.data, data, and scale.data?</li>
  </ol>
  <p><strong>raw.data</strong> 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.</p>
  <p><strong>data</strong> 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).</p>
  <p><strong>scale.data</strong>
  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.</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-23T16:54:43.007Z
Answers.Text: 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
Answers.UserDisplayName: Zizogolu
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-24T12:52:29.933Z
Answers.Text: 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.
Answers.UserDisplayName: Peter
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-18T18:50:08.027Z
Answers.Text: @FereshTeh look for comparison at [the formula](https://github.com/satijalab/seurat/issues/185#issuecomment-338299619) Seurat uses: `log1p(value/colSums[cell-idx] *scale_factor)` (note the implicit _+1_ and _logn_ in the formula)
Answers.UserDisplayName: Tapper
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-06-23T16:45:21.043Z
Answers.LastActivityDate: 2018-06-23T16:45:21.043Z
Answers.LastEditDate: 2020-06-18T08:30:41.743Z
Answers.UserDisplayName: Peter
Body: <p>Sorry I just got totally confused conceptually.</p>
  
  <p>If this is my raw count data</p>
  
  <p>Likely, Seurat divides each value by sum of the column afterward times by 10000. </p>
  
  <p>which gives so </p>
  
  <pre><code>                   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
  </code></pre>
  
  <p>Literally Seurat claims that final step would be taking natural log of the above matrix as I tested with </p>
  
  <pre><code>library(seurat)
  mat &lt;- 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 &lt;- 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
  </code></pre>
  
  <p>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 </p>
  
  <p>When I used </p>
  
  <pre><code>VlnPlot(object = y, features.plot = "DDB_G0277853", x.lab.rot = FALSE, y.log = TRUE)
  </code></pre>
  
  <p>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</p>
  
  <p>This is my seurat object</p>
  
Tags: <r><scrnaseq><seurat><ggplot2>
Title: Which data is being used for violin plot?
ThreadText: # Which data is being used for violin plot?
  
  (Asked by: username_0 on 2018-06-22)
  
  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
  
  **Tags:** r, scrnaseq, seurat, ggplot2
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2018-06-23. Score: 2 | Accepted answer
  
  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](https://satijalab.org/seurat/faq) explains what data is stored in the object:
  
  > 7. 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.
  
  > **Comments:**
  > **username_0**: 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  
  > **username_2**: 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.  
  > **username_3**: @FereshTeh look for comparison at [the formula](https://github.com/satijalab/seurat/issues/185#issuecomment-338299619) Seurat uses: `log1p(value/colSums[cell-idx] *scale_factor)` (note the implicit _+1_ and _logn_ in the formula)  
  
  ---
  
  ### Answer by username_1 on 2018-06-22. Score: 2
  
  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)
  
  > **Comments:**
  > **username_0**: Sorry, what you think about logNormalize function in Seurat that does not return log  transformed data?  
  > **username_0**: 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?  
  
  ---
  
  