comparison deseq2.R @ 41:0a0a3388e3f2 draft

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/deseq2 commit cbeb1c4c436be04323bd9a809a6393d00b168d07"
author iuc
date Mon, 29 Nov 2021 18:16:10 +0000
parents b30a443484ab
children 6ef2cba4e35a
comparison
equal deleted inserted replaced
40:ed9e8345a292 41:0a0a3388e3f2
50 "help", "h", 0, "logical", 50 "help", "h", 0, "logical",
51 "cores", "s", 0, "integer", 51 "cores", "s", 0, "integer",
52 "batch_factors", "w", 1, "character", 52 "batch_factors", "w", 1, "character",
53 "outfile", "o", 1, "character", 53 "outfile", "o", 1, "character",
54 "countsfile", "n", 1, "character", 54 "countsfile", "n", 1, "character",
55 "sizefactorsfile", "F", 1, "character",
55 "rlogfile", "r", 1, "character", 56 "rlogfile", "r", 1, "character",
56 "vstfile", "v", 1, "character", 57 "vstfile", "v", 1, "character",
57 "header", "H", 0, "logical", 58 "header", "H", 0, "logical",
58 "factors", "f", 1, "character", 59 "factors", "f", 1, "character",
59 "files_to_labels", "l", 1, "character", 60 "files_to_labels", "l", 1, "character",
215 dds <- get_deseq_dataset(sample_table, header = opt$header, design_formula = design_formula, tximport = opt$tximport, txtype = opt$txtype, tx2gene = opt$tx2gene) 216 dds <- get_deseq_dataset(sample_table, header = opt$header, design_formula = design_formula, tximport = opt$tximport, txtype = opt$txtype, tx2gene = opt$tx2gene)
216 # estimate size factors for the chosen method 217 # estimate size factors for the chosen method
217 if (!is.null(opt$esf)) { 218 if (!is.null(opt$esf)) {
218 dds <- estimateSizeFactors(dds, type = opt$esf) 219 dds <- estimateSizeFactors(dds, type = opt$esf)
219 } 220 }
221
222 # estimate size factors for each sample
223 # - https://support.bioconductor.org/p/97676/
224 if (!is.null(opt$sizefactorsfile)) {
225 nm <- assays(dds)[["avgTxLength"]]
226 if (!is.null(nm)) {
227 ## Recommended: takes into account tximport data
228 cat("\nsize factors for samples: taking tximport data into account\n")
229 size_factors <- estimateSizeFactorsForMatrix(counts(dds) / nm)
230 } else {
231 norm_factors <- normalizationFactors(dds)
232 if (!is.null(norm_factors)) {
233 ## In practice, gives same results as above.
234 cat("\nsize factors for samples: no tximport data, using derived normalization factors\n")
235 size_factors <- estimateSizeFactorsForMatrix(norm_factors)
236 } else {
237 ## If we have no other information, estimate from raw.
238 cat("\nsize factors for samples: no tximport data, no normalization factors, estimating from raw data\n")
239 size_factors <- estimateSizeFactorsForMatrix(counts(dds))
240 }
241 }
242 write.table(size_factors, file = opt$sizefactorsfile, sep = "\t", col.names = F, quote = FALSE)
243 }
244
220 apply_batch_factors <- function(dds, batch_factors) { 245 apply_batch_factors <- function(dds, batch_factors) {
221 rownames(batch_factors) <- batch_factors$identifier 246 rownames(batch_factors) <- batch_factors$identifier
222 batch_factors <- subset(batch_factors, select = -c(identifier, condition)) 247 batch_factors <- subset(batch_factors, select = -c(identifier, condition))
223 dds_samples <- colnames(dds) 248 dds_samples <- colnames(dds)
224 batch_samples <- rownames(batch_factors) 249 batch_samples <- rownames(batch_factors)