---
output: html_document
---

```{r setup, include=FALSE, warning=FALSE, message=FALSE}
knitr::opts_chunk$set(
  echo = as.logical(opt$X_e),
  error = TRUE
)
```

# `DESeqDataSet` object

```{r 'DESeqDataSet object'}
count_file_paths = strsplit(opt$X_P, ',')[[1]]
count_file_names = strsplit(opt$X_N, ',')[[1]]
sample_table = read.table(opt$X_S, header = TRUE)
row.names(sample_table) = sample_table[,2]
sample_table = sample_table[count_file_names, ]

## copy count files into OUTPUT_DIR/counts
dir.create(paste0(OUTPUT_DIR, '/counts'), recursive = TRUE)
file_copy = file.copy(count_file_paths, paste0(OUTPUT_DIR, '/counts/', count_file_names), overwrite = TRUE)

## DESeqDataSet object
dds = DESeqDataSetFromHTSeqCount(sampleTable = sample_table,
                                 directory = paste0(OUTPUT_DIR, '/counts'),
                                 design = formula(opt$X_p))
dds
```
