Skip to content

Commit

Permalink
Fix CUSTOM/MATRIXFILTER (nf-core#3912)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
WackerO and pinin4fjords authored Oct 5, 2023
1 parent 44d9d83 commit e432a05
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions modules/nf-core/custom/matrixfilter/templates/matrixfilter.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/modules/nf-core/custom/matrixfilter/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit e432a05

Please sign in to comment.