DESeq2 Error: ncol(countData) == nrow(colData) is not TRUE
1
0
Entering edit mode
anpham ▴ 60
@anpham-7402
Last seen 7.2 years ago

I tried to build an DESeqDataSet with a count matrix and a table of sample information. My count matrix is read from a csv file. The count matrix has gene names as the first column. Here are my codes and error message. Please advise as how I should address the error message. Thank you.

 

# read in the count data and column data

countData <- read.csv ("Gcount.csv", header=T) # dim 48545, 437

colData <- read.csv("Phe.csv", header=TRUE)  # dim 436 53

# construct the DESeqDataSet object
dds <- DESeqDataSetFromMatrix (countData = countData, 
                               colData = colData, 
                               design = ~age_cut4 + Batch_RNA + Study + sex)

# I got the following error message

Error: ncol(countData) == nrow(colData) is not TRUE

 

 

deseq2 error • 21k views
ADD COMMENT
2
Entering edit mode
@mikelove
Last seen 13 hours ago
United States

The countData should be only a matrix of counts, where each column corresponds and is in the same order as the rows of colData.

As you have a first column with names, you just need to remove that (and you can assign the names as rownames):

mat <- countData[,-1]
rownames(mat) <- countData[,1]
ADD COMMENT
0
Entering edit mode

Hi. I don't understand how to fix this. 

Can you explain it with more details?

Thanks you!

ADD REPLY
0
Entering edit mode

Can you partner with a bioinformatician or someone with experience with R coding?

ADD REPLY
0
Entering edit mode

Hello Michael

I could not make the same matrix although I did what you said

ADD REPLY
0
Entering edit mode

The countData input should be a matrix of counts.

You made need to partner with someone with R / bioinformatics experience if you get stuck here.

ADD REPLY
0
Entering edit mode

Would you plz help me in this error:

Error in DESeqDataSet(se, design = design, ignoreRank) : some values in assay are negative

ADD REPLY
0
Entering edit mode

DESeq2 is for count data, if you are trying to provide count values that are negative, you either made a mistake or should use alternative software if you are not working with count data.

ADD REPLY
0
Entering edit mode

Hi Michael love,

I am having the same problem. I made sure that my counts data is matrix and that the number of rows in the metadata is equal to the columns in the counts data. Here are my inputs:

countdata <- read.csv("/Users/ghidaelbanna/Desktop/Dermatomyositis/Aim #2/Aim2_R/Aim2_Option2_IFNGenes_CountData_R.csv", row.names = "gene_name" ) countData <- countdata[,c(1:20)] countdatamatrix <- as.matrix(countData) metadata <- read.csv("/Users/ghidaelbanna/Desktop/Dermatomyositis/Aim #2/Aim2_R/Aim2_Option2_Metadata_R.csv", row.names = 1) dds <- DESeqDataSetFromMatrix(countData=countdatamatrix, colData = metadata, design = ~dex, tidy = TRUE) Error in DESeqDataSetFromMatrix(countData = countdatamatrix, colData = metadata, : ncol(countData) == nrow(colData) is not TRUE ncol(countdatamatrix) == nrow(metadata) [1] TRUE class(countdatamatrix) [1] "matrix" "array" class(metadata) [1] "data.frame"

Any idea what is the problem on my end? thank you

ADD REPLY
0
Entering edit mode

See the tidy argument details.

ADD REPLY

Login before adding your answer.

Traffic: 536 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