Merge branch 'jaffal_crash' into 'dev'

Fix for when JAFFAL returns exit status 1 when no fusions are found

See merge request epi2melabs/workflows/wf-transcriptomes!80
This commit is contained in:
Neil Horner 2022-11-15 19:56:48 +00:00
commit 7040a043d4
5 changed files with 56 additions and 33 deletions

View File

@ -12,9 +12,6 @@ variables:
docker-run: docker-run:
# Remove this directive in downstream templates
tags: [large_ram] # no need for big ram
# Define a 1D job matrix to inject a variable named MATRIX_NAME into # Define a 1D job matrix to inject a variable named MATRIX_NAME into
# the CI environment, we can use the value of MATRIX_NAME to determine # the CI environment, we can use the value of MATRIX_NAME to determine
# which options to apply as part of the rules block below # which options to apply as part of the rules block below

View File

@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Demo differential expression data in repository. - Demo differential expression data in repository.
- Improved DE explanation in docs - Improved DE explanation in docs
### Fixed ### Fixed
- Fix JAFFAL terminating workflow when no fusions found.
- Error if condition sheet and sample sheet don't match. - Error if condition sheet and sample sheet don't match.
## [v0.1.5] ## [v0.1.5]

View File

@ -791,31 +791,43 @@ def jaffal_table(report, result_csv):
'sample_id', 'fusion genes', 'chrom1', 'chrom2', 'spanning reads', 'sample_id', 'fusion genes', 'chrom1', 'chrom2', 'spanning reads',
'classification', 'known'] 'classification', 'known']
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={
'spanning reads': 'nreads',
'fusion genes': 'genes'}, inplace=True)
df.drop(columns=['chrom1', 'chrom2'], inplace=True)
section = report.add_section() section = report.add_section()
section.markdown(""" try:
### JAFFAL fusion transcript summary df = pd.read_csv(result_csv)
except pd.errors.EmptyDataError:
section.markdown("""
### JAFFAL fusion transcript summary
This table summarizes putative fusion transcripts identified This section summarizes putative fusion transcripts identified
by [JAFFAL](https://github.com/Oshlack/JAFFA/). by [JAFFAL](https://github.com/Oshlack/JAFFA/).
* genes: the gene symbols of the fusion partners No fusion transcripts detected for current sample.
* nreads: The number of reads supporting the fusion """)
* classification: JAFFAL's classification else:
* known: whether this fusion is in the given set of known gene fusions sid_col = df.pop('sample_id')
* chroms: the respective, original chromosome location of the two partner df.insert(0, 'sample_id', sid_col)
genes
""") df = df[cols]
section.table(df) df['chroms'] = df.chrom1.astype(str) + ':' + df.chrom2.astype(str)
df.rename(columns={
'spanning reads': 'nreads',
'fusion genes': 'genes'}, inplace=True)
df.drop(columns=['chrom1', 'chrom2'], inplace=True)
section.markdown("""
### JAFFAL fusion transcript summary
This table summarizes putative fusion transcripts identified
by [JAFFAL](https://github.com/Oshlack/JAFFA/).
* genes: the gene symbols of the fusion partners
* nreads: The number of reads supporting the fusion
* classification: JAFFAL's classification
* known: whether this fusion is in the given set of known gene fusions
* chroms: the respective, original chromosome location of the
two partner genes
""")
section.table(df)
def de_section(report): def de_section(report):

View File

@ -454,7 +454,6 @@ workflow pipeline {
jaffal_out = file("$projectDir/data/OPTIONAL_FILE_1") jaffal_out = file("$projectDir/data/OPTIONAL_FILE_1")
} }
get_transcriptome( get_transcriptome(
merge_gff_bundles.out.gff merge_gff_bundles.out.gff
.join(run_gffcompare.out.gffcmp_dir) .join(run_gffcompare.out.gffcmp_dir)

View File

@ -12,6 +12,8 @@ process jaffal{
script: script:
""" """
JAFFAOUT=jaffal_output_$sample_id JAFFAOUT=jaffal_output_$sample_id
# JAFFAL exists with status code 1 when there's 0 fusion hits. Prevent this with '||:'
$params.jaffal_dir/tools/bin/bpipe run \ $params.jaffal_dir/tools/bin/bpipe run \
-n $params.threads \ -n $params.threads \
-p jaffa_output="\$JAFFAOUT/" \ -p jaffa_output="\$JAFFAOUT/" \
@ -20,14 +22,26 @@ process jaffal{
-p annotation=$annotation \ -p annotation=$annotation \
-p fastqInputFormat="*.fastq" \ -p fastqInputFormat="*.fastq" \
$params.jaffal_dir/JAFFAL.groovy \ $params.jaffal_dir/JAFFAL.groovy \
$fastq $fastq || :
mv "\$JAFFAOUT/jaffa_results.csv" "\$JAFFAOUT/${sample_id}_jaffa_results.csv"
# Add sample id column summary="\$JAFFAOUT/all/all.summary"
sed "s/\$/,${sample_id}/" \$JAFFAOUT/${sample_id}_jaffa_results.csv > tmp1
# Add header if [ -f \$summary ]; then
sed "1 s/${sample_id}/sample_id/" tmp1 > tmp2 # The summary is writtten so assume JAFFAL completed.
mv tmp2 \$JAFFAOUT/${sample_id}_jaffa_results.csv if [ ! -s \$summary ]; then
echo "JAFFAL failed to find any fusion transcripts for ${sample_id}"
touch "\$JAFFAOUT/${sample_id}_jaffa_results.csv"
else
echo JAFFAL found fusion transcripts for ${sample_id}
mv "\$JAFFAOUT/jaffa_results.csv" "\$JAFFAOUT/${sample_id}_jaffa_results.csv"
# Add sample id column and header
sed "s/\$/,${sample_id}/" \$JAFFAOUT/${sample_id}_jaffa_results.csv \
| sed "1 s/${sample_id}/sample_id/" > tmp
mv tmp \$JAFFAOUT/${sample_id}_jaffa_results.csv
fi
else
echo JAFFAL encountered an error while prosessing ${sample_id}
fi
""" """
} }