This is a test version of Biostars. For the public version, visit https://www.biostars.org.
DESeq2 saying that dimensions of count matrix and metadata don't agree, but they do agree

Hi all,

I have a counts matrix and a metadata table with the following dimension:

> dim(as.matrix(cts)) 
[1] 6009   60
> dim(colData)
[1] 60  4

so that there are 60 samples and 60 corresponding rows of metadata in colData.

The problem that I'm having is the following. Whenever I try to setup the DESeqData object,

# construct DESeqDataSet Object
dds <- DESeqDataSetFromMatrix(countData=cts,
                              colData=colData,
                              design=~Condition+Timepoint,tidy=TRUE)

I get the following error:

Error in DESeqDataSetFromMatrix(countData = as.matrix(cts), colData = colData,  : 
  ncol(countData) == nrow(colData) is not TRUE

Which doesn't make sense to me. I'm thinking it has something to do with how my cts matrix is setup :

Rstudio environment showing cts

Perhaps the rownames are causing issues? I don't know.

expression r differential

What does it give if you type the exact command of error msg

ncol(as.matrix(ct) == nrow(colData)

1 answer

Hi, please use tidy = FALSE, and then it will work.

Also, it is strange that you have no colnames on your expression matrix. Obviously the columns of cts must match, in both number and order, the rows of colData.

Kevin

Hi Kevin,

Thanks! tidy=False fixed it. I do have colnames, just hadn't added tacked them on before screenshotting. Thanks for your help!

Log in to answer this question.