Skip to content

Commit

Permalink
Rlib and config updates
Browse files Browse the repository at this point in the history
  • Loading branch information
katiesevans committed Mar 1, 2022
1 parent 3734895 commit a72d6eb
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 42 deletions.
8 changes: 4 additions & 4 deletions conf/quest.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Configuration for Quest (slurm)


process {
// process {

conda = "/projects/b1059/software/conda_envs/concordance-nf_env"
module = 'R/3.6.0'
}
// conda = "/projects/b1059/software/conda_envs/concordance-nf_env"
// module = 'R/3.6.0'
// }

params {

Expand Down
8 changes: 4 additions & 4 deletions conf/quest_debug.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

// For quest debug

singularity { singularity.enabled = true }
// singularity { singularity.enabled = true }

process {

Expand All @@ -14,18 +14,18 @@ process {
// }

// container = 'docker://faithman/concordance:latest'
module = "R/3.6.0"
// module = "R/3.6.0"

}

params {
debug = true
date = new Date().format( 'yyyyMMdd' )
genome = "WS245"
genome = "WS283"
fq_file_prefix = "test_data"
params.out = "DEBUG_concordance-${date}"
//reference = "WS245/WS245.fa.gz"
reference = "/projects/b1059/data/genomes/c_elegans/${genome}"
// reference = "/projects/b1059/data/genomes/c_elegans/${genome}"
fq_file = 'test_data/sample_sheet.tsv'

min_depth = 0
Expand Down
59 changes: 25 additions & 34 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ date = new Date().format( 'yyyyMMdd' )
params.out = "concordance-${date}"
params.debug = false
params.help = false
//params.info_sheet = "(required)"
params.species == "c_elegans"
params.R_libpath = "/projects/b1059/software/R_lib_3.6.0"


// Debug
Expand Down Expand Up @@ -95,16 +93,18 @@ workflow {
vcf_index = Channel.fromPath("${params.vcf}.tbi") // make sure the index format is consistent in process inputs
bam_coverage = Channel.fromPath("${params.bam_coverage}")

hard_filtered_vcf.combine(vcf_index) | (calculate_gtcheck)

if (params.species == "c_elegans") {
// moved npr1 allele check to alignment
// if (params.species == "c_elegans") {

hard_filtered_vcf.combine(vcf_index) | (calculate_gtcheck & npr1_allele_check)
// hard_filtered_vcf.combine(vcf_index) | (calculate_gtcheck & npr1_allele_check)

} else {
// } else {

hard_filtered_vcf.combine(vcf_index) | (calculate_gtcheck)
// hard_filtered_vcf.combine(vcf_index) | (calculate_gtcheck)

}
// }


calculate_gtcheck.out.combine(bam_coverage)
Expand Down Expand Up @@ -137,10 +137,7 @@ process get_species_sheet {
file("*.tsv")

"""
# add R_libpath to .libPaths() into the R script, create a copy into the NF working directory
echo ".libPaths(c(\\"${params.R_libpath}\\", .libPaths() ))" | cat - ${workflow.projectDir}/bin/download_google_sheet.R > download_google_sheet.R
Rscript --vanilla download_google_sheet.R ${params.species}
Rscript --vanilla ${workflow.projectDir}/bin/download_google_sheet.R ${params.species}
"""

Expand Down Expand Up @@ -184,11 +181,8 @@ process process_concordance_results {
file("problem_strains.tsv")

"""
# add R_libpath to .libPaths() into the R script, create a copy into the NF working directory
echo ".libPaths(c(\\"${params.R_libpath}\\", .libPaths() ))" | cat - ${workflow.projectDir}/bin/process_concordance.R > process_concordance.R
# Run concordance analysis
Rscript --vanilla process_concordance.R SM_coverage.tsv WI_info_sheet.tsv ${params.concordance_cutoff}
Rscript --vanilla ${workflow.projectDir}/bin/process_concordance.R SM_coverage.tsv WI_info_sheet.tsv ${params.concordance_cutoff}
"""
}

Expand Down Expand Up @@ -228,10 +222,8 @@ process within_group_pairwise {
isotype = pair_group[2]

"""
echo ".libPaths(c(\\"${params.R_libpath}\\", .libPaths() ))" | cat - ${workflow.projectDir}/bin/plot_pairwise.R > plot_pairwise.R
bcftools query -f '%CHROM\t%POS[\t%GT]\n' -s ${pair} concordance.vcf.gz > out.tsv
Rscript --vanilla plot_pairwise.R ${pair} ${group} ${isotype}
Rscript --vanilla ${workflow.projectDir}/bin/plot_pairwise.R ${pair} ${group} ${isotype}
"""
}
Expand Down Expand Up @@ -327,32 +319,32 @@ process between_group_pairwise {
sp2 = pair_group[1]

"""
echo ".libPaths(c(\\"${params.R_libpath}\\", .libPaths() ))" | cat - ${workflow.projectDir}/bin/process_strain_pairwise.R > process_strain_pairwise.R
csvtk cut -t -f CHROM,POS,${sp1},${sp2} out_gt.tsv > ${sp1}-${sp2}.queried.tsv
Rscript --vanilla process_strain_pairwise.R ${sp1} ${sp2} ${sp1}-${sp2}.queried.tsv
Rscript --vanilla ${workflow.projectDir}/bin/process_strain_pairwise.R ${sp1} ${sp2} ${sp1}-${sp2}.queried.tsv
mv condition_results.tsv ${sp1}-${sp2}.tsv
mv for_distribution.tsv ${sp1}-${sp2}-distribution.tsv
rm ${sp1}-${sp2}.queried.tsv
"""
}

process npr1_allele_check {
// Moved this process to alignment now
// process npr1_allele_check {

cpus params.cores
// cpus params.cores

publishDir "${params.out}/concordance", mode: 'copy', overwrite: true
// publishDir "${params.out}/concordance", mode: 'copy', overwrite: true

input:
tuple file("concordance.vcf.gz"), file("concordance.vcf.gz.tbi") //from npr1_allele
// input:
// tuple file("concordance.vcf.gz"), file("concordance.vcf.gz.tbi") //from npr1_allele

output:
file("npr1_allele_strain.tsv") //into npr1_out
// output:
// file("npr1_allele_strain.tsv") //into npr1_out

"""
echo -e 'problematic_strain\\tgt' > npr1_allele_strain.tsv
bcftools view --threads ${params.cores} -t X:4768788 concordance.vcf.gz | bcftools query -f '[%SAMPLE\\t%GT\\n]' | awk '\$2 != "1/1"' >> npr1_allele_strain.tsv
"""
}
// """
// echo -e 'problematic_strain\\tgt' > npr1_allele_strain.tsv
// bcftools view --threads ${params.cores} -t X:4768788 concordance.vcf.gz | bcftools query -f '[%SAMPLE\\t%GT\\n]' | awk '\$2 != "1/1"' >> npr1_allele_strain.tsv
// """
// }

process merge_betweengroup_pairwise_output {

Expand Down Expand Up @@ -402,8 +394,7 @@ process combine_pairwise_results {
file("new_isotype_groups.tsv")

"""
echo ".libPaths(c(\\"${params.R_libpath}\\", .libPaths() ))" | cat - ${workflow.projectDir}/bin/merge_groups_info.R > merge_groups_info.R
Rscript --vanilla merge_groups_info.R isotype_groups.tsv merge_betweengroup_pairwise_output.tsv npr1_allele_strain.tsv
Rscript --vanilla ${workflow.projectDir}/bin/merge_groups_info.R isotype_groups.tsv merge_betweengroup_pairwise_output.tsv npr1_allele_strain.tsv
"""
}

Expand Down
11 changes: 11 additions & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,14 @@ dag {
file = "${params.tracedir}/${params.timestamp}_dag.svg"
}

singularity {

enabled = true
autoMounts = true

cacheDir = "/projects/b1059/singularity"
pullTimeout = '20 min'
}

process.container = 'andersenlab/concordance'

0 comments on commit a72d6eb

Please sign in to comment.