suppressPackageStartupMessages({
library(GeneseeBulk)
library(DESeq2)
library(dplyr)
library(stringr)
library(readr)
})
knitr::opts_chunk$set(warning = FALSE, error = FALSE, message = FALSE)
counts = read_tsv(params$input_tsv)
names(counts)[1] = 'SYMBOL'
cd = tibble(sample_id = names(counts)[-1])
sample_sheet = read_csv(params$sample_sheet_csv)
sample_sheet$sample_id = as.character(sample_sheet$sample_id)
print(knitr::kable(sample_sheet, caption = "Sample Sheet"), "html", table.attr='class="flat-table"')
# Maybe set factor levels here
cd = left_join(cd, sample_sheet)
count_matrix =  as.matrix(counts[,-1])
rownames(count_matrix) = counts[[1]]
dge = SummarizedExperiment(assays = list(counts = count_matrix), colData = cd, rowData = counts[,1])

Input sample sheet.

assays(dge) = assays(dge)['counts']

Write data

print(knitr::kable(colData(dge), caption = "Sample Sheet"), "html", table.attr='class="flat-table"')

Output data

saveRDS(dge, file = sprintf('%s_se.rds', params$output_root))


amcdavid/GeneseeBulk documentation built on March 26, 2022, 4:58 a.m.