From 7f7c630dd8c4b2ef6eba5553fed099460340c7a1 Mon Sep 17 00:00:00 2001 From: dweemx Date: Mon, 22 Mar 2021 12:53:41 +0100 Subject: [PATCH] [scanpy] Add multi-sample QC workflow --- main.nf | 29 +++++++++++++++++++++++--- src/scanpy/main.nf | 52 +++++++++++++++++++++++++++++++++++++++------- 2 files changed, 71 insertions(+), 10 deletions(-) diff --git a/main.nf b/main.nf index 139a42e2..b822f8e4 100644 --- a/main.nf +++ b/main.nf @@ -273,15 +273,15 @@ workflow single_sample_qc { include { single_sample_qc as SINGLE_SAMPLE_QC; - } from './main' params(params) + } from './src/scanpy/main' params(params) include { - PUBLISH as PUBLISH_SINGLE_SAMPLE_SCOPE; + PUBLISH; } from "./src/utils/workflows/utils" params(params) getDataChannel | SINGLE_SAMPLE_QC if(params.utils?.publish) { - PUBLISH_SINGLE_SAMPLE_SCOPE( + PUBLISH( SINGLE_SAMPLE_QC.out.filtered, "SINGLE_SAMPLE_QC", "h5ad", @@ -292,6 +292,29 @@ workflow single_sample_qc { } +workflow multi_sample_qc { + + include { + multi_sample_qc as MULTI_SAMPLE_QC; + } from './src/scanpy/main' params(params) + include { + PUBLISH; + } from "./src/utils/workflows/utils" params(params) + + getDataChannel | MULTI_SAMPLE_QC + + if(params.utils?.publish) { + PUBLISH( + MULTI_SAMPLE_QC.out.filtered, + "MULTI_SAMPLE_QC", + "h5ad", + null, + false + ) + } + +} + workflow multi_sample { include { diff --git a/src/scanpy/main.nf b/src/scanpy/main.nf index e0e10ff9..2d93a789 100644 --- a/src/scanpy/main.nf +++ b/src/scanpy/main.nf @@ -6,14 +6,19 @@ import static groovy.json.JsonOutput.* ////////////////////////////////////////////////////// // Import sub-workflows from the modules: - +include { + getBaseName; +} from '../utils/processes/files.nf' +include { + FILTER_AND_ANNOTATE_AND_CLEAN; +} from '../utils/workflows/filterAnnotateClean.nf' params(params) include { INIT; - getDataChannel; } from '../utils/workflows/utils' params(params) INIT(params) include { - SC__FILE_CONVERTER + SC__FILE_CONVERTER; + SC__FILE_CONCATENATOR; } from '../utils/processes/utils' params(params) include { getDataChannel @@ -25,7 +30,6 @@ include { SINGLE_SAMPLE } from './workflows/single_sample.nf' params(params) - workflow single_sample { main: @@ -38,9 +42,43 @@ workflow single_sample { workflow single_sample_qc { + take: + data + main: - getDataChannel | \ - SC__FILE_CONVERTER | \ - QC_FILTER + out = SC__FILE_CONVERTER( data ) + out = FILTER_AND_ANNOTATE_AND_CLEAN( out ) + QC_FILTER( out ) } + +workflow multi_sample_qc { + + take: + data + + main: + if(!params?.sc?.scanpy?.filter) { + throw new Exception("VSN ERROR: Missing params.sc.scanpy.filter config.") + } + if(!params?.sc?.file_concatenator) { + throw new Exception("VSN ERROR: Missing params.sc.file_concatenator config.") + } + + out = data | \ + SC__FILE_CONVERTER | \ + FILTER_AND_ANNOTATE_AND_CLEAN + + out = QC_FILTER( out ).filtered + out = SC__FILE_CONCATENATOR( + out.map { + it -> it[1] + }.toSortedList( + { a, b -> getBaseName(a, "SC") <=> getBaseName(b, "SC") } + ) + ) + + emit: + filtered = out + +} \ No newline at end of file