Question: DEseq2 ncol(countData) == nrow(colData) is not TRUE Error
0
gravatar for trumbia
3 months ago by
trumbia0
trumbia0 wrote:

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 • 317 views
ADD COMMENTlink modified 3 months ago • written 3 months ago by trumbia0
Answer: DEseq2 ncol(countData) == nrow(colData) is not TRUE Error
0
gravatar for Michael Love
3 months ago by
Michael Love26k
United States
Michael Love26k wrote:

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 COMMENTlink modified 3 months ago • written 3 months ago by Michael Love26k

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

ADD REPLYlink written 3 months ago by trumbia0

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 REPLYlink written 3 months ago by Michael Love26k

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 REPLYlink written 7 weeks ago by dgree0

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

ADD REPLYlink written 7 weeks ago by Martin Morgan ♦♦ 24k

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

ADD REPLYlink written 7 weeks ago by dgree0

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

E.g.

class(my.metadata)

etc.

ADD REPLYlink written 7 weeks ago by Michael Love26k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 173 users visited in the last hour