Answers.Body: <p>Answered at biostars: <a href="https://www.biostars.org/p/9561238/#9561240" rel="nofollow noreferrer">https://www.biostars.org/p/9561238/#9561240</a></p>
  <blockquote>
  <p>DESeq2 is meant for digital counts (RNA-seq and similar assays). Arrays are not supported, nor is the implemented method meaningful for array intensity values.</p>
  <p>Guides on how to handle these data are probably in here:</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-04-20T13:22:53.823Z
Answers.Text: Thanks for linking to the other answer, but when you do so, please also reproduce the answer here so that it will not depend on the external link not breaking.
Answers.UserDisplayName: terdon
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-04-20T11:07:26.637Z
Answers.LastActivityDate: 2023-04-20T20:40:25.893Z
Answers.LastEditDate: 2023-04-20T20:40:25.893Z
Answers.UserDisplayName: ATpoint
Body: <p><em>This question was also asked on <a href="https://www.biostars.org/p/9561238" rel="nofollow noreferrer">Biostars</a></em></p>
  <p>I am trying to download and analyze a miRNA expression dataset from NCBI GEO <code>(GSE25631)</code>. I specifically want non-normalized data to perform normalization and my own set of other analyses later on. Accordingly, I downloaded the <code>Series Matrix File</code> (to match the Sample IDs with their phenotype) and the non-normalized data <code>GSE25631_non-normalized_data.txt.gz</code> programmatically using the <code>GEOquery</code> package in R. To normalize the data I'm using the <code>DESeq2</code> package. When I run the <code>DESeqDataSetFromMatrix</code> function I get this error:</p>
  <blockquote>
  <p>Error in DESeqDataSet(se, design = design, ignoreRank) :
  some values in assay are negative</p>
  </blockquote>
  <p>I went back to the non-normalized data and observed that there are a lot of negative values. I need suggestions on how to deal with this issue. Should I replace all such values with NA? I also observed that every probe has a detection p-value associated with it. Should I also filter out the expression values which have a p-value higher than 0.05?</p>
  <pre><code>&gt; head(raw_counts)
          gbm-0001 Detection Pval gbm-0011 Detection Pval gbm-0013 Detection Pval gbm-0024 Detection Pval gbm-0058 Detection Pval
          ILMN_3167304   27.875      0.3071961 -24.9375      0.6689599    14.25       0.350027   4.3125      0.4723163     8.25      0.3966338
          ILMN_3168038  211.875       6.42E-05   1.0625      0.4925717    99.25    0.003645935  60.3125      0.1657064    72.25     0.01086376
          ILMN_3167890 13839.88       3.68E-38 23507.06       3.68E-38 22345.25       3.68E-38 20482.31       3.68E-38 21419.25       3.68E-38
          ILMN_3167526    5.875      0.4577177 105.0625     0.03279042     8.25      0.4117529 -29.6875       0.683706    11.25      0.3604082
          ILMN_3167209   82.875     0.06708142 182.0625      0.0007096    60.25     0.05167192   9.3125      0.4403947    72.25     0.01086376
  </code></pre>
  <p>Here's the R script which I used for all the mentioned steps.</p>
  <pre><code>library(GEOquery)
  library(DESeq2)
  library(tidyverse)
  
  
  data &lt;- getGEO(GEO = &quot;GSE25631&quot;, 
             destdir = &quot;E:\\GSE25631&quot;,
             GSEMatrix = TRUE,
             AnnotGPL = FALSE,
             getGPL = FALSE,
             parseCharacteristics = TRUE)
  
  clindata &lt;- data$GSE25631_series_matrix.txt.gz@phenoData@data
  
  url = &quot;https://www.ncbi.nlm.nih.gov/geo/download/? 
  acc=GSE25631&amp;format=file&amp;file=GSE25631%5Fnon%2Dnormalized%5Fdata%2Etxt%2Egz&quot;
  download.file(url, &quot;E:\\GSE25631\\GSE25631_raw_counts.gz&quot;)
  raw_counts &lt;-read.delim(&quot;E:\\GSE25631\\GSE25631_raw_counts.gz&quot;, 
                       stringsAsFactors = FALSE, sep = &quot;\t&quot;)
  colnames(raw_counts) &lt;- raw_counts[5,]
  raw_counts &lt;- raw_counts[-(1:5),]
  raw_counts &lt;- raw_counts %&gt;% remove_rownames %&gt;% column_to_rownames(var = &quot;ID_REF&quot;)
  raw_counts &lt;- raw_counts[ , c(TRUE, FALSE)]
  
  
  colnames(raw_counts) &lt;- clindata<span class="math-container">$title
  rownames(clindata) &lt;- clindata$</span>title
  colnames(clindata)[colnames(clindata) == &quot;disease state:ch1&quot;] &lt;- &quot;Condition&quot;
  clindata<span class="math-container">$Condition[clindata$</span>Condition == &quot;primary glioblastoma multiform (brain tumor)&quot;] &lt;- &quot;GBM&quot;
  clindata<span class="math-container">$Condition[clindata$</span>Condition == &quot;normal&quot;] &lt;- &quot;Normal&quot;
  clindata<span class="math-container">$Condition &lt;- as.factor(clindata$</span>Condition)
  
  dds &lt;- DESeqDataSetFromMatrix(countData = raw_counts,
                            colData = clindata,
                            design = ~ Condition)
  </code></pre>
  
Tags: <deseq2><normalization><microarray><geoquery><geo>
Title: DESeq2 throwing error while normalizing raw microarray expression data due to presence of negative values
ThreadText: # DESeq2 throwing error while normalizing raw microarray expression data due to presence of negative values
  
  (Asked by: username_0 on 2023-04-20)
  
  *This question was also asked on [Biostars](https://www.biostars.org/p/9561238)*
  
  I am trying to download and analyze a miRNA expression dataset from NCBI GEO `(GSE25631)`. I specifically want non-normalized data to perform normalization and my own set of other analyses later on. Accordingly, I downloaded the `Series Matrix File` (to match the Sample IDs with their phenotype) and the non-normalized data `GSE25631_non-normalized_data.txt.gz` programmatically using the `GEOquery` package in R. To normalize the data I'm using the `DESeq2` package. When I run the `DESeqDataSetFromMatrix` function I get this error:
  
  > Error in DESeqDataSet(se, design = design, ignoreRank) :
  > some values in assay are negative
  
  I went back to the non-normalized data and observed that there are a lot of negative values. I need suggestions on how to deal with this issue. Should I replace all such values with NA? I also observed that every probe has a detection p-value associated with it. Should I also filter out the expression values which have a p-value higher than 0.05?
  
  ```
  > head(raw_counts)
          gbm-0001 Detection Pval gbm-0011 Detection Pval gbm-0013 Detection Pval gbm-0024 Detection Pval gbm-0058 Detection Pval
          ILMN_3167304   27.875      0.3071961 -24.9375      0.6689599    14.25       0.350027   4.3125      0.4723163     8.25      0.3966338
          ILMN_3168038  211.875       6.42E-05   1.0625      0.4925717    99.25    0.003645935  60.3125      0.1657064    72.25     0.01086376
          ILMN_3167890 13839.88       3.68E-38 23507.06       3.68E-38 22345.25       3.68E-38 20482.31       3.68E-38 21419.25       3.68E-38
          ILMN_3167526    5.875      0.4577177 105.0625     0.03279042     8.25      0.4117529 -29.6875       0.683706    11.25      0.3604082
          ILMN_3167209   82.875     0.06708142 182.0625      0.0007096    60.25     0.05167192   9.3125      0.4403947    72.25     0.01086376
  
  ```
  
  Here's the R script which I used for all the mentioned steps.
  
  ```
  library(GEOquery)
  library(DESeq2)
  library(tidyverse)
  
  data <- getGEO(GEO = "GSE25631", 
             destdir = "E:\\GSE25631",
             GSEMatrix = TRUE,
             AnnotGPL = FALSE,
             getGPL = FALSE,
             parseCharacteristics = TRUE)
  
  clindata <- data$GSE25631_series_matrix.txt.gz@phenoData@data
  
  url = "https://www.ncbi.nlm.nih.gov/geo/download/? 
  acc=GSE25631&format=file&file=GSE25631%5Fnon%2Dnormalized%5Fdata%2Etxt%2Egz"
  download.file(url, "E:\\GSE25631\\GSE25631_raw_counts.gz")
  raw_counts <-read.delim("E:\\GSE25631\\GSE25631_raw_counts.gz", 
                       stringsAsFactors = FALSE, sep = "\t")
  colnames(raw_counts) <- raw_counts[5,]
  raw_counts <- raw_counts[-(1:5),]
  raw_counts <- raw_counts %>% remove_rownames %>% column_to_rownames(var = "ID_REF")
  raw_counts <- raw_counts[ , c(TRUE, FALSE)]
  
  colnames(raw_counts) <- clindata$title
  rownames(clindata) <- clindata$title
  colnames(clindata)[colnames(clindata) == "disease state:ch1"] <- "Condition"
  clindata$Condition[clindata$Condition == "primary glioblastoma multiform (brain tumor)"] <- "GBM"
  clindata$Condition[clindata$Condition == "normal"] <- "Normal"
  clindata$Condition <- as.factor(clindata$Condition)
  
  dds <- DESeqDataSetFromMatrix(countData = raw_counts,
                            colData = clindata,
                            design = ~ Condition)
  
  ```
  
  **Tags:** deseq2, normalization, microarray, geoquery, geo
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-04-20. Score: 2 | Accepted answer
  
  Answered at biostars: <https://www.biostars.org/p/9561238/#9561240>
  
  > DESeq2 is meant for digital counts (RNA-seq and similar assays). Arrays are not supported, nor is the implemented method meaningful for array intensity values.
  >
  > Guides on how to handle these data are probably in here:
  
  > **Comments:**
  > **username_2**: Thanks for linking to the other answer, but when you do so, please also reproduce the answer here so that it will not depend on the external link not breaking.  
  
  ---
  
  