DESeq2 dds Creation
1
0
Entering edit mode
2.4 years ago
cgp09741 ▴ 10

Hello,

I am trying to generate a dds out of a count matrix file. I haven successfully imported the count matrix for "countData" as well as the metadata for "colData" but when I run "DESeqDataFromMatrix" I receive the error

Error in SummarizedExperiment(assays = SimpleList(counts = countData), : the rownames and colnames of the supplied assay(s) must be NULL or identical to those of the SummarizedExperiment object (or derivative) to construct

Below are the code lines I am running to get to this point, any help would be appreciated to generate a dds so I can run DESeq2.

raw_counts <- read.csv("raw_counts.csv", header = TRUE, row.names = 1)
countdata <- as.matrix(raw_counts)
coldata <- read.csv("metadata.csv", header = T, row.names = 1)
dds <- DESeqDataSetFromMatrix(countData = countdata,
                          colData = coldata,
                          design = ~ sample)

Thank you.

deseq2 • 2.2k views
ADD COMMENT
0
Entering edit mode
2.4 years ago
ATpoint 86k

object 'countData' not found

It must be countdata, with a lowercase d as in the 2nd line of code.

ADD COMMENT
0
Entering edit mode

Yes, thank you I caught that right before seeing this! I get a new error when I correct that which is:

Error in SummarizedExperiment(assays = SimpleList(counts = countData), : the rownames and colnames of the supplied assay(s) must be NULL or identical to those of the SummarizedExperiment object (or derivative) to construct

ADD REPLY
0
Entering edit mode

Check that all(rownames(coldata) %in% colnames(countdata)). If it returns FALSE, your colData rownames don't match the column names for the counts, so the samples can't be properly associated with the sample-specific metadata.

Correcting that should solve the error.

ADD REPLY
0
Entering edit mode

Great, thank you. It seems they are not aligned. What code would align the two?

ADD REPLY
1
Entering edit mode

In the simplest case you make an intersect, to get the samples that are in both countdata and coldata and then sort them. Something like:

#/ for example (untested)
i <- intersect(colnames(countdata), rownames(coldata))`
countsdata2 <- countdata[,i]
coldata2 <- coldata[i,]
ADD REPLY

Login before adding your answer.

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