From e432a05dc59832d55307442264ad2b70039f5e3a Mon Sep 17 00:00:00 2001 From: WackerO <43847497+WackerO@users.noreply.github.com> Date: Thu, 5 Oct 2023 10:25:19 +0200 Subject: [PATCH] Fix CUSTOM/MATRIXFILTER (#3912) * Added log_assays param to shinyngs tests, updated shinyngs containers, removed na.omit() from proteus * Updated shinyngs containers, added test for plot_exploratory --log_assays param * added --log2_assays flag back into nextflow.config * removed redundant process definition * prettier, updated proteus tests * Added na.rm to matrixfilter * Made params more uniform, updated meta.yml and main.nf * Bugfix, added tests * linting * Combined rejection files into one file * Updated test file path * Propose more generic framework for matrixfilter * Update output definitition * Fix bool output * Update tests * appease eclint * fixed matrixfilter bug, added comments --------- Co-authored-by: Jonathan Manning --- .../nf-core/custom/matrixfilter/templates/matrixfilter.R | 6 ++++-- tests/modules/nf-core/custom/matrixfilter/test.yml | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/nf-core/custom/matrixfilter/templates/matrixfilter.R b/modules/nf-core/custom/matrixfilter/templates/matrixfilter.R index dc8b508f1c2..0bfff8cca41 100644 --- a/modules/nf-core/custom/matrixfilter/templates/matrixfilter.R +++ b/modules/nf-core/custom/matrixfilter/templates/matrixfilter.R @@ -156,6 +156,8 @@ if ((opt\$sample_file != '') && ( ! is.null(opt\$grouping_variable))){ # Also set up filtering for NAs; use by default minimum_proportion_not_na; only # use minimum_samples_not_na if it is provided (default NULL) +# -->NA test can always use minimum_samples_not_na as this will contain the correct +# value even if the proportion is to be used if (is.null(opt\$minimum_samples_not_na)) { opt\$minimum_samples_not_na <- ncol(abundance_matrix) * opt\$minimum_proportion_not_na @@ -164,8 +166,8 @@ if (is.null(opt\$minimum_samples_not_na)) { # Define the tests tests <- list( - 'abundance' = function(x) sum(x > opt\$minimum_abundance, na.rm = T) >= opt\$minimum_samples, - 'na' = function(x) !any(is.na(x)) || sum(!is.na(x))/length(x) >= opt\$minimum_samples_not_n + 'abundance' = function(x) sum(x > opt\$minimum_abundance, na.rm = T) >= opt\$minimum_samples, # check if rows have sufficiently high abundance + 'na' = function(x) !any(is.na(x)) || sum(!is.na(x)) >= opt\$minimum_samples_not_na # check if enough values in row are not NA ) # Apply the functions row-wise on the abundance_matrix and store the result in a boolean matrix diff --git a/tests/modules/nf-core/custom/matrixfilter/test.yml b/tests/modules/nf-core/custom/matrixfilter/test.yml index cf86a8bacf2..f8af0f09039 100644 --- a/tests/modules/nf-core/custom/matrixfilter/test.yml +++ b/tests/modules/nf-core/custom/matrixfilter/test.yml @@ -45,9 +45,9 @@ files: - path: output/custom/R_sessionInfo.log - path: output/custom/mq_prop_test.filtered.tsv - md5sum: a0943baaa48ea76bdb8c80a580dc9953 + md5sum: f5bcfe041816e20ef4cd89bbe0a7e7a2 - path: output/custom/mq_prop_test.tests.tsv - md5sum: 65f7c7ad7e475d82985bd3fc4fec0451 + md5sum: 12fc7c32300f774924c5d4ad59b1e447 - path: output/custom/versions.yml - name: custom matrixfilter test_custom_matrixfilter_na_samples @@ -58,7 +58,7 @@ files: - path: output/custom/R_sessionInfo.log - path: output/custom/mq_samples_test.filtered.tsv - md5sum: f0d81baf35d7eb324365ad5e1c6eb2ae + md5sum: 9deea105a4bf8bf7128a7621d4acedb6 - path: output/custom/mq_samples_test.tests.tsv - md5sum: c9e91fb2e26ba8f5d3c73f0d2252fb56 + md5sum: be76a1f032f4c7650faa910a87a5467f - path: output/custom/versions.yml