I'm trying to analyse RNAseq data using the DESeq2 package in R, but I'm quite new to it. I'm running into an issue when I want to create the DESeqDataSheet. I keep getting the following error:
Error in DESeqDataSetFromMatrix(countData = my_matrix, colData = my_dataframe, : ncol(countData) == nrow(colData) is not TRUE
I've checked and double checked my count matrix and my metadata sheet, the colnumber of the matrix is the same as the rownumber of the dataframe. As are the colnames of the matrix the same as the rownames in the dataframe. Additionally I'm pretty sure I've downloaded and installed the package in the right way.
Here's a minimal version of the code and example dataset I use. The last part of which I'm using to doublecheck the right length and names of everything.
library(DESeq2)
# Create a matrix
my_matrix <- matrix(data = c(1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18,
19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30),
nrow = 3,
ncol = 30,
byrow = TRUE) # Fill matrix by rows
rownames(my_matrix)<-c("Gene1", "Gene2", "Gene3")
my_dataframe <- data.frame(
sample = c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "AA", "AB", "AC", "AD"),
condition = c("apple", "banana", "orange"),
experiment = c(TRUE, FALSE, TRUE)
)
rownames(my_dataframe)<-c("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30")
dds <- DESeqDataSetFromMatrix(countData=my_matrix,
colData=my_dataframe,
design= ~ sample + experiment + genotype:condition , tidy = TRUE)
ncol(my_matrix)
nrow(my_dataframe)
ncol(my_matrix) == nrow(my_dataframe)
all(colnames(my_matrix) == rownames(my_dataframe))
Here's the error I'm getting, including the results of my doublechecking.
> dds <- DESeqDataSetFromMatrix(countData=my_matrix,
+ colData=my_dataframe,
+ design= ~ sample + experiment + genotype:condition , tidy = TRUE)
Error in DESeqDataSetFromMatrix(countData = my_matrix, colData = my_dataframe, :
ncol(countData) == nrow(colData) is not TRUE
> ncol(my_matrix)
[1] 30
> nrow(my_dataframe)
[1] 30
> ncol(my_matrix) == nrow(my_dataframe)
[1] TRUE
> all(colnames(my_matrix) == rownames(my_dataframe))
[1] TRUE
I've tried the same code with a minimal version using a count matrix and metadata sheet from Bioconductor. I run into the same issue. I've tried de- and re-installing the package. I've restarted R Studio many times. I've deleted everything and started new. I don't know what to try anymore. I've read the vignette and documentation on Bioconductor, as well as other tutorials. I checked already here and on other forums and couldn't find anything that helped. I asked ChatGPT and watched a few youtube videos. I don't know where else to look for help.
I would really appreciate any help! Thanks in advance!
Amazing, thank you! I must have overlooked that.