diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 990f235..590faa5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -50,7 +50,7 @@ docker-run: parallel: matrix: - MATRIX_NAME: [ - "fusions", "differential_expression", "isoforms", + "fusions", "differential_expression", "isoforms", "isoforms_bam", "only_differential_expression", "differential_expression_gff3", "ncbi_gzip", "ncbi_no_gene_id", "ensembl_with_versions", "differential_expression_mouse", "no_ref_annotation" @@ -68,6 +68,13 @@ docker-run: --ref_genome ${CI_PROJECT_NAME}/data/chr20/hg38_chr20.fa --ref_annotation ${CI_PROJECT_NAME}/data/chr20/gencode.v22.annotation.chr20.gtf --pychopper_backend phmm \ -c ${CI_PROJECT_NAME}/data/demo.nextflow.config" NF_IGNORE_PROCESSES: preprocess_reads,merge_transcriptomes,decompress_annotation,decompress_ref,decompress_transcriptome,preprocess_ref_transcriptome + - if: $MATRIX_NAME == "isoforms_bam" + variables: + NF_BEFORE_SCRIPT: mkdir -p ${CI_PROJECT_NAME}/data/ && wget -O ${CI_PROJECT_NAME}/data/wf-isoforms_test_data.tar.gz https://ont-exd-int-s3-euwst1-epi2me-labs.s3.amazonaws.com/wf-isoforms/wf-isoforms_test_data.tar.gz && tar -xzvf ${CI_PROJECT_NAME}/data/wf-isoforms_test_data.tar.gz -C ${CI_PROJECT_NAME}/data/ && wget -O ${CI_PROJECT_NAME}/data/demo.nextflow.config https://ont-exd-int-s3-euwst1-epi2me-labs.s3.amazonaws.com/wf-isoforms/demo.nextflow.config + NF_WORKFLOW_OPTS: "--bam ${CI_PROJECT_NAME}/data/ERR6053095_chr20.bam --transcriptome-source reference-guided \ + --ref_genome ${CI_PROJECT_NAME}/data/chr20/hg38_chr20.fa --ref_annotation ${CI_PROJECT_NAME}/data/chr20/gencode.v22.annotation.chr20.gtf --pychopper_backend phmm \ + -c ${CI_PROJECT_NAME}/data/demo.nextflow.config" + NF_IGNORE_PROCESSES: preprocess_reads,merge_transcriptomes,decompress_annotation,decompress_ref,decompress_transcriptome,preprocess_ref_transcriptome - if: $MATRIX_NAME == "no_ref_annotation" variables: NF_BEFORE_SCRIPT: mkdir -p ${CI_PROJECT_NAME}/data/ && wget -O ${CI_PROJECT_NAME}/data/wf-isoforms_test_data.tar.gz https://ont-exd-int-s3-euwst1-epi2me-labs.s3.amazonaws.com/wf-isoforms/wf-isoforms_test_data.tar.gz && tar -xzvf ${CI_PROJECT_NAME}/data/wf-isoforms_test_data.tar.gz -C ${CI_PROJECT_NAME}/data/ && wget -O ${CI_PROJECT_NAME}/data/demo.nextflow.config https://ont-exd-int-s3-euwst1-epi2me-labs.s3.amazonaws.com/wf-isoforms/demo.nextflow.config diff --git a/README.md b/README.md index 7a53e55..86d18a0 100644 --- a/README.md +++ b/README.md @@ -86,9 +86,9 @@ Find related protocols in the [Nanopore community](https://community.nanoporetec ## Input example -This workflow accepts FASTQ files as input. +This workflow accepts either FASTQ or BAM files as input. -The FASTQ input parameters for this workflow accept one of three cases: (i) the path to a single FASTQ file; (ii) the path to a top-level directory containing FASTQ files; (iii) the path to a directory containing one level of sub-directories which in turn contain FASTQ files. In the first and second cases (i and ii), a sample name can be supplied with `--sample`. In the last case (iii), the data is assumed to be multiplexed with the names of the sub-directories as barcodes. In this case, a sample sheet can be provided with `--sample_sheet`. If you are using the workflow for differential expression analysis the last case(iii) will be expected with a minimum of 4 samples (at least 2 replicates of each sample to compare) but we recommend 6 samples (three replicates). +The FASTQ or BAM input parameters for this workflow accept one of three cases: (i) the path to a single FASTQ or BAM file; (ii) the path to a top-level directory containing FASTQ or BAM files; (iii) the path to a directory containing one level of sub-directories which in turn contain FASTQ or BAM files. In the first and second cases (i and ii), a sample name can be supplied with `--sample`. In the last case (iii), the data is assumed to be multiplexed with the names of the sub-directories as barcodes. In this case, a sample sheet can be provided with `--sample_sheet`. ``` (i) (ii) (iii) @@ -106,7 +106,6 @@ input_reads.fastq ─── input_directory ─── input_directory - ## Input parameters ### Input Options @@ -114,6 +113,7 @@ input_reads.fastq ─── input_directory ─── input_directory | Nextflow parameter name | Type | Description | Help | Default | |--------------------------|------|-------------|------|---------| | fastq | string | FASTQ files to use in the analysis. | This accepts one of three cases: (i) the path to a single FASTQ file; (ii) the path to a top-level directory containing FASTQ files; (iii) the path to a directory containing one level of sub-directories which in turn contain FASTQ files. In the first and second case, a sample name can be supplied with `--sample`. In the last case, the data is assumed to be multiplexed with the names of the sub-directories as barcodes. In this case, a sample sheet can be provided with `--sample_sheet`. | | +| bam | string | BAM or unaligned BAM (uBAM) files to use in the analysis. | This accepts one of three cases: (i) the path to a single BAM file; (ii) the path to a top-level directory containing BAM files; (iii) the path to a directory containing one level of sub-directories which in turn contain BAM files. In the first and second case, a sample name can be supplied with `--sample`. In the last case, the data is assumed to be multiplexed with the names of the sub-directories as barcodes. In this case, a sample sheet can be provided with `--sample_sheet`. | | | transcriptome_source | string | Select how the transcriptome used for analysis should be prepared. | To analyse only gene fusions and differential expression use of an existing transcriptome may be preferred and so 'precomputed' should be selected. In this case the 'ref_transcriptome' parameter should be specified. To create a reference transcriptome using an existing reference genome, select 'reference guided' and specify the 'ref_genome' parameter. | reference-guided | | ref_genome | string | Path to reference genome sequence [.fa/.fq/.fa.gz/fq.gz]. Required for reference-based workflow. | A reference genome is required for reference-based assembly of a transcriptome. | | | ref_transcriptome | string | Transcriptome reference file. Required for precomputed transcriptome calculation and for differential expression analysis. | A reference transcriptome related to the sample under study. Must be supplied when the 'Transcriptome source' parameter has been set to 'precomputed' or to perform differential expression. | | diff --git a/docs/06_input_example.md b/docs/06_input_example.md index 45ef56d..edb244c 100644 --- a/docs/06_input_example.md +++ b/docs/06_input_example.md @@ -1,7 +1,7 @@ -This workflow accepts FASTQ files as input. +This workflow accepts either FASTQ or BAM files as input. -The FASTQ input parameters for this workflow accept one of three cases: (i) the path to a single FASTQ file; (ii) the path to a top-level directory containing FASTQ files; (iii) the path to a directory containing one level of sub-directories which in turn contain FASTQ files. In the first and second cases (i and ii), a sample name can be supplied with `--sample`. In the last case (iii), the data is assumed to be multiplexed with the names of the sub-directories as barcodes. In this case, a sample sheet can be provided with `--sample_sheet`. If you are using the workflow for differential expression analysis the last case(iii) will be expected with a minimum of 4 samples (at least 2 replicates of each sample to compare) but we recommend 6 samples (three replicates). +The FASTQ or BAM input parameters for this workflow accept one of three cases: (i) the path to a single FASTQ or BAM file; (ii) the path to a top-level directory containing FASTQ or BAM files; (iii) the path to a directory containing one level of sub-directories which in turn contain FASTQ or BAM files. In the first and second cases (i and ii), a sample name can be supplied with `--sample`. In the last case (iii), the data is assumed to be multiplexed with the names of the sub-directories as barcodes. In this case, a sample sheet can be provided with `--sample_sheet`. ``` (i) (ii) (iii) @@ -15,4 +15,4 @@ input_reads.fastq ─── input_directory ─── input_directory │ └── reads2.fastq └── barcode03 └── reads0.fastq -``` +``` \ No newline at end of file diff --git a/docs/06_input_parameters.md b/docs/06_input_parameters.md index cc538fd..9ca1f8d 100644 --- a/docs/06_input_parameters.md +++ b/docs/06_input_parameters.md @@ -3,6 +3,7 @@ | Nextflow parameter name | Type | Description | Help | Default | |--------------------------|------|-------------|------|---------| | fastq | string | FASTQ files to use in the analysis. | This accepts one of three cases: (i) the path to a single FASTQ file; (ii) the path to a top-level directory containing FASTQ files; (iii) the path to a directory containing one level of sub-directories which in turn contain FASTQ files. In the first and second case, a sample name can be supplied with `--sample`. In the last case, the data is assumed to be multiplexed with the names of the sub-directories as barcodes. In this case, a sample sheet can be provided with `--sample_sheet`. | | +| bam | string | BAM or unaligned BAM (uBAM) files to use in the analysis. | This accepts one of three cases: (i) the path to a single BAM file; (ii) the path to a top-level directory containing BAM files; (iii) the path to a directory containing one level of sub-directories which in turn contain BAM files. In the first and second case, a sample name can be supplied with `--sample`. In the last case, the data is assumed to be multiplexed with the names of the sub-directories as barcodes. In this case, a sample sheet can be provided with `--sample_sheet`. | | | transcriptome_source | string | Select how the transcriptome used for analysis should be prepared. | To analyse only gene fusions and differential expression use of an existing transcriptome may be preferred and so 'precomputed' should be selected. In this case the 'ref_transcriptome' parameter should be specified. To create a reference transcriptome using an existing reference genome, select 'reference guided' and specify the 'ref_genome' parameter. | reference-guided | | ref_genome | string | Path to reference genome sequence [.fa/.fq/.fa.gz/fq.gz]. Required for reference-based workflow. | A reference genome is required for reference-based assembly of a transcriptome. | | | ref_transcriptome | string | Transcriptome reference file. Required for precomputed transcriptome calculation and for differential expression analysis. | A reference transcriptome related to the sample under study. Must be supplied when the 'Transcriptome source' parameter has been set to 'precomputed' or to perform differential expression. | | diff --git a/main.nf b/main.nf index 295468a..af14b9d 100644 --- a/main.nf +++ b/main.nf @@ -9,7 +9,7 @@ import nextflow.util.BlankSeparatedList; import java.util.ArrayList; nextflow.enable.dsl = 2 -include { fastq_ingress } from './lib/ingress' +include { fastq_ingress; xam_ingress } from './lib/ingress' include { reference_assembly } from './subworkflows/reference_assembly' include { gene_fusions } from './subworkflows/JAFFAL/gene_fusions' include { differential_expression } from './subworkflows/differential_expression' @@ -737,18 +737,12 @@ workflow { Pinguscript.ping_start(nextflow, workflow, params) - fastq = file(params.fastq, type: "file") - error = null if (params.containsKey("minimap_index_opts")) { error = "`--minimap_index_opts` parameter is deprecated. Use parameter `--minimap2_index_opts` instead." } - if (!fastq.exists()) { - error = "--fastq: File doesn't exist, check path." - } - if (params.transcriptome_source == "precomputed" && !params.ref_transcriptome){ error = "As transcriptome source parameter is precomputed you must include a ref_transcriptome parameter" } @@ -808,22 +802,35 @@ workflow { } if (error){ throw new Exception(error) - }else{ - reads = samples = fastq_ingress([ - "input":params.fastq, - "sample":params.sample, - "sample_sheet":params.sample_sheet, - "analyse_unclassified":params.analyse_unclassified, - "stats": true, - "fastcat_extra_args": "", - "per_read_stats": true]) - - pipeline(reads, ref_genome, ref_annotation, - jaffal_refBase, params.jaffal_genome, params.jaffal_annotation, - ref_transcriptome, use_ref_ann) - - output(pipeline.out.results) } + + if (params.fastq) { + samples = fastq_ingress([ + "input":params.fastq, + "sample":params.sample, + "sample_sheet":params.sample_sheet, + "analyse_unclassified":params.analyse_unclassified, + "stats": true, + "fastcat_extra_args": "", + "per_read_stats": true]) + } else { + samples = xam_ingress([ + "input":params.bam, + "sample":params.sample, + "sample_sheet":params.sample_sheet, + "analyse_unclassified":params.analyse_unclassified, + "keep_unaligned": true, + "return_fastq": true, + "stats": true, + "per_read_stats": true]) + } + + pipeline(samples, ref_genome, ref_annotation, + jaffal_refBase, params.jaffal_genome, params.jaffal_annotation, + ref_transcriptome, use_ref_ann) + + output(pipeline.out.results) + } workflow.onComplete { diff --git a/nextflow.config b/nextflow.config index 33e5fd2..482f156 100644 --- a/nextflow.config +++ b/nextflow.config @@ -13,6 +13,7 @@ params { help = false fastq = null + bam = null ref_genome = null ref_annotation = null transcriptome_source = "reference-guided" diff --git a/nextflow_schema.json b/nextflow_schema.json index 155299a..1c5164c 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -23,6 +23,12 @@ "description": "FASTQ files to use in the analysis.", "help_text": "This accepts one of three cases: (i) the path to a single FASTQ file; (ii) the path to a top-level directory containing FASTQ files; (iii) the path to a directory containing one level of sub-directories which in turn contain FASTQ files. In the first and second case, a sample name can be supplied with `--sample`. In the last case, the data is assumed to be multiplexed with the names of the sub-directories as barcodes. In this case, a sample sheet can be provided with `--sample_sheet`." }, + "bam": { + "type": "string", + "format": "path", + "description": "BAM or unaligned BAM (uBAM) files to use in the analysis.", + "help_text": "This accepts one of three cases: (i) the path to a single BAM file; (ii) the path to a top-level directory containing BAM files; (iii) the path to a directory containing one level of sub-directories which in turn contain BAM files. In the first and second case, a sample name can be supplied with `--sample`. In the last case, the data is assumed to be multiplexed with the names of the sub-directories as barcodes. In this case, a sample sheet can be provided with `--sample_sheet`." + }, "transcriptome_source": { "type": "string", "enum": [ @@ -74,10 +80,24 @@ "allOf": [ { "required": [ - "fastq", "transcriptome_source" ] - }] + }, + { + "oneOf": [ + { + "required": [ + "fastq" + ] + }, + { + "required": [ + "bam" + ] + } + ] + } + ] }, "output_options": { "title": "Output Options",