# Transform and feed data into DESeq2 with DESeqDataSetFromMatrix

There is a normalized expression matrix. I split it into two and want to do DE on the two cells' subsets. I am having trouble transforming it into the format that DESeq2 would accept. The function that I would think I need to use is the following:

dds <- DESeqDataSetFromMatrix(countData = cts,
colData = coldata,
design= ~ batch + condition)


It would be perfect if I could somehow feed two matrixes separately, but I can not find it. Any suggestions would be greatly appreciated.

Update

I tried the following:

cells <- c(cell_names, cell_names_cyt)
groups <- c(rep("NE", times=length(cell_names)), rep("EX",
times=length(cell_names_cyt)))

colData <- data.frame(
Cells <- cells,
Groups <- groups
)

dds <- DESeqDataSetFromMatrix(countData = df,
colData = colData,
design= ~ Groups)


But getting the error:

Error in DESeqDataSet(se, design = design, ignoreRank) : some values in assay are not integers

Of course, they are floats since I already normalized the matrices.

Update

I did the following since I am using Seurat:

df <- as.data.frame(as.matrix(seurat_object@raw.data))
df <- df[,colnames(df) %in% cells]


But then the following:

dds <- DESeqDataSetFromMatrix(countData = df,
colData = colData,
design= ~ Groups)


Gave me an error:

Error in DESeqDataSet(se, design = design, ignoreRank) : all variables in design formula must be columns in colData

• Don't input normalized counts, use raw counts. – Devon Ryan May 8 '18 at 7:46
• Yeah, I used raw counts retrieved from Seurat, but then got another error. – Nikita Vlasenko May 8 '18 at 13:59

Error in DESeqDataSet(se, design = design, ignoreRank) : all variables in design formula must be columns in colData

I think that means just what it says...you don't have a "Groups" column in coldata. Did you spotcheck your ColData data frame to make sure it looks the way it should?

> cells <- c("1","2","3")
> groups <- c("a", "b", "c")
> test <- data.frame(Cells <- cells, Groups <- groups)
> test
Cells....cells Groups....groups
1              1                a
2              2                b
3              3                c
> colnames(test)
[1] "Cells....cells"   "Groups....groups"