How to solve Error in DESeqDataSetFromMatrix

75 Views Asked by At

I am trying to run Differential Gene Expression analisys on my RNAseq dataset. I am relatively new to it and now using DESeq2. When I try to run DESeqDataSetFromMatrix I get the following error:

Error in DESeqDataSet(se, design = design, ignoreRank) : 
  counts matrix should be numeric, currently it has mode: logical

This is the code I am using:

Count <- read_excel("ReadS_Count_Final_CTRL_XS_SXM.xlsx")
View(Count)
head(Count)

Count$CTRL <- as.numeric(Count$CTRL)
Count$XS <- as.numeric(Count$XS)
Count$SXM <- as.numeric(Count$SXM)
Count$VDAG_ID <- as.numeric(Count$VDAG_ID)

#To Filter IDs with reads count lower than 5
Count <- Count[which(rowSums(Count)> 5),]

condition <- factor(c("VDAG", "C", "X", "S"))

coldata <- data.frame(row.names = colnames(Count), condition)

dds <- DESeqDataSetFromMatrix(countData = Count, 
                              colData = coldata,
                              design = ~condition)

Any help is greatly appreciated. Thank you!

1

There are 1 best solutions below

0
Mohamad Hashemian On

The error message suggests that the counts matrix input to the Matrix function is in logical format instead of numeric format. To fix this issue, you can try converting the count matrix from logical to numeric using the as.numeric() function as you have done with the individual columns:

enter code here

# Convert the count matrix to numeric
Count <- as.matrix(Count)
Count <- as.numeric(Count)

# Continue with the rest of the code...