'Error in Deseq2 DESeqDataSetFromMatrix ncol(countData) == nrow(colData) is not TRUE

I am trying to normalize my dataset ( ASV count table ) using DESeq2, for 16SrRNA metagenome analysis.

I have made sure that ncol of countData == nrow of colData, and that the rows and column are in the same order, with the same name (sample name). This is the error message :

Error in DESeqDataSetFromMatrix(countData = as.matrix(count_tab_t), colData = meta_data,  : 
  ncol(countData) == nrow(colData) is not TRUE

I'm not sure why I am still encountering this error even though I ran this line on an old dataset and it worked fine.

I have only imported the csv files and formatted them before running this line :

count_tab <- read.csv('2022April2_mangrove.bacteria.unique_tally_full.csv', header = T,row.names = 1)
meta_data <- read.csv("2022April_mangrove_study.bacteria.edge_data_full.csv", header = T,row.names = 1)
taxon_map <- read.csv("2022April2_mangrove.bacteria.taxon_map.csv", header = T ,row.names = 1)
    
#formatting count_tab and meta_data
count_tab[is.na(count_tab)] <- 0
count_tab[count_tab < 1] <- 0
count_tab_t <- t(count_tab) #transpose for DESeq2
count_tab_t <- as.numeric(count_tab_t)
meta_data[is.na(meta_data)] <- 0

#DESeq2 Normalization
library(DESeq2)
deseq_counts <- DESeqDataSetFromMatrix(countData = as.matrix(count_tab_t), colData = meta_data ,design = ~Compartment)

What else can I check for to solve this error??

I'm a new DESeq2 user and have very limited R experience. What else



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source