diff --git a/CHANGELOG.md b/CHANGELOG.md index cf488eec..91deffb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,8 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [[#369]](https://github.com/nf-core/smrnaseq/issues/369) - Fix [Linting](https://github.com/nf-core/smrnaseq/pull/377) - Fixed linting warnings and updated modules & subworkflows. - [[#374]](https://github.com/nf-core/smrnaseq/pull/374) - Fix [default tests](https://github.com/nf-core/smrnaseq/issues/375) so that they do not require additional profiles in CI. Change GitHub CI fail-fast strategy to false. - [[#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. - [[#378]](https://github.com/nf-core/smrnaseq/pull/378) - Fix [`--mirtrace_species` bug](<(https://github.com/nf-core/smrnaseq/issues/348)>). Make `MIRTRACE` process conditional. Add mirgenedb test. -- [[#375](https://github.com/nf-core/smrnaseq/pull/375) - Test merging of [technical repeats](https://github.com/nf-core/smrnaseq/issues/212). +- [[#375]](https://github.com/nf-core/smrnaseq/pull/375) - Test merging of [technical repeats](https://github.com/nf-core/smrnaseq/issues/212). ## v2.3.1 - 2024-04-18 - Gray Zinc Dalmation Patch diff --git a/bin/edgeR_miRBase.r b/bin/edgeR_miRBase.r index 5be691fc..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(filelist[[1]]) > 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.") } } 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..53d3148c --- /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/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") + ] + """ + } + } + + 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/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"), + ] + """ + } + } + + 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: