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

Add metric parameter suffixes #155

Merged
merged 6 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,25 @@ jobs:
- name: Run pipeline with test data and wfmash_only parameters
run: |
nextflow run ${GITHUB_WORKSPACE} -profile test,docker --outdir ./results ${{ matrix.parameters }}

metric_parameter_suffixes:
name: Run pipeline with metric parameter suffixes
# Only run on push if this is the nf-core dev branch (merged PRs)
if: "${{ github.event_name != 'push' || (github.event_name == 'push' && github.repository == 'nf-core/pangenome') }}"
runs-on: ubuntu-latest
strategy:
matrix:
parameters:
- "--wfmash_sequence_length 8k --wfmash_block_length 38K --seqwish_transclose_batch 9M"
steps:
- name: Check out pipeline code
uses: actions/checkout@v3

- name: Install Nextflow
uses: nf-core/setup-nextflow@v1
with:
version: "23.04.0"

- name: Run pipeline with test data and wfmash_only parameters
run: |
nextflow run ${GITHUB_WORKSPACE} -profile test,docker --outdir ./results ${{ matrix.parameters }}
65 changes: 56 additions & 9 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,53 @@ def generate_smoothxg_poa_params_cmd() {

def smoothxg_poa_params_cmd = generate_smoothxg_poa_params_cmd()

def parse_int(int s) {
return s
}

def parse_int(String s) {
def p = /\d+[KkMmGgTt]?$/
def out = 890
heringerp marked this conversation as resolved.
Show resolved Hide resolved
heringerp marked this conversation as resolved.
Show resolved Hide resolved
if (s ==~ p) {
if (s.isInteger()) {
out = s.toInteger()
} else {
def intti = s.substring(0, s.length() - 1).toInteger()
heringerp marked this conversation as resolved.
Show resolved Hide resolved
def suffixi = s.substring(s.length() - 1, s.length())
//Evaluating the expression value
switch(suffixi) {
//There is case statement defined for 4 cases
heringerp marked this conversation as resolved.
Show resolved Hide resolved
// Each case statement section has a break condition to exit the loop

case "k":
case "K":
out = intti * 1000
break;
case "m":
case "M":
out = intti * 1000000
break;
case "g":
case "G":
out = intti * 1000000000
break;
case "t":
case "T":
out = intti * 1000000000000
break;
default:
//println("The value is unknown");
heringerp marked this conversation as resolved.
Show resolved Hide resolved
// we will never hit this case
break;
}
}
} else {
// errorrrrr
heringerp marked this conversation as resolved.
Show resolved Hide resolved
return 0
}
return out
}

process {

publishDir = [
Expand All @@ -67,12 +114,12 @@ process {
ext.args = {
[
"-n ${params.n_haplotypes - 1}",
"-s ${params.wfmash_segment_length}",
"-s ${parse_int(params.wfmash_segment_length)}",
"-p ${params.wfmash_map_pct_id}",
params.wfmash_merge_segments ? "-M" : "",
params.wfmash_exclude_delim ? "-Y ${params.wfmash_exclude_delim}" : "-X",
params.wfmash_no_splits ? "-N" : "",
params.wfmash_block_length ? "-l ${params.wfmash_block_length}" : "-l ${params.wfmash_segment_length * 5}",
params.wfmash_block_length ? "-l ${parse_int(params.wfmash_block_length)}" : "-l ${parse_int(params.wfmash_segment_length) * 5}",
"-k ${params.wfmash_mash_kmer}",
"-H ${params.wfmash_mash_kmer_thres}",
"${wfmash_sparse_map_cmd}",
Expand All @@ -90,12 +137,12 @@ process {
ext.args = {
[
"-n ${params.n_haplotypes - 1}",
"-s ${params.wfmash_segment_length}",
"-s ${parse_int(params.wfmash_segment_length)}",
"-p ${params.wfmash_map_pct_id}",
params.wfmash_merge_segments ? "-M" : "",
params.wfmash_exclude_delim ? "-Y ${params.wfmash_exclude_delim}" : "-X",
params.wfmash_no_splits ? "-N" : "",
params.wfmash_block_length ? "-l ${params.wfmash_block_length}" : "-l ${params.wfmash_segment_length * 5}",
params.wfmash_block_length ? "-l ${parse_int(params.wfmash_block_length)}" : "-l ${parse_int(params.wfmash_segment_length) * 5}",
"-k ${params.wfmash_mash_kmer}",
"-H ${params.wfmash_mash_kmer_thres}",
"${wfmash_sparse_map_cmd}",
Expand All @@ -114,12 +161,12 @@ process {
ext.args = {
[
"-n ${params.n_haplotypes - 1}",
"-s ${params.wfmash_segment_length}",
"-s ${parse_int(params.wfmash_segment_length)}",
"-p ${params.wfmash_map_pct_id}",
params.wfmash_merge_segments ? "-M" : "",
params.wfmash_exclude_delim ? "-Y ${params.wfmash_exclude_delim}" : "-X",
params.wfmash_no_splits ? "-N" : "",
params.wfmash_block_length ? "-l ${params.wfmash_block_length}" : "-l ${params.wfmash_segment_length * 5}",
params.wfmash_block_length ? "-l ${parse_int(params.wfmash_block_length)}" : "-l ${parse_int(params.wfmash_segment_length) * 5}",
"-k ${params.wfmash_mash_kmer}",
"-H ${params.wfmash_mash_kmer_thres}",
"${wfmash_sparse_map_cmd}",
Expand Down Expand Up @@ -147,12 +194,12 @@ process {
ext.args = {
[
"-n ${params.n_haplotypes - 1}",
"-s ${params.wfmash_segment_length}",
"-s ${parse_int(params.wfmash_segment_length)}",
"-p ${params.wfmash_map_pct_id}",
params.wfmash_merge_segments ? "-M" : "",
params.wfmash_exclude_delim ? "-Y ${params.wfmash_exclude_delim}" : "-X",
params.wfmash_no_splits ? "-N" : "",
params.wfmash_block_length ? "-l ${params.wfmash_block_length}" : "-l ${params.wfmash_segment_length * 5}",
params.wfmash_block_length ? "-l ${parse_int(params.wfmash_block_length)}" : "-l ${parse_int(params.wfmash_segment_length) * 5}",
"-k ${params.wfmash_mash_kmer}",
"-H ${params.wfmash_mash_kmer_thres}",
"${wfmash_sparse_map_cmd}",
Expand All @@ -173,7 +220,7 @@ process {
[
"-k ${params.seqwish_min_match_length}",
"-f ${params.seqwish_sparse_factor}",
"-B ${params.seqwish_transclose_batch}",
"-B ${parse_int(params.seqwish_transclose_batch)}",
"-P",
params.seqwish_temp_dir ? "--temp-dir ${params.seqwish_temp_dir}" : ""
].join(" ").trim()
Expand Down
18 changes: 10 additions & 8 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,17 @@
"help_text": "Use `mash dist` or `mash triangle` to explore the typical level of divergence between the sequences in your input (see https://pggb.readthedocs.io/en/latest/rst/tutorials/divergence_estimation.html#divergence-estimation for more information). Convert this to an approximate percent identity and provide it as --wfmash_map_pct_id <PCT>. A list of examples can be found at https://github.com/pangenome/pggb#example-builds-for-diverse-species."
},
"wfmash_segment_length": {
"type": "integer",
"default": 5000,
"type": "string",
"default": "5K",
heringerp marked this conversation as resolved.
Show resolved Hide resolved
"description": "Segment length for mapping.",
"help_text": "Crucially, --wfmash_segment_length provides a kind of minimum alignment length filter. The `mashmap3` step in `wfmash` will only consider segments of this size. For small pangenome graphs, or where there are few repeats, --wfmash_segment_length can be set low (for example 500 when building a MHC pangenome graph). However, for larger contexts, with repeats, it can be very important to set this high (for instance 50k in the case of human genomes). A long segment length ensures that we represent long collinear regions of the input sequences in the structure of the graph. In general, this should at least be larger than transposons and other common repeats in your pangenome. A list of examples can be found at https://github.com/pangenome/pggb#example-builds-for-diverse-species."
"help_text": "Crucially, --wfmash_segment_length provides a kind of minimum alignment length filter. The `mashmap3` step in `wfmash` will only consider segments of this size. For small pangenome graphs, or where there are few repeats, --wfmash_segment_length can be set low (for example 500 when building a MHC pangenome graph). However, for larger contexts, with repeats, it can be very important to set this high (for instance 50k in the case of human genomes). A long segment length ensures that we represent long collinear regions of the input sequences in the structure of the graph. In general, this should at least be larger than transposons and other common repeats in your pangenome. A list of examples can be found at https://github.com/pangenome/pggb#example-builds-for-diverse-species.",
"pattern": "^([1-9]\\d*[kKmMgGtT]?|0)$"
},
"wfmash_block_length": {
"type": "string",
"default": "wfmash_segment_length * 5",
"description": "Minimum block length filter for mapping.",
"help_text": "By default, wfmash only keeps mappings with at least 5 times the size of a segment. This can be adjusted with --wfmash_block_length <BLOCK_LENGTH>."
"help_text": "By default, wfmash only keeps mappings with at least 5 times the size of a segment. This can be adjusted with --wfmash_block_length <BLOCK_LENGTH>.",
"pattern": "^([1-9]\\d*[kKmMgGtT]?|0)$"
},
"wfmash_mash_kmer": {
"type": "integer",
Expand Down Expand Up @@ -130,10 +131,11 @@
"help_text": "Graph induction with seqwish often works better when we filter very short matches out of the input alignments. In practice, these often occur in regions of low alignment quality, which are typical of areas with large INDELs and structural variations in the wfmash alignments. This underalignment is then resolved in the smoothxg step. Removing short matches can simplify the graph and remove spurious relationships caused by short repeated homologies.\nA setting of --seqwish_min_match_length 47 is optimal for around 5% divergence, and we suggest lowering it for higher divergence and increasing it for lower divergence. Values up to --seqwish_min_match_length 311 work well for human haplotypes. In effect, setting --seqwish_min_match_length to N means that we can tolerate a local pairwise difference rate of no more than 1/N. Thus, INDELs which may be represented by complex series of edit operations will be opened into bubbles in the induced graph, and alignment regions with very low identity will be ignored. Using affine-gapped alignment (such as with minimap2) may reduce the impact of this step by representing large indels more precisely in the input alignments. However, it remains important due to local inconsistency in alignments in low-complexity sequence."
},
"seqwish_transclose_batch": {
"type": "integer",
"default": 10000000,
"type": "string",
"default": "10M",
"description": "Number of base pairs to use for transitive closure batch.",
"help_text": "If you run out of memory during the seqwish step, you can lower this value. It will take longer, but it will use less memory."
"help_text": "If you run out of memory during the seqwish step, you can lower this value. It will take longer, but it will use less memory.",
"pattern": "^([1-9]\\d*[kKmMgGtT]?|0)$"
},
"seqwish_sparse_factor": {
"type": "number",
Expand Down