Skip to content
Snippets Groups Projects
Verified Commit cfcbc0be authored by nfontrod's avatar nfontrod
Browse files

R/load_matrix.R: fix batch effect column handling

parent 07fb22d6
No related branches found
No related tags found
No related merge requests found
...@@ -49,7 +49,9 @@ load_matrix <- function(design_table, path, my_formula) { ...@@ -49,7 +49,9 @@ load_matrix <- function(design_table, path, my_formula) {
for (my_col in cn[3:length(cn)]) { for (my_col in cn[3:length(cn)]) {
sample_table[[my_col]] <- as.factor(sample_table[[my_col]]) sample_table[[my_col]] <- as.factor(sample_table[[my_col]])
} }
sample_table <- sample_table[, c("sampleName", "fileName", "condition")] tmp_cn <- c("sampleName", "fileName", "condition")
tmp_cn <- unique(c(tmp_cn, cn[3:length(cn)]))
sample_table <- sample_table[, tmp_cn]
sample_table$condition <- as.factor(sample_table$condition) sample_table$condition <- as.factor(sample_table$condition)
dds_input <- DESeq2::DESeqDataSetFromHTSeqCount( dds_input <- DESeq2::DESeqDataSetFromHTSeqCount(
sampleTable = as.data.frame(sample_table), sampleTable = as.data.frame(sample_table),
...@@ -57,10 +59,10 @@ load_matrix <- function(design_table, path, my_formula) { ...@@ -57,10 +59,10 @@ load_matrix <- function(design_table, path, my_formula) {
design = as.formula(my_formula) design = as.formula(my_formula)
) )
dds <- DESeq2::DESeq(dds_input) dds <- DESeq2::DESeq(dds_input)
if (length(cn) <= 3) { if (length(tmp_cn) <= 3) {
ac <- "" ac <- ""
} else { } else {
ac <- cn[4:length(cn)] ac <- tmp_cn[4:length(tmp_cn)]
} }
res <- list(dds = dds, acol = ac) res <- list(dds = dds, acol = ac)
return(res) return(res)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment