From e63cc73b6c705f728def02a7fb3e8580da57df2e Mon Sep 17 00:00:00 2001 From: Neil Horner Date: Mon, 1 Aug 2022 19:07:20 +0000 Subject: [PATCH] Fusions --- README.md | 4 ++-- bin/report.py | 20 ++++++++----------- docs/quickstart.md | 4 ++-- main.nf | 13 ++++++++---- .../JAFFAL/download_jaffal_references.sh | 5 +++++ subworkflows/JAFFAL/gene_fusions.nf | 6 ++++++ 6 files changed, 32 insertions(+), 20 deletions(-) create mode 100644 subworkflows/JAFFAL/download_jaffal_references.sh diff --git a/README.md b/README.md index 07edbcd..a7de289 100644 --- a/README.md +++ b/README.md @@ -138,7 +138,7 @@ do: ```shell mkdir jaffal_data_dir cd jaffal_data_dir/ -wf-transcriptomes/download_jaffal_references.sh +wf-transcriptomes/subworkflows/JAFFAL/load_jaffal_references.sh ```` To use alternative genome and annotation files, they should be prepared as described @@ -147,7 +147,7 @@ To use alternative genome and annotation files, they should be prepared as descr **Specifying the location of the JAFFA code and reference directories** `--jaffal_dir` -This is the directory made by running install_jaffa.sh as shown above +Full path to the directory made by running install_jaffa.sh as shown above. eg: /home/wf-trnascriptomes/JAFFA `--jaffal_refBase` The directory containing the reference data prepared for use with JAFFAL diff --git a/bin/report.py b/bin/report.py index 07a83c9..bc3699b 100755 --- a/bin/report.py +++ b/bin/report.py @@ -798,20 +798,16 @@ def seq_stats_tabs(report, sample_ids, stats): section.plot(Tabs(tabs=tabs)) -def jaffal_table(report, sample_ids, result_csvs): +def jaffal_table(report, result_csv): """Make a table of fusion transcripts identified by JAFFAL.""" cols = [ 'sample_id', 'fusion genes', 'chrom1', 'chrom2', 'spanning reads', 'classification', 'known'] - dfs = [] - for csv, sid in zip(result_csvs, sample_ids): - df = pd.read_csv(csv) - df['sample_id'] = sid - sid_col = df.pop('sample_id') - df.insert(0, 'sample_id', sid_col) - dfs.append(df) - df = pd.concat(dfs) + df = pd.read_csv(result_csv) + sid_col = df.pop('sample_id') + df.insert(0, 'sample_id', sid_col) + df = df[cols] df['chroms'] = df.chrom1.astype(str) + ':' + df.chrom2.astype(str) df.rename(columns={ @@ -874,7 +870,7 @@ def main(): "--cluster_qc_dirs", required=False, type=str, default=None, nargs='*', help="Directory with various cluster quality csvs") parser.add_argument( - "--jaffal_csv", required=False, type=str, default=None, nargs='*', + "--jaffal_csv", required=False, type=str, default=None, help="Path to JAFFAL results csv") parser.add_argument('--denovo', dest='denovo', action='store_true') @@ -921,8 +917,8 @@ def main(): if args.cluster_qc_dirs is not None: cluster_quality(args.cluster_qc_dirs, report, sample_ids) - if args.jaffal_csv is not None: - jaffal_table(report, sample_ids, args.jaffal_csv) + if args.jaffal_csv: + jaffal_table(report, args.jaffal_csv) # Arguments and software versions report.add_section( diff --git a/docs/quickstart.md b/docs/quickstart.md index 0076331..0b75659 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -90,7 +90,7 @@ do: ```shell mkdir jaffal_data_dir cd jaffal_data_dir/ -wf-transcriptomes/download_jaffal_references.sh +wf-transcriptomes/subworkflows/JAFFAL/load_jaffal_references.sh ```` To use alternative genome and annotation files, they should be prepared as described @@ -99,7 +99,7 @@ To use alternative genome and annotation files, they should be prepared as descr **Specifying the location of the JAFFA code and reference directories** `--jaffal_dir` -This is the directory made by running install_jaffa.sh as shown above +Full path to the directory made by running install_jaffa.sh as shown above. eg: /home/wf-trnascriptomes/JAFFA `--jaffal_refBase` The directory containing the reference data prepared for use with JAFFAL diff --git a/main.nf b/main.nf index 5f82738..eea88ba 100644 --- a/main.nf +++ b/main.nf @@ -282,12 +282,12 @@ process makeReport { path "params.json" val denovo path pychopper_report + path jaffal_csv tuple val(sample_ids), path(seq_summaries), path(aln_stats), path(gffcmp_dir), - path(gff_annotation), - path(jaffal_csv) + path(gff_annotation) output: path("wf-transcriptomes-*.html"), emit: report script: @@ -297,6 +297,8 @@ process makeReport { def OPT_ALN = denovo ? '' : "--alignment_stats ${aln_stats}" def OPT_DENOVO = denovo ? "--denovo" : '' def OPT_PC_REPORT = pychopper_report.name.startsWith('OPTIONAL_FILE') ? '' : "--pychop_report ${pychopper_report}" + def OPT_JAFFAL_CSV = jaffal_csv.name.startsWith('OPTIONAL_FILE') ? '' : "--jaffal_csv ${jaffal_csv}" + """ report.py --report $report_name \ --versions $versions \ @@ -308,7 +310,7 @@ process makeReport { --gffcompare_dir $gffcmp_dir \ --gff_annotation $gff_annotation \ --transcript_table_cov_thresh $params.transcript_table_cov_thresh \ - --jaffal_csv $jaffal_csv + $OPT_JAFFAL_CSV \ $OPT_DENOVO """ } @@ -408,6 +410,9 @@ workflow pipeline { if (jaffal_refBase){ gene_fusions(full_len_reads, jaffal_refBase, jaffal_genome, jaffal_annotation) + jaffal_out = gene_fusions.out.results_csv.collectFile(keepHeader: true, name: 'jaffal.csv') + }else{ + jaffal_out = file("$projectDir/data/OPTIONAL_FILE_1") } makeReport( @@ -415,11 +420,11 @@ workflow pipeline { workflow_params, params.denovo, pychopper_report, + jaffal_out, summariseConcatReads.out.summary .join(m.stats) .join(run_gffcompare.out.gffcmp_dir) .join(merge_gff_bundles.out.gff) - .join(gene_fusions.out.results_csv) .toList().transpose().toList()) report = makeReport.out.report diff --git a/subworkflows/JAFFAL/download_jaffal_references.sh b/subworkflows/JAFFAL/download_jaffal_references.sh new file mode 100644 index 0000000..ec12648 --- /dev/null +++ b/subworkflows/JAFFAL/download_jaffal_references.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +#Download the data. We should we move the data out of Figshare? +wget -O JAFFA_REFERENCE_FILES_HG38_GENCODE22.V2.tar.gz https://figshare.com/ndownloader/files/25410494 +tar -zxvf JAFFA_REFERENCE_FILES_HG38_GENCODE22.V2.tar.gz \ No newline at end of file diff --git a/subworkflows/JAFFAL/gene_fusions.nf b/subworkflows/JAFFAL/gene_fusions.nf index 5b8f550..0456da1 100644 --- a/subworkflows/JAFFAL/gene_fusions.nf +++ b/subworkflows/JAFFAL/gene_fusions.nf @@ -22,6 +22,12 @@ process jaffal{ $params.jaffal_dir/JAFFAL.groovy \ $fastq mv "\$JAFFAOUT/jaffa_results.csv" "\$JAFFAOUT/${sample_id}_jaffa_results.csv" + + # Add sample id column + sed "s/\$/,${sample_id}/" \$JAFFAOUT/${sample_id}_jaffa_results.csv > tmp1 + # Add header + sed "1 s/${sample_id}/sample_id/" tmp1 > tmp2 + mv tmp2 \$JAFFAOUT/${sample_id}_jaffa_results.csv """ }