Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions modules/nf-core/ribowaltz/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ process RIBOWALTZ {
tuple val(meta), path("*.cds_coverage_psite.tsv{,.gz}") , emit: cds_coverage , optional: true
tuple val(meta), path("*nt_coverage_psite.tsv{,.gz}") , emit: cds_window_coverage , optional: true
tuple val(meta), path("ribowaltz_qc/*.pdf") , emit: ribowaltz_qc , optional: true
tuple val(meta), path("ribowaltz_qc/*.tsv") , emit: ribowaltz_qc_data , optional: true
path "versions.yml" , emit: versions

when:
Expand All @@ -41,6 +42,9 @@ process RIBOWALTZ {
touch ${prefix}.cds_coverage_psite.tsv
mkdir -p offset_plot/${prefix} && touch offset_plot/${prefix}/29.pdf
mkdir -p ribowaltz_qc && touch ribowaltz_qc/${prefix}.metaprofile_psite.pdf
touch ribowaltz_qc/${prefix}.psite_region.tsv
touch ribowaltz_qc/${prefix}.frames.tsv
touch ribowaltz_qc/${prefix}.frames_stratified.tsv

cat <<-END_VERSIONS > versions.yml
"${task.process}":
Expand Down
13 changes: 13 additions & 0 deletions modules/nf-core/ribowaltz/meta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,19 @@ output:
description: riboWaltz diagnostic plots (optional)
pattern: "ribowaltz_qc/*"
ontologies: []
ribowaltz_qc_data:
- - meta:
type: map
description: |
Groovy Map containing sample information
e.g. `[ id:'sample1', single_end:false ]`
- ribowaltz_qc/*.tsv:
type: file
description: TSV files containing data underlying riboWaltz QC plots including
P-site region distribution, frame distribution, and frame distribution
stratified by read length (optional)
pattern: "ribowaltz_qc/*.tsv"
ontologies: []
versions:
- versions.yml:
type: file
Expand Down
15 changes: 15 additions & 0 deletions modules/nf-core/ribowaltz/templates/ribowaltz.r
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,11 @@ save_psite_region_plot <- function(sample_name, dt.ls, annotation.df) {

ggplot2::ggsave(paste0(getwd(), "/ribowaltz_qc/", sample_name, ".psite_region.pdf"), psite_region.gg, dpi = 400, width = 10)

# Export underlying data
region_dt <- psite_region[["count_dt"]]
if (!is.null(region_dt)) {
data.table::fwrite(region_dt, paste0(getwd(), "/ribowaltz_qc/", sample_name, ".psite_region.tsv"), sep = "\t")
}
}

#' Save Frame Plots
Expand Down Expand Up @@ -329,12 +334,22 @@ save_frame_plots <- function(sample_name, dt.ls, annotation.df, min_length, max_

ggplot2::ggsave(paste0(getwd(), "/ribowaltz_qc/", sample_name, ".frames_stratified.pdf"), frames_stratified.gg, dpi = 600, height = 9 , width = 12)

# Export underlying data for stratified frames
frames_stratified_dt <- frames_stratified[["count_dt"]]
if (!is.null(frames_stratified_dt)) {
data.table::fwrite(frames_stratified_dt, paste0(getwd(), "/ribowaltz_qc/", sample_name, ".frames_stratified.tsv"), sep = "\t")
}

frames <- riboWaltz::frame_psite(dt.ls, region = "all", length_range = min_length:max_length, sample = sample_name, annotation = annotation.df, colour = "grey70")
frames.gg <- frames[[paste0("plot_", sample_name)]]

ggplot2::ggsave(paste0(getwd(), "/ribowaltz_qc/", sample_name, ".frames.pdf"), frames.gg, dpi = 600, height = 9 , width = 9)

# Export underlying data for aggregated frames
frames_dt <- frames[["count_dt"]]
if (!is.null(frames_dt)) {
data.table::fwrite(frames_dt, paste0(getwd(), "/ribowaltz_qc/", sample_name, ".frames.tsv"), sep = "\t")
}
}


Expand Down
2 changes: 2 additions & 0 deletions modules/nf-core/ribowaltz/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ nextflow_process {
{ assert snapshot(process.out.cds_coverage).match('cds_coverage') },
{ assert snapshot(process.out.cds_window_coverage).match('cds_window_coverage') },
{ assert snapshot(process.out.ribowaltz_qc.size() == 8) },
{ assert snapshot(process.out.ribowaltz_qc_data.size() == 3) },
{ assert snapshot(process.out.versions).match('versions') }
)
}
Expand Down Expand Up @@ -69,6 +70,7 @@ nextflow_process {
{ assert snapshot(process.out.codon_coverage_psite).match('codon_coverage_psite_stub') },
{ assert snapshot(process.out.cds_coverage).match('cds_coverage_stub') },
{ assert snapshot(process.out.ribowaltz_qc.size() == 1) },
{ assert snapshot(process.out.ribowaltz_qc_data.size() == 3) },
{ assert snapshot(process.out.versions).match('versions_stub') }
)
}
Expand Down
Loading