Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sfitz concat vcf #213

Merged
merged 18 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ include { muse } from './module/muse' addParams(
include { intersect } from './module/intersect' addParams(
workflow_output_dir: "${params.output_dir_base}/intersect-BCFtools-${params.BCFtools_version}",
workflow_log_output_dir: "${params.log_output_dir}/process-log/intersect-BCFtools-${params.BCFtools_version}",
output_filename: generate_standard_filename("Consensus",
output_filename: generate_standard_filename("BCFtools_${params.BCFtools_version}",
yashpatel6 marked this conversation as resolved.
Show resolved Hide resolved
params.dataset_id,
params.sample_id,
[:]))
Expand Down
13 changes: 6 additions & 7 deletions module/intersect-processes.nf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ process intersect_VCFs_BCFtools {
publishDir path: "${params.workflow_output_dir}/output",
mode: "copy",
pattern: "isec-2-or-more"
publishDir path: "${params.workflow_output_dir}/output",
mode: "copy",
pattern: "isec-1-or-more/*.txt"
publishDir path: "${params.workflow_log_output_dir}",
mode: "copy",
pattern: ".command.*",
Expand All @@ -31,7 +34,7 @@ process intersect_VCFs_BCFtools {
path "*.vcf.gz.tbi", emit: consensus_idx
path ".command.*"
path "isec-2-or-more"
path "isec-1-or-more", emit: isec_dir
path "isec-1-or-more/*.txt", emit: isec

script:
vcf_list = vcfs.join(' ')
Expand All @@ -52,27 +55,23 @@ process intersect_VCFs_BCFtools {
publishDir path: "${params.workflow_output_dir}/output",
mode: "copy",
pattern: "*.tiff"
publishDir path: "${params.workflow_output_dir}/output",
mode: "copy",
pattern: "isec-1-or-more/*.txt"
publishDir path: "${params.workflow_log_output_dir}",
mode: "copy",
pattern: ".command.*",
saveAs: { "${task.process.replace(':', '/')}/log${file(it).getName()}" }

input:
path script_dir
path isec_dir
path isec

output:
path "isec-1-or-more/*.txt"
path ".command.*"
path "*.tiff"

script:
"""
set -euo pipefail
Rscript ${script_dir}/plot-venn.R --isec_dir ${isec_dir} --outfile ${params.output_filename}_Venn-diagram.tiff
Rscript ${script_dir}/plot-venn.R --isec_readme README.txt --isec_sites sites.txt --outfile ${params.output_filename}_Venn-diagram.tiff
tyamaguchi-ucla marked this conversation as resolved.
Show resolved Hide resolved
"""
}

Expand Down
2 changes: 1 addition & 1 deletion module/intersect.nf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ workflow intersect {
)
plot_VennDiagram_R(
script_dir_ch,
intersect_VCFs_BCFtools.out.isec_dir,
intersect_VCFs_BCFtools.out.isec,
)
concat_VCFs_BCFtools(
intersect_VCFs_BCFtools.out.consensus_vcf,
Expand Down
16 changes: 9 additions & 7 deletions r-scripts/plot-venn.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Script to plot a Venn diagram of shared variants from the different SNV calling algorithms, using the output of BCFtools isec
# Initial commit: Sorel Fitz-Gibbon 2023-06-29
# Input:
# -i, --isec_dir: The directory containing the output from BCFtools intersect
# -d, --dataset: The dataset ID passed from nextflow
# -r, --isec_readme: The README.txt file from BCFtools intersect
# -s, --isec_sites: The sites.txt file from BCFtools intersect
# -o, --outfile: The output filename
# Output:
# - A Venn diagram of shared variant counts from the BCFtools intersection of the VCF files

Expand All @@ -12,7 +13,8 @@ library('VennDiagram');

## Parse the arguments #############################################################################
parser <- ArgumentParser();
parser$add_argument('-i', '--isec_dir', help = 'The directory containing the output from BCFtools intersect', type = 'character');
parser$add_argument('-r', '--isec_readme', help = 'The directory containing the output from BCFtools intersect', type = 'character');
parser$add_argument('-s', '--isec_sites', help = 'The directory containing the output from BCFtools intersect', type = 'character');
yashpatel6 marked this conversation as resolved.
Show resolved Hide resolved
parser$add_argument('-o', '--outfile', help = 'Output filename', type = 'character');
args <- parser$parse_args();

Expand All @@ -31,11 +33,11 @@ plot.venn <- function(tool.variants, outfile) {

### Main ###########################################################################################
# Get intersection counts from BCFtools isec output and format for plotting
algorithms <- readLines(file.path(args$isec_dir,'README.txt'));
algorithms <- algorithms[grep(paste0('^', args$isec_dir), algorithms)];
algorithms <- gsub(paste0(args$isec_dir,'.*\t'), '', algorithms);
algorithms <- readLines(args$isec_readme);
tyamaguchi-ucla marked this conversation as resolved.
Show resolved Hide resolved
algorithms <- algorithms[grep('^isec-1-or-more', algorithms)];
algorithms <- gsub('isec-1-or-more.*\t', '', algorithms);
algorithms <- gsub('-.*', '', algorithms);
sites <- read.table(file.path(args$isec_dir,'sites.txt'), header = FALSE, colClasses = 'character');
sites <- read.table(args$isec_sites, header = FALSE, colClasses = 'character');
split.col <- strsplit(as.character(sites$V5), '');
sites$col1 <- sapply(split.col, '[', 1);
sites$col2 <- sapply(split.col, '[', 2);
Expand Down
Loading