From f45093feba37f4023e701e60cbbbb4492bf75354 Mon Sep 17 00:00:00 2001 From: atrigila <18577080+atrigila@users.noreply.github.com> Date: Fri, 16 Aug 2024 14:33:03 +0000 Subject: [PATCH 1/4] fix plotmds checks --- CHANGELOG.md | 1 + bin/edgeR_miRBase.r | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ecca6b7..83b47a4a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [[#350]](https://github.com/nf-core/smrnaseq/pull/350) - Fix [MIRTOP_QUANT conda issue](https://github.com/nf-core/smrnaseq/issues/347), set python version to 3.7 to fix pysam issue - [[#351]](https://github.com/nf-core/smrnaseq/issues/351) - Fix [Protocol inheritance issue](https://github.com/nf-core/smrnaseq/pull/364) - fixing protocol inheritance from subworkflow with move to config profile(s) for different protocols - [[#371]](https://github.com/nf-core/smrnaseq/issues/371) - Fix [Plain test profile](https://github.com/nf-core/smrnaseq/pull/372) - Updated default protocol value to "custom". +- [[#187]](https://github.com/nf-core/smrnaseq/issues/187) - Fix checking number of samples which causes error in plotMDS. ## v2.3.1 - 2024-04-18 - Gray Zinc Dalmation Patch diff --git a/bin/edgeR_miRBase.r b/bin/edgeR_miRBase.r index 5be691fc..98c9c0a2 100755 --- a/bin/edgeR_miRBase.r +++ b/bin/edgeR_miRBase.r @@ -79,7 +79,7 @@ for (i in 1:2) { } # Make MDS plot (only perform with 3 or more samples) - if (length(filelist[[1]]) > 2){ + if (length(ncol(dataNorm$counts)) > 2){ pdf(paste(header,"_edgeR_MDS_plot.pdf",sep="")) MDSdata <- plotMDS(dataNorm) dev.off() From 374cd5dde8fc0272286a544e5413b51bbdcadba5 Mon Sep 17 00:00:00 2001 From: atrigila <18577080+atrigila@users.noreply.github.com> Date: Tue, 20 Aug 2024 15:42:23 +0000 Subject: [PATCH 2/4] fix if clause mds plot --- bin/edgeR_miRBase.r | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/edgeR_miRBase.r b/bin/edgeR_miRBase.r index 98c9c0a2..8f8233bc 100755 --- a/bin/edgeR_miRBase.r +++ b/bin/edgeR_miRBase.r @@ -79,7 +79,7 @@ for (i in 1:2) { } # Make MDS plot (only perform with 3 or more samples) - if (length(ncol(dataNorm$counts)) > 2){ + if (ncol(dataNorm$counts) > 2){ pdf(paste(header,"_edgeR_MDS_plot.pdf",sep="")) MDSdata <- plotMDS(dataNorm) dev.off() @@ -111,6 +111,8 @@ for (i in 1:2) { # Write clustered distance values to file write.table(hmap$carpet, paste(header,"_log2CPM_sample_distances.txt",sep=""), quote=FALSE, sep="\t") + } else { + warning("Not enough samples to create an MDS plot. At least 3 samples are required.") } } From 48627821d755e4fd828e9d3c23483d9ce81bfe0f Mon Sep 17 00:00:00 2001 From: atrigila <18577080+atrigila@users.noreply.github.com> Date: Tue, 20 Aug 2024 15:46:42 +0000 Subject: [PATCH 3/4] add nf-tests and reorganize module structure --- modules/local/{ => edger_qc}/edger_qc.nf | 0 modules/local/edger_qc/tests/edger_qc.nf.test | 58 +++++++++ .../edger_qc/tests/edger_qc.nf.test.snap | 120 ++++++++++++++++++ nf-test.config | 13 ++ subworkflows/local/mirna_quant.nf | 2 +- 5 files changed, 192 insertions(+), 1 deletion(-) rename modules/local/{ => edger_qc}/edger_qc.nf (100%) create mode 100644 modules/local/edger_qc/tests/edger_qc.nf.test create mode 100644 modules/local/edger_qc/tests/edger_qc.nf.test.snap create mode 100644 nf-test.config diff --git a/modules/local/edger_qc.nf b/modules/local/edger_qc/edger_qc.nf similarity index 100% rename from modules/local/edger_qc.nf rename to modules/local/edger_qc/edger_qc.nf diff --git a/modules/local/edger_qc/tests/edger_qc.nf.test b/modules/local/edger_qc/tests/edger_qc.nf.test new file mode 100644 index 00000000..fa145784 --- /dev/null +++ b/modules/local/edger_qc/tests/edger_qc.nf.test @@ -0,0 +1,58 @@ +nextflow_process { + + name "Test Process EDGER_QC" + script "../edger_qc.nf" + process "EDGER_QC" + + test("Should not produce MDS plot") { + + when { + params { + outdir = "${outputDir}" + } + process { + """ + input[0] = [file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Clone1_N1_mature.sorted.idxstats"), + file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Clone1_N1_mature_hairpin.sorted.idxstats") + ] + """ + } + } + + then { + assert process.success + assert snapshot(process.out).match() + } + + } + + test("Should produce MDS plot") { + + when { + params { + outdir = "${outputDir}" + } + process { + """ + input[0] = [ + file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Clone1_N1_mature.sorted.idxstats"), + file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Clone1_N1_mature_hairpin.sorted.idxstats"), + file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Clone1_N3_mature.sorted.idxstats"), + file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Clone1_N3_mature_hairpin.sorted.idxstats"), + file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Control_N1_mature.sorted.idxstats"), + file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Control_N1_mature_hairpin.sorted.idxstats"), + file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Control_N2_mature.sorted.idxstats"), + file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Control_N2_mature_hairpin.sorted.idxstats"), + ] + """ + } + } + + then { + assert process.success + assert snapshot(process.out).match() + } + + } + +} diff --git a/modules/local/edger_qc/tests/edger_qc.nf.test.snap b/modules/local/edger_qc/tests/edger_qc.nf.test.snap new file mode 100644 index 00000000..531e1f5a --- /dev/null +++ b/modules/local/edger_qc/tests/edger_qc.nf.test.snap @@ -0,0 +1,120 @@ +{ + "Should not produce MDS plot": { + "content": [ + { + "0": [ + [ + "hairpin_counts.csv:md5,9a2c4c71862349eee5071cf08a81df52", + "hairpin_logtpm.csv:md5,590516d1c7447023933f055446d34552", + "hairpin_logtpm.txt:md5,5cbb1258c290d958910db677490596c0", + "hairpin_normalized_CPM.txt:md5,2f6685750d4c0aa1dc8150276f8a5a2d", + "hairpin_unmapped_read_counts.txt:md5,b3ca3b9f01dbdab1bdbd989769121794", + "mature_counts.csv:md5,17b953ef2fb4e58d83acc263f68755fd", + "mature_logtpm.csv:md5,b4654e4ec264243156b1ceab73503017", + "mature_logtpm.txt:md5,9cba6dd8336de7fe79be641285e92a73", + "mature_normalized_CPM.txt:md5,43db2854ec00e6afca25883b64ad67bd", + "mature_unmapped_read_counts.txt:md5,0e129ffe42aa32f96250a5071d3a7649" + ] + ], + "1": [ + "versions.yml:md5,2e5b1dd3ed5befd1d4c9812a3fcb768a" + ], + "edger_files": [ + [ + "hairpin_counts.csv:md5,9a2c4c71862349eee5071cf08a81df52", + "hairpin_logtpm.csv:md5,590516d1c7447023933f055446d34552", + "hairpin_logtpm.txt:md5,5cbb1258c290d958910db677490596c0", + "hairpin_normalized_CPM.txt:md5,2f6685750d4c0aa1dc8150276f8a5a2d", + "hairpin_unmapped_read_counts.txt:md5,b3ca3b9f01dbdab1bdbd989769121794", + "mature_counts.csv:md5,17b953ef2fb4e58d83acc263f68755fd", + "mature_logtpm.csv:md5,b4654e4ec264243156b1ceab73503017", + "mature_logtpm.txt:md5,9cba6dd8336de7fe79be641285e92a73", + "mature_normalized_CPM.txt:md5,43db2854ec00e6afca25883b64ad67bd", + "mature_unmapped_read_counts.txt:md5,0e129ffe42aa32f96250a5071d3a7649" + ] + ], + "versions": [ + "versions.yml:md5,2e5b1dd3ed5befd1d4c9812a3fcb768a" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.4" + }, + "timestamp": "2024-08-20T15:35:12.666335127" + }, + "Should produce MDS plot": { + "content": [ + { + "0": [ + [ + "hairpin_CPM_heatmap.pdf:md5,5d7ade334680f6fa7f822c9c5059ee97", + "hairpin_counts.csv:md5,4b0fa0e52a7b8b40bdc5930378430136", + "hairpin_edgeR_MDS_distance_matrix.txt:md5,f0eb20be2b7bae7775ef65e03139f5a9", + "hairpin_edgeR_MDS_plot.pdf:md5,27c8a310bdfd200f37068c9fddb80d17", + "hairpin_edgeR_MDS_plot_coordinates.txt:md5,2f1f865b11c4ee5253f80ebe9a1914ee", + "hairpin_log2CPM_sample_distances.txt:md5,20592bfa42e23827dfac02eab1e033ff", + "hairpin_log2CPM_sample_distances_dendrogram.pdf:md5,1bfcdd534efcb49b167ef29981f325ce", + "hairpin_log2CPM_sample_distances_heatmap.pdf:md5,2e8e51bd4778a644bce4c0253f683c0b", + "hairpin_logtpm.csv:md5,35a5449d3468995e8010907105922898", + "hairpin_logtpm.txt:md5,1de707003b6ed2c38372670d69eaf5fb", + "hairpin_normalized_CPM.txt:md5,d42e8eb89175107c5dfbfb2c7da98d37", + "hairpin_unmapped_read_counts.txt:md5,c587147fb1a5b6681c17eff2d4859022", + "mature_CPM_heatmap.pdf:md5,486f30379c552346025d9f25eb9a2e52", + "mature_counts.csv:md5,f961a9d6749dbf0c84dfb8976e0b6516", + "mature_edgeR_MDS_distance_matrix.txt:md5,bfbf327feedbc2e7bbbd57020ae0594c", + "mature_edgeR_MDS_plot.pdf:md5,9f9e312f882ff7e7de70701af4dd0f6b", + "mature_edgeR_MDS_plot_coordinates.txt:md5,b89854153c61a348929ea3901a61bd56", + "mature_log2CPM_sample_distances.txt:md5,b4ed17084de4711e7fd4a12d221d65ec", + "mature_log2CPM_sample_distances_dendrogram.pdf:md5,03c1ff39c90fbc64a1112d93756592fa", + "mature_log2CPM_sample_distances_heatmap.pdf:md5,e4dc113bae6464ad0b914f173f8042b1", + "mature_logtpm.csv:md5,850a8ed0e4559d338578f81dc849acf5", + "mature_logtpm.txt:md5,9087155e2f4bc7f85ced8ab8c02c77e6", + "mature_normalized_CPM.txt:md5,3bc348a1248f9597dfc9e8e465c3c8a8", + "mature_unmapped_read_counts.txt:md5,138cf290420edbf9721b9db861204c9c" + ] + ], + "1": [ + "versions.yml:md5,2e5b1dd3ed5befd1d4c9812a3fcb768a" + ], + "edger_files": [ + [ + "hairpin_CPM_heatmap.pdf:md5,5d7ade334680f6fa7f822c9c5059ee97", + "hairpin_counts.csv:md5,4b0fa0e52a7b8b40bdc5930378430136", + "hairpin_edgeR_MDS_distance_matrix.txt:md5,f0eb20be2b7bae7775ef65e03139f5a9", + "hairpin_edgeR_MDS_plot.pdf:md5,27c8a310bdfd200f37068c9fddb80d17", + "hairpin_edgeR_MDS_plot_coordinates.txt:md5,2f1f865b11c4ee5253f80ebe9a1914ee", + "hairpin_log2CPM_sample_distances.txt:md5,20592bfa42e23827dfac02eab1e033ff", + "hairpin_log2CPM_sample_distances_dendrogram.pdf:md5,1bfcdd534efcb49b167ef29981f325ce", + "hairpin_log2CPM_sample_distances_heatmap.pdf:md5,2e8e51bd4778a644bce4c0253f683c0b", + "hairpin_logtpm.csv:md5,35a5449d3468995e8010907105922898", + "hairpin_logtpm.txt:md5,1de707003b6ed2c38372670d69eaf5fb", + "hairpin_normalized_CPM.txt:md5,d42e8eb89175107c5dfbfb2c7da98d37", + "hairpin_unmapped_read_counts.txt:md5,c587147fb1a5b6681c17eff2d4859022", + "mature_CPM_heatmap.pdf:md5,486f30379c552346025d9f25eb9a2e52", + "mature_counts.csv:md5,f961a9d6749dbf0c84dfb8976e0b6516", + "mature_edgeR_MDS_distance_matrix.txt:md5,bfbf327feedbc2e7bbbd57020ae0594c", + "mature_edgeR_MDS_plot.pdf:md5,9f9e312f882ff7e7de70701af4dd0f6b", + "mature_edgeR_MDS_plot_coordinates.txt:md5,b89854153c61a348929ea3901a61bd56", + "mature_log2CPM_sample_distances.txt:md5,b4ed17084de4711e7fd4a12d221d65ec", + "mature_log2CPM_sample_distances_dendrogram.pdf:md5,03c1ff39c90fbc64a1112d93756592fa", + "mature_log2CPM_sample_distances_heatmap.pdf:md5,e4dc113bae6464ad0b914f173f8042b1", + "mature_logtpm.csv:md5,850a8ed0e4559d338578f81dc849acf5", + "mature_logtpm.txt:md5,9087155e2f4bc7f85ced8ab8c02c77e6", + "mature_normalized_CPM.txt:md5,3bc348a1248f9597dfc9e8e465c3c8a8", + "mature_unmapped_read_counts.txt:md5,138cf290420edbf9721b9db861204c9c" + ] + ], + "versions": [ + "versions.yml:md5,2e5b1dd3ed5befd1d4c9812a3fcb768a" + ] + } + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "24.04.4" + }, + "timestamp": "2024-08-20T15:39:22.840053942" + } +} \ No newline at end of file diff --git a/nf-test.config b/nf-test.config new file mode 100644 index 00000000..eab0ec0b --- /dev/null +++ b/nf-test.config @@ -0,0 +1,13 @@ +config { + // location for all nf-tests + testsDir "tests" + + // nf-test directory including temporary files for each test + workDir ".nf-test" + + // location of library folder that is added automatically to the classpath + libDir "tests/lib/" + + // location of an optional nextflow.config file specific for executing tests + configFile "nextflow.config" +} diff --git a/subworkflows/local/mirna_quant.nf b/subworkflows/local/mirna_quant.nf index aea1c9a7..98002274 100644 --- a/subworkflows/local/mirna_quant.nf +++ b/subworkflows/local/mirna_quant.nf @@ -21,7 +21,7 @@ include { BAM_SORT_STATS_SAMTOOLS as BAM_STATS_MATURE include { SEQCLUSTER_SEQUENCES } from '../../modules/local/seqcluster_collapse.nf' include { MIRTOP_QUANT } from '../../modules/local/mirtop_quant.nf' include { TABLE_MERGE } from '../../modules/local/datatable_merge.nf' -include { EDGER_QC } from '../../modules/local/edger_qc.nf' +include { EDGER_QC } from '../../modules/local/edger_qc/edger_qc.nf' workflow MIRNA_QUANT { take: From e1a18e6f3454225384fa888f20b11f04dead8edb Mon Sep 17 00:00:00 2001 From: atrigila <18577080+atrigila@users.noreply.github.com> Date: Tue, 20 Aug 2024 15:52:30 +0000 Subject: [PATCH 4/4] replace for nf-core repo --- modules/local/edger_qc/tests/edger_qc.nf.test | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/local/edger_qc/tests/edger_qc.nf.test b/modules/local/edger_qc/tests/edger_qc.nf.test index fa145784..53d3148c 100644 --- a/modules/local/edger_qc/tests/edger_qc.nf.test +++ b/modules/local/edger_qc/tests/edger_qc.nf.test @@ -12,8 +12,8 @@ nextflow_process { } process { """ - input[0] = [file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Clone1_N1_mature.sorted.idxstats"), - file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Clone1_N1_mature_hairpin.sorted.idxstats") + input[0] = [file("https://github.com/nf-core/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Clone1_N1_mature.sorted.idxstats"), + file("https://github.com/nf-core/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Clone1_N1_mature_hairpin.sorted.idxstats") ] """ } @@ -35,14 +35,14 @@ nextflow_process { process { """ input[0] = [ - file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Clone1_N1_mature.sorted.idxstats"), - file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Clone1_N1_mature_hairpin.sorted.idxstats"), - file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Clone1_N3_mature.sorted.idxstats"), - file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Clone1_N3_mature_hairpin.sorted.idxstats"), - file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Control_N1_mature.sorted.idxstats"), - file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Control_N1_mature_hairpin.sorted.idxstats"), - file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Control_N2_mature.sorted.idxstats"), - file("https://github.com/atrigila/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Control_N2_mature_hairpin.sorted.idxstats"), + file("https://github.com/nf-core/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Clone1_N1_mature.sorted.idxstats"), + file("https://github.com/nf-core/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Clone1_N1_mature_hairpin.sorted.idxstats"), + file("https://github.com/nf-core/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Clone1_N3_mature.sorted.idxstats"), + file("https://github.com/nf-core/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Clone1_N3_mature_hairpin.sorted.idxstats"), + file("https://github.com/nf-core/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Control_N1_mature.sorted.idxstats"), + file("https://github.com/nf-core/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Control_N1_mature_hairpin.sorted.idxstats"), + file("https://github.com/nf-core/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Control_N2_mature.sorted.idxstats"), + file("https://github.com/nf-core/test-datasets/raw/smrnaseq/nf-test_data/edger_qc/Control_N2_mature_hairpin.sorted.idxstats"), ] """ }