'DESeq Error: Some values in assay are negative

I am running a DESeq analysis through importing counts from FeatureCounts. I generate the counts matrix but when I get to running the DESeqMatrixFromDataSet, I get the following error. I have checked my counts several times and I don't see any negative results.

I will appreciate any help with this.

    library(purrr)
    library(tidyverse)
    f_files<- list.files("C:/Users/cash/Desktop/DESeq analysis 2", pattern = "\\.txt$", full.names = T)
    
    read_in_feature_counts<- function(file){
      cnt<- read_tsv(file, col_names =T, comment = "#")
      cnt<- cnt %>% dplyr::select(-Chr, -Start, -End, -Strand, -Length)
      return(cnt)
    }
    
    raw_counts<- map(f_files, read_in_feature_counts)
    raw_counts_df<- purrr::reduce(raw_counts, inner_join) 
    head(raw_counts_df)
    
    # Assign condition (first four are controls, second four contain the expansion)
    condition <- factor(c("Donor1-1_S1_R2_001", "Donor1-2_S2_R2_001", "Donor2-1_S10_R2_001", "Donor2-2_S11_R2_001","Donor3-1_S1_R2_001", "Donor3-2_S2_R2_001", "Donor4-1_S10_R2_001", "Donor4-2_S11_R2_001"))
    
    library(DESeq2)
    
    # Create a coldata frame and instantiate the DESeqDataSet. See ?DESeqDataSetFromMatrix
    coldata <- data.frame(row.names=colnames(raw_counts_df))
    
    
    dds <- DESeqDataSetFromMatrix(countData=raw_counts_df, colData=coldata, design=~condition)
    
    **Error in DESeqDataSet(se, design = design, ignoreRank) : 
      some values in assay are negative**

Here is the new error:

> dds <- DESeqDataSetFromMatrix(countData=raw_counts_df, colData=coldata, design=~condition)
converting counts to integer mode
Error in DESeqDataSet(se, design = design, ignoreRank) : 
  all variables in design formula must be columns in colData
r


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source