Skip to content

Commit

Permalink
phylogenetics is now optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Phuong-Le committed Jun 3, 2024
1 parent 2c11a84 commit 3bd5484
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
22 changes: 8 additions & 14 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,27 @@ workflow {
.splitCsv( header: true, sep : '\t' )
.map { row -> tuple( row.match_normal_id, row.sample_id, row.bam, row.bai ) }
pileup_sample = conpairPileupSample(sample_pileup_input_ch)
// pileup_sample.view()
// normal
match_pileup_input_ch = Channel.of(sample_paths)
.splitCsv( header: true, sep : '\t' )
.map { row -> tuple( row.match_normal_id, row.match_normal_id, row.bam_match, row.bai_match ) }
.unique()
pileup_match = conpairPileupMatch(match_pileup_input_ch)
// pileup_match.view()

// Concordance between sample and match normal
concordance_input_ch = pileup_sample.combine(pileup_match)
.map { sample -> tuple(sample[1], sample[2], sample[3], sample[5]) }
// concordance_input_ch.view()
concordance_output_ch = verifyConcordance(concordance_input_ch)
.collectFile( name: 'concordance.txt', newLine: true )
// concordance_output_ch.view()

// Contamination
contamination_input_ch = pileup_match.cross(pileup_sample)
.map { sample -> tuple(sample[0][0], sample[0][2], sample[1][1], sample[1][2] ) }
// contamination_input_ch.view()
.map { sample -> tuple(sample[0][0], sample[0][2], sample[1][1], sample[1][2]) }
contamination_output_ch = conpairContamination(contamination_input_ch)
.collectFile( name: 'contamination.txt', newLine: true )
// contamination_output_ch.view()

// Filtering contamination based on concordance and contamination
(sample_paths_conpaired, conpair_log, concordance_path, contamination_path) = conpairFilter(concordance_output_ch, contamination_output_ch, params.sample_paths)
// sample_paths_conpaired.view()


// filtered sample paths will replace sample paths from here
Expand Down Expand Up @@ -104,22 +97,23 @@ workflow {
.map( sample -> tuple(sample[0][0], sample[1][1], sample[1][2], sample[1][3], sample[1][4], sample[0][1]) )
(bbinom_filtered_vcf_ch, filtered_sigprofiler_vcf_ch) = betaBinomFilter(beta_binom_filter_input_ch)

phylogenetics_input_ch.view()

// Phylogenetics, only run this if there are more than 2 sample per donor (genotype_bin only has one column), AND if mutation type is snp
// work in progress
if (params.mut_type == 'snp') {
if (params.mut_type == 'snp' && params.phylogenetics == true) {
phylogenetics_input__filtered_ch = phylogenetics_input_ch.filter { it[3].readLines().first().split(' ').size() > 2 }
phylogenetics_input__filtered_ch.view()
(branched_vcf, other_files, mpboot_log) = getPhylogeny(phylogenetics_input_ch)
// generate mutation matrix for the branches by SigProfilerMatrixGenerator
(matrix_by_branches_ch, vcf_with_header_ch) = matrixGeneratorOnBranches(branched_vcf)
matrix_by_branches_ch.view()
concatMatrices(matrix_by_branches_ch.toList())
}

// generate mutation matrix for the samples by SigProfilerMatrixGenerator
matrixGeneratorOnSamples(filtered_sigprofiler_vcf_ch.toList())

// generate mutation matrix for the branches by SigProfilerMatrixGenerator
(matrix_by_branches_ch, vcf_with_header_ch) = matrixGeneratorOnBranches(branched_vcf)
matrix_by_branches_ch.view()
concatMatrices(matrix_by_branches_ch.toList())


// // // split reference genome if not cached (ie if cachedir is empty)
// // if ( file(params.reference_genome_cachedir).listFiles().toList().isEmpty() ) {
Expand Down
4 changes: 2 additions & 2 deletions modules/concatMatrices.nf
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
process concatMatrices {

publishDir "${params.outdir}", overwrite: false

input:
path matrix_dirs, stageAs: "indir/*"
path matrix_dirs, stageAs: "indir/matrix_generator*"

output:
path outdir
Expand Down
7 changes: 7 additions & 0 deletions modules/validate.nf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ validParams = [
mut_type: 'str',
reference_genome: 'path',
high_depth_region: 'path',
phylogenetics: 'boolean',
reference_genome_cachedir: 'path',
mutmat_kmer: 'int',
outdir: 'path',
Expand Down Expand Up @@ -63,6 +64,12 @@ void validate(Map params) {
}
break

case 'boolean':
if (value !instanceof Boolean) {
invalidValues[key] = [value, 'boolean value']
}
break

case '':
break

Expand Down
1 change: 1 addition & 0 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ params {
reference_genome = ""
high_depth_region = ""
reference_genome_cachedir = ""
phylogenetics = true
mutmat_kmer = 3
outdir = ""
}
Expand Down

0 comments on commit 3bd5484

Please sign in to comment.