Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

R differential modules control over output prefixes #3664

Merged
merged 13 commits into from
Jul 25, 2023
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
Loading