Question: Issue with DESeqDataSetFromMatrix
gravatar for matthew.sinton
9 months ago by
matthew.sinton0 wrote:

Hi All,

I'm very new to using R, and I'm trying to use it to perform an analysis of RNA-seq data, to look at differential expression. I've done a few online tutorials to try and build up some background, but I'm hitting a roadblock. 

Basically, when I run my script, I get the following error:

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

I realise that this error means that my colData and countData don't quite match up. I performed the following, which showed that I have 7 columns in my countData and 6 rows in my colData file:


However, I cannot see how to alter the colData file to make it match up. Or how to get my countData file to skip the first row containing gene IDs, so that it only counts 6 columns. 

My countData.csv file looks like this:

GeneID                         Control1     Control2     Control3     LPO1    LPO2     LPO3

ENSG01254216542                1.1             1.3         1.14         7.0    7.5      7.2


The colData.csv file looks like this:

                     Condition         type

Control1           untreated         paired-read

Control2           untreated         paired-read        

Control3           untreated         paired-read

LPO1               treated             paired-read

LPO2               treated             paired-read

LPO3               treated             paired-read

The script that I'm using is: 


data <-read.csv("//") 

se <- data

countData <- as.matrix(se,row.names="Geneid", header = TRUE, sep = '\t', row.names = 1)
colData <- read.csv("//", row.names=1)

colData <- colData[,c("condition","type")]
colnames(countData) <- NULL
dds <- (countData = countData,
                              colData = colData,
                              design = ~ condition)
dds <- dds[ rowSums(counts(dds)) > 1, ]

I was wondering if anyone may be able to help with a solution? I'm sure that it's something very obvious, but any help would be very much appreciated, as I don't have access to bioinformatic support. 



ADD COMMENTlink modified 9 months ago by Michael Love25k • written 9 months ago by matthew.sinton0
Answer: Issue with DESeqDataSetFromMatrix
gravatar for Michael Love
9 months ago by
Michael Love25k
United States
Michael Love25k wrote:

Is this Affymetric gene expression data? If so you should not use an RNA-seq method. You should use limma's methods for microarray data.

ADD COMMENTlink written 9 months ago by Michael Love25k


No, this is from an RNA-seq analysis. I aligned my reads using STAR, and then used featureCounts to generate my counts


ADD REPLYlink written 9 months ago by matthew.sinton0

Ok I was thrown off by the non-integer counts and the "affy" tag. There are some mistakes in the as.matrix line. Those arguments don't work with as.matrix. If you want to split off the first column of data, you should instead do something like:

cts <- as.matrix(data[,-1])
ADD REPLYlink modified 9 months ago • written 9 months ago by Michael Love25k
Please log in to add an answer.


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