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.
Yes, thank you I caught that right before seeing this! I get a new error when I correct that which is:
Check that
all(rownames(coldata) %in% colnames(countdata))
. If it returnsFALSE
, 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.
Great, thank you. It seems they are not aligned. What code would align the two?
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: