Skip to content

Commit

Permalink
R differential modules control over output prefixes (nf-core#3664)
Browse files Browse the repository at this point in the history
* R differential modules control over output prefixes

* Set differential module prefixes

* Actually we need to do prefix handling within the template

* Set differential module prefixes

* Fix test files for new prefix specification

* Add meta to limma test

* Fix DESeq2 tests

* fix remaining tests for limma

* Update grep to fix broken solve

* Try bumping affy

* Use new build

* update md5sum for annotation
  • Loading branch information
Jonathan Manning authored and snesic committed Oct 10, 2023
1 parent fb809db commit f288d50
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 101 deletions.
6 changes: 3 additions & 3 deletions modules/nf-core/affy/justrma/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ process AFFY_JUSTRMA {
tag "$meta.id"
label 'process_single'

conda "bioconda::bioconductor-affy=1.76.0"
conda "bioconda::bioconductor-affy=1.78.0"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/bioconductor-affy:1.76.0--r42hc0cfd56_2':
'biocontainers/bioconductor-affy:1.76.0--r42hc0cfd56_2' }"
'https://depot.galaxyproject.org/singularity/bioconductor-affy:1.78.0--r43ha9d7317_1':
'biocontainers/bioconductor-affy:1.78.0--r43ha9d7317_1' }"

input:
tuple val(meta), path(samplesheet), path(celfiles_dir)
Expand Down
21 changes: 9 additions & 12 deletions modules/nf-core/deseq2/differential/templates/deseq_de.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ round_dataframe_columns <- function(df, columns = NULL, digits = 8){
# Set defaults and classes

opt <- list(
output_prefix = ifelse('$task.ext.prefix' == 'null', '$meta.id', '$task.ext.prefix'),
count_file = '$counts',
sample_file = '$samplesheet',
contrast_variable = '$contrast_variable',
Expand Down Expand Up @@ -143,7 +144,7 @@ for ( ao in names(args_opt)){

# Check if required parameters have been provided

required_opts <- c('contrast_variable', 'reference_level', 'target_level')
required_opts <- c('contrast_variable', 'reference_level', 'target_level', 'output_prefix')
missing <- required_opts[unlist(lapply(opt[required_opts], is.null)) | ! required_opts %in% names(opt)]

if (length(missing) > 0){
Expand Down Expand Up @@ -369,10 +370,6 @@ if (opt\$shrink_lfc){
################################################
################################################

prefix_part_names <- c('contrast_variable', 'reference_level', 'target_level', 'blocking_variables')
prefix_parts <- unlist(lapply(prefix_part_names, function(x) gsub("[^[:alnum:]]", "_", opt[[x]])))
output_prefix <- paste(prefix_parts[prefix_parts != ''], collapse = '-')

contrast.name <-
paste(opt\$target_level, opt\$reference_level, sep = "_vs_")
cat("Saving results for ", contrast.name, " ...\n", sep = "")
Expand All @@ -386,7 +383,7 @@ write.table(
round_dataframe_columns(data.frame(comp.results, check.names = FALSE)),
check.names = FALSE
),
file = paste(output_prefix, 'deseq2.results.tsv', sep = '.'),
file = paste(opt\$output_prefix, 'deseq2.results.tsv', sep = '.'),
col.names = TRUE,
row.names = FALSE,
sep = '\t',
Expand All @@ -396,7 +393,7 @@ write.table(
# Dispersion plot

png(
file = paste(output_prefix, 'deseq2.dispersion.png', sep = '.'),
file = paste(opt\$output_prefix, 'deseq2.dispersion.png', sep = '.'),
width = 600,
height = 600
)
Expand All @@ -405,7 +402,7 @@ dev.off()

# R object for other processes to use

saveRDS(dds, file = paste(output_prefix, 'dds.rld.rds', sep = '.'))
saveRDS(dds, file = paste(opt\$output_prefix, 'dds.rld.rds', sep = '.'))

# Size factors

Expand All @@ -417,7 +414,7 @@ sf_df = data.frame(
colnames(sf_df) <- c('sample', 'sizeFactor')
write.table(
sf_df,
file = paste(output_prefix, 'deseq2.sizefactors.tsv', sep = '.'),
file = paste(opt\$output_prefix, 'deseq2.sizefactors.tsv', sep = '.'),
col.names = TRUE,
row.names = FALSE,
sep = '\t',
Expand All @@ -432,7 +429,7 @@ write.table(
counts(dds, normalized = TRUE),
check.names = FALSE
),
file = paste(output_prefix, 'normalised_counts.tsv', sep = '.'),
file = paste(opt\$output_prefix, 'normalised_counts.tsv', sep = '.'),
col.names = TRUE,
row.names = FALSE,
sep = '\t',
Expand All @@ -458,7 +455,7 @@ for (vs_method_name in strsplit(opt\$vs_method, ',')){
),
check.names = FALSE
),
file = paste(output_prefix, vs_method_name,'tsv', sep = '.'),
file = paste(opt\$output_prefix, vs_method_name,'tsv', sep = '.'),
col.names = TRUE,
row.names = FALSE,
sep = '\t',
Expand All @@ -472,7 +469,7 @@ for (vs_method_name in strsplit(opt\$vs_method, ',')){
################################################
################################################

sink(paste(output_prefix, "R_sessionInfo.log", sep = '.'))
sink(paste(opt\$output_prefix, "R_sessionInfo.log", sep = '.'))
print(sessionInfo())
sink()

Expand Down
15 changes: 6 additions & 9 deletions modules/nf-core/limma/differential/templates/limma_de.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ read_delim_flexible <- function(file, header = TRUE, row.names = NULL, check.nam
# Set defaults and classes

opt <- list(
output_prefix = ifelse('$task.ext.prefix' == 'null', '$meta.id', '$task.ext.prefix'),
count_file = '$intensities',
sample_file = '$samplesheet',
contrast_variable = '$contrast_variable',
Expand Down Expand Up @@ -111,7 +112,7 @@ for ( ao in names(args_opt)){

# Check if required parameters have been provided

required_opts <- c('contrast_variable', 'reference_level', 'target_level')
required_opts <- c('contrast_variable', 'reference_level', 'target_level', 'output_prefix')
missing <- required_opts[unlist(lapply(opt[required_opts], is.null)) | ! required_opts %in% names(opt)]

if (length(missing) > 0){
Expand Down Expand Up @@ -340,10 +341,6 @@ comp.results <- do.call(topTable, toptable_args)[rownames(intensities.table),]
################################################
################################################

prefix_part_names <- c('contrast_variable', 'reference_level', 'target_level', 'blocking_variables')
prefix_parts <- unlist(lapply(prefix_part_names, function(x) gsub("[^[:alnum:]]", "_", opt[[x]])))
output_prefix <- paste(prefix_parts[prefix_parts != ''], collapse = '-')

contrast.name <-
paste(opt\$target_level, opt\$reference_level, sep = "_vs_")
cat("Saving results for ", contrast.name, " ...\n", sep = "")
Expand All @@ -356,7 +353,7 @@ write.table(
probe_id = rownames(comp.results),
comp.results
),
file = paste(output_prefix, 'limma.results.tsv', sep = '.'),
file = paste(opt\$output_prefix, 'limma.results.tsv', sep = '.'),
col.names = TRUE,
row.names = FALSE,
sep = '\t',
Expand All @@ -366,7 +363,7 @@ write.table(
# Dispersion plot

png(
file = paste(output_prefix, 'limma.mean_difference.png', sep = '.'),
file = paste(opt\$output_prefix, 'limma.mean_difference.png', sep = '.'),
width = 600,
height = 600
)
Expand All @@ -375,15 +372,15 @@ dev.off()

# R object for other processes to use

saveRDS(fit2, file = paste(output_prefix, 'MArrayLM.limma.rds', sep = '.'))
saveRDS(fit2, file = paste(opt\$output_prefix, 'MArrayLM.limma.rds', sep = '.'))

################################################
################################################
## R SESSION INFO ##
################################################
################################################

sink(paste(output_prefix, "R_sessionInfo.log", sep = '.'))
sink(paste(opt\$output_prefix, "R_sessionInfo.log", sep = '.'))
print(sessionInfo())
sink()

Expand Down
2 changes: 1 addition & 1 deletion modules/nf-core/untar/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ process UNTAR {
tag "$archive"
label 'process_single'

conda "conda-forge::sed=4.7 bioconda::grep=3.4 conda-forge::tar=1.34"
conda "conda-forge::sed=4.7 conda-forge::grep=3.11 conda-forge::tar=1.34"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/ubuntu:20.04' :
'nf-core/ubuntu:20.04' }"
Expand Down
2 changes: 1 addition & 1 deletion tests/modules/nf-core/affy/justrma/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
files:
- path: output/affy/normalised.eset.rds
- path: output/affy/hgu133a2.annotation.tsv
md5sum: b718d6ff9f3037cf398d7ef7ea03a84d
md5sum: ffe59c061c8e304966f5f8156fb41805
- path: output/affy/normalised.matrix.tsv
md5sum: 462665542e9531f6d8993b745ce78ae4
- path: output/affy/versions.yml
Loading

0 comments on commit f288d50

Please sign in to comment.