DEseq2 ncol(countData) == nrow(colData) is not TRUE Error
1
0
Entering edit mode
trumbia • 0
@trumbia-21415
Last seen 4.7 years ago

Hello'

I have an error of ncol(countData) == nrow(colData) is not TRUE when I tried to set matrix. Code is below:

countdata = read.table('k.txt', header=TRUE, sep = "\t", row.names = 1, as.is=TRUE)

show(countdata) countdata <- as.matrix(countdata)

head(countdata)

condition <- factor(c(rep("x", 2), rep("y", 2),rep("z", 2),rep("t", 2)))

show(condition)

library(DESeq2)

coldata <- data.frame(skip=colnames(countdata), condition)

show(coldata)

dds <- DESeqDataSetFromMatrix(countData=countdata, colData=coldata, design=~condition) # here is it gave an error

dds <- DESeq(dds)

Also my data file like this

       x  y z t

b1 5 6 7 8

b2 3 4 5 6

Could you help me? Thanks

deseq2 • 4.6k views
ADD COMMENT
0
Entering edit mode
@mikelove
Last seen 18 hours ago
United States

You can probably debug this on your end. The counts matrix needs to have same number of columns as the sample table (colData) has rows, because columns of the counts matrix are matched with samples (they must also be in the same order, DESeq2 assumes same order in both).

ADD COMMENT
0
Entering edit mode

I can not debug this one. I guess i have problem about generating coldata but I still could not figure out

ADD REPLY
0
Entering edit mode

Maybe you can connect with a bioinformatics group at your institute to work through use of R? Basically you need to provide DESeq2 with the correct data first and it checks to see if basic rules have been followed. One of these is that the sample information is consistent with the number of samples. You can also try to learn about using R online, from eg the free courses or Quick-R.

ADD REPLY
0
Entering edit mode

Hi,

I also have the same problem, even though everything looks okay.

Error in DESeqDataSetFromMatrix(countData = my_counts, colData = my.metadata, : ncol(countData) == nrow(colData) is not TRUE

ncol(my_counts) [1] 154 nrow(my.metadata) [1] 154

I also double checked the order of sample names, they are the same. Any idea how to solve this?

ADD REPLY
0
Entering edit mode

Is my_counts a matrix? try coercing it my_counts = as.matrix(my_counts).

ADD REPLY
0
Entering edit mode

Thanks for you reply. Yes, indeed it's a matrix.

ADD REPLY
0
Entering edit mode

Can you post the classes of everything and your actual code?

E.g.

class(my.metadata)

etc.

ADD REPLY

Login before adding your answer.

Traffic: 413 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6