This is a test version of Biostars. For the public version, visit https://www.biostars.org.
DESeq2: DESeqDataSetFromMatrix Error

Everything was running smoothly until I ran into the DESeqDataSetFromMatrix error.

Error in DESeqDataSetFromMatrix(countData = Counts, colData = coldata,  : 
  ncol(countData) == nrow(colData) is not TRUE

My code:

Counts <- read.delim("RiboTag_count_matrix_10-05-2023.csv", header = TRUE, sep=",")
Counts # dimension is 24421 rows x 13 columns; first column is GeneID

Counts <- Counts[rowSums(Counts[ ,-1]) > 0, ] #omit the first column (GeneID)
Counts # dimension is 19,222 rows x 13 columns

condition <-factor(c("Het","Het","Het","Het", "Cre_WT","Cre_WT","Cre_WT","Cre_WT", "WT_naked_F.1","WT_naked_F.2","WT_naked_M.1","WT_naked_M.2"))

coldata <- data.frame(row.names = colnames(Counts[ ,-1]), condition)

coldata # 12 rows and it matches

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

The error message showed up when I ran the dds

The rest of the code:

dds <- DESeq(dis)
vsdata <- vet(dds, blind=FALSE)

#PCA Plot
plotPCA(vsdata,intgroup="condition")

How do I resolve this error? I checked the conditions for DESEqDataSet code to run and I don't see any problem... but I don't know why it gave me the error message

r rna-seq deseq2

1 answer

Your sample ids and gene ids need to be rownames, not in columns like the other data.

just to confirm before DESeqDataSetFromMatrix I should transpose the matrix, correct?

Look at the vignette, make your data look just like that.

Log in to answer this question.