DESeqDataSetFromMatrix
1
2
Entering edit mode
Gian ▴ 30
@chloe-25118
Last seen 2.3 years ago
Italy
control = factor(c(rep("Control",5),NA,NA))
affected=  factor(c(rep("Affected",7)))
library(DESeq2)
dds<-DESeqDataSetFromMatrix(
    countData=countTable,
    design =~control+affected,
    colData=data.frame(
      control=control,
      affected=affected
    ))
normCounts<-rlog(dds,blind=false)

This error coming

Error in DESeqDataSetFromMatrix(countData = countTable, design = ~control +  : 
  ncol(countData) == nrow(colData) is not TRUE
DESeqDataSetFromMatrix • 19k views
ADD COMMENT
2
Entering edit mode
Kevin Blighe ★ 4.0k
@kevin
Last seen 6 weeks ago
Republic of Ireland

Hi,

As implied by the error message, for this command to work correctly, the following must return TRUE:

meta <- data.frame(
  control = control,
  affected = affected)
ncol(countTable) == nrow(meta)

That is, to say, the number of columns of your input raw counts table (passed to the function as countData) must be equal to the number of rows of your input sample metadata (passed to the function as colData). It also follows that the order of these (the columns and the rows) must match.

As a suggestion, I think that you may need:

dds <- DESeqDataSetFromMatrix(
  countData = countTable,
  design = ~ condition,
  colData = data.frame(
    condition = c(control, affected)))

, assuming that the elements of c(control, affected) are perfectly aligned to the columns of countTable

Kevin

ADD COMMENT
0
Entering edit mode
#normalizing counts
library(DESeq2)
dds<-DESeqDataSetFromMatrix(
    countData=countTable,
    design =~ condition,
    colData=data.frame(
      condition = c(control, affected)
    ))
normCounts<-rlog(dds,blind = FALSE)

When I add like this it shows this error for design Now I check that number of columns of countData is equal to the number of rows of colData

Error in DESeqDataSet(se, design = design, ignoreRank) : 
  design has a single variable, with all samples having the same value.
  use instead a design of '~ 1'. estimateSizeFactors, rlog and the VST can then be used
ADD REPLY
2
Entering edit mode

Hi again, and thank you for replying.

control = factor(c(rep("Control",5),NA,NA))
affected = factor(c(rep("Affected",7)))

Why are there values of NA here? If you have samples whose condition is unknown, you may consider removing these samples from the dataset, or create a third 'condition' called 'Unknown'.



You may wish to try:

control = c(rep('Control', 5), 'Unknown', 'Unknown')
affected = rep('Affected', 7)
meta <- data.frame(
  condition = factor(c(control, affected),
    levels = c('Control', 'Affected', 'Unknown')))

dds <- DESeqDataSetFromMatrix(
  countData = countTable,
  design = ~ condition,
  colData = meta)
ADD REPLY
1
Entering edit mode

Thanks, it resolved.

ADD REPLY

Login before adding your answer.

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