Skip to content

Commit

Permalink
preparing for main report
Browse files Browse the repository at this point in the history
  • Loading branch information
zachary-foster committed Aug 8, 2023
1 parent f519529 commit 0a48b5e
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 27 deletions.
53 changes: 53 additions & 0 deletions assets/main_report.Rmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: "Test report for core genome phylogeny"
output: html_document
date: "`r format(Sys.time(), '%d %B, %Y')`"
params:
ref_meta: "/home/fosterz/files/projects/work/current/nf-core-plantpathsurveil/test/output_full/iqtree2/input_alignments.treefile"
core_phylo: "/media/fosterz/external_primary/files/projects/work/current/nf-core-plantpathsurveil/test/data/metadata_medium.csv"
---

```{r include=FALSE, eval=FALSE}
params = list(
ref_meta = "/home/fosterz/files/projects/work/current/nf-core-plantpathsurveil/test/output_full/iqtree2/input_alignments.treefile",
ref_meta = "/media/fosterz/external_primary/files/projects/work/current/nf-core-plantpathsurveil/test/data/metadata_medium.csv"
)
```


```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## Prepare

Load required libraries.

```{r}
library(ggtree)
library(treeio)
```


Load metadata.

```{r}
metadata <- read.csv(params$metadata)
metadata$sample <- paste0(metadata$sample, "_T1")
```

Load treefile.

```{r}
tree <- read.newick(params$treefile)
```

plot tree

```{r}
ggplot(tree, aes(x, y)) +
geom_tree() +
theme_tree() +
geom_tiplab(as_ylab = FALSE, color = '#555555')
```

41 changes: 41 additions & 0 deletions modules/local/mainreport.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
process MAIN_REPORT {
tag "$group_meta.id"
label 'process_low'

conda "conda-forge::r-base conda-forge::r-rmarkdown conda-forge::r-yaml conda-forge::r-poppr conda-forge::r-adegenet conda-forge::r-ape conda-forge::r-readr conda-forge::r-igraph"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/mulled-v2-31ad840d814d356e5f98030a4ee308a16db64ec5:0e852a1e4063fdcbe3f254ac2c7469747a60e361-0' :
'quay.io/biocontainers/mulled-v2-31ad840d814d356e5f98030a4ee308a16db64ec5:0e852a1e4063fdcbe3f254ac2c7469747a60e361-0' }"

input:
tuple val(group_meta), val(ref_metas), file(snp_phylos), file(ani_matrix), file(core_phylo)
path samp_stats
path ref_stats

output:
tuple val(ref_meta), path("*.html"), emit: html
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${group_meta.id}"
"""
Rscript -e "workdir<-getwd()
rmarkdown::render('${projectDir}/assets/main_report.Rmd',
params = list(
ref_meta = \\\"$ref_meta\\\",
core_phylo = \\\"$core_phylo\\\"
),
output_file = \\\"${prefix}_report.html\\\",
knit_root_dir=workdir,
output_dir=workdir)"
cat <<-END_VERSIONS > versions.yml
"${task.process}":
rmarkdown: \$(Rscript -e "cat(paste(packageVersion('rmarkdown'), collapse='.'))")
END_VERSIONS
"""
}
1 change: 1 addition & 0 deletions subworkflows/local/assign_references.nf
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,6 @@ workflow ASSIGN_REFERENCES {

emit:
sample_data = new_sample_data // [val(meta), [file(fastq)], val(ref_meta), file(reference), val(group_meta)]
ani_matrix = SOURMASH_COMPARE.out.csv // [val(group_meta), val(csv)]
versions = ch_versions // channel: [ versions.yml ]
}
2 changes: 1 addition & 1 deletion subworkflows/local/call_variants.nf
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ workflow CALL_VARIANTS {
ch_versions = ch_versions.mix(VCFLIB_VCFFILTER.out.versions.toSortedList().map{it[0]})

emit:
vcf = VCFLIB_VCFFILTER.out.vcf // channel: [ ref_meta, vcf ]
vcf = VCFLIB_VCFFILTER.out.vcf // channel: [ val(ref+group_meta), fil(vcf) ]
versions = ch_versions // channel: [ versions.yml ]
}

1 change: 1 addition & 0 deletions subworkflows/local/core_genome_phylogeny.nf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ workflow CORE_GENOME_PHYLOGENY {

emit:
pirate_aln = PIRATE.out.aln // channel: [ ref_meta, align_fasta ]
phylogeny = IQTREE2.out.phylogeny // channel: [ group_meta, tree ]

versions = ch_versions // channel: [ versions.yml ]
}
Expand Down
9 changes: 5 additions & 4 deletions subworkflows/local/download_references.nf
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ workflow DOWNLOAD_REFERENCES {

emit:
assem_samp_combos = genome_ids // [ val(genome_id), val(meta) ] for each assembly/sample combination
sequence = DOWNLOAD_ASSEMBLIES.out.sequence // [ val(genome_id), file(fna) ] for each assembly
gff = MAKEGFFWITHFASTA.out.gff // [ val(genome_id), file(gff) ] for each assembly
signatures = SOURMASH_SKETCH_GENOME.out.signatures // [ val(genome_id), file(signature) ] for each assembly
versions = ch_versions // [ versions.yml ]
sequence = DOWNLOAD_ASSEMBLIES.out.sequence // [ val(genome_id), file(fna) ] for each assembly
gff = MAKEGFFWITHFASTA.out.gff // [ val(genome_id), file(gff) ] for each assembly
signatures = SOURMASH_SKETCH_GENOME.out.signatures // [ val(genome_id), file(signature) ] for each assembly
stats = MERGE_ASSEMBLIES.out.merged_stats.map { it[1] } // [ file(stats) ]
versions = ch_versions // [ versions.yml ]
}
3 changes: 3 additions & 0 deletions subworkflows/local/variant_calling_analysis.nf
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ workflow VARIANT_CALLING_ANALYSIS {
samtools_fai = MAKE_REFERENCE_INDEX.out.samtools_fai
samtools_gzi = MAKE_REFERENCE_INDEX.out.samtools_gzi
bwa_index = MAKE_REFERENCE_INDEX.out.bwa_index
phylogeny = IQTREE2_SNP.out.phylogeny
.map { [it[0].group, it[0].ref, it[1]] } // channel: [ group_meta, ref_meta, tree ]

versions = ch_versions // channel: [ versions.yml ]

}
Expand Down
35 changes: 13 additions & 22 deletions workflows/plantpathsurveil.nf
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ include { DOWNLOAD_REFERENCES } from '../subworkflows/local/download_refere
include { ASSIGN_REFERENCES } from '../subworkflows/local/assign_references'
include { GENOME_ASSEMBLY } from '../subworkflows/local/genome_assembly'

include { MAIN_REPORT } from '../modules/local/mainreport'

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -142,29 +143,19 @@ workflow PLANTPATHSURVEIL {
//READ2TREE_ANALYSIS (
//)

// Create main summary report
report_in = VARIANT_CALLING_ANALYSIS.out.phylogeny // [ group_meta, ref_meta, tree ]
.groupTuple() // [ group_meta, [ref_meta], [tree] ]
.join(ASSIGN_REFERENCES.out.ani_matrix) // [ group_meta, [ref_meta], [tree], ani_matrix ]
.join(CORE_GENOME_PHYLOGENY.out.phylogeny, remainder: true) // [ group_meta, [ref_meta], [snp_tree], ani_matrix, core_tree ]
.map { it + [ch_input, ASSIGN_REFERENCES.out.stats] }.view()

MAIN_REPORT (
report_in,
ch_input,
DOWNLOAD_REFERENCES.out.stats.first()
)


//COARSE_SAMPLE_TAXONOMY.out.kingdom
//.join(COARSE_SAMPLE_TAXONOMY.out.hits)
//.join(INPUT_CHECK.out.reads_and_ref)
//.branch {
// bacteria: it[1] == "Bacteria"
// eukaryote: it[1] == "Eukaryota"
// unknown: true
//}
//.set { subpipeline_input }
//
//BACTERIAPIPELINE (
// subpipeline_input.bacteria,
// ch_input
//)
//ch_versions = ch_versions.mix(BACTERIAPIPELINE.out.versions)
//EUKARYOTEPIPELINE (
// subpipeline_input.eukaryote,
// ch_input
//)
//ch_versions = ch_versions.mix(EUKARYOTEPIPELINE.out.versions)

// Save version info
CUSTOM_DUMPSOFTWAREVERSIONS (
ch_versions.unique().collect(sort:true)
Expand Down

0 comments on commit 0a48b5e

Please sign in to comment.