Skip to content

Commit

Permalink
change --ont defaults and illumina error rate [Mykrobe-tools#133 & My…
Browse files Browse the repository at this point in the history
  • Loading branch information
mbhall88 committed Nov 30, 2021
1 parent 56ee772 commit 0300bd8
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 30 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

### Changed
- Default kmer size (21) made consistent across all subcommands [[#141][141]]
- Nanopore preset `--ont` defaults to an expected error rate of 0.08 and ploidy
'haploid' [[#134][134]]
- Default Illumina expected error rate change from 0.05 to 0.001 [[#133][133]]

### Fixed
- Improved error messaging when an X amino acid resolves to a mutation already present
Expand Down Expand Up @@ -63,6 +66,8 @@ this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
[119]: https://github.com/Mykrobe-tools/mykrobe/issues/119
[123]: https://github.com/Mykrobe-tools/mykrobe/issues/123
[127]: https://github.com/Mykrobe-tools/mykrobe/issues/127
[133]: https://github.com/Mykrobe-tools/mykrobe/issues/133
[134]: https://github.com/Mykrobe-tools/mykrobe/issues/134
[140]: https://github.com/Mykrobe-tools/mykrobe/issues/140
[141]: https://github.com/Mykrobe-tools/mykrobe/issues/141
[Unreleased]: https://github.com/Mykrobe-tools/mykrobe/compare/v0.10.0...HEAD
Expand Down
8 changes: 4 additions & 4 deletions src/mykrobe/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import argparse
import os

from mykrobe import K
from mykrobe import K, ONT_E_RATE, ONT_PLOIDY, ILLUMINA_E_RATE

sequence_or_graph_parser_mixin = argparse.ArgumentParser(add_help=False)
sequence_or_graph_parser_mixin.add_argument(
Expand Down Expand Up @@ -75,7 +75,7 @@
genotyping_mixin.add_argument(
"--ont",
action="store_true",
help="Set default for ONT data. Sets expected_error_rate to 0.15 and to haploid",
help=f"Set defaults for ONT data. Sets `-e {ONT_E_RATE} --ploidy {ONT_PLOIDY}`",
)
genotyping_mixin.add_argument(
"--guess_sequence_method",
Expand Down Expand Up @@ -123,8 +123,8 @@
genotyping_mixin.add_argument(
"-e",
"--expected_error_rate",
help="Expected sequencing error rate (default: %(default).2f)",
default=0.05,
help="Expected sequencing error rate (default: %(default).3f)",
default=ILLUMINA_E_RATE,
type=float,
)
genotyping_mixin.add_argument(
Expand Down
24 changes: 6 additions & 18 deletions src/mykrobe/cmds/amr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import logging
import tempfile

from mykrobe import ONT_E_RATE, ONT_PLOIDY

logger = logging.getLogger(__name__)

import json
Expand Down Expand Up @@ -342,24 +344,10 @@ def run(parser, args):
args.ont = True

if args.ont:
args.expected_error_rate = 0.15
args.ploidy = "haploid"
args.ignore_minor_calls = True
logger.warning("Setting ploidy to haploid (because --ont flag used)")
logger.warning("Setting ignore_minor_calls to True (because --ont flag was used)")
logger.warning(f"Setting expected_error_rate error rate to {args.expected_error_rate} (because --ont flag was used)")
args.model = "kmer_count"

# If the user didn't specify the conf_percent_cutoff, then set it
# depending on whether or not the --ont flag was used
if args.conf_percent_cutoff == -1:
if args.ont:
args.conf_percent_cutoff = 90
logger.warning("Setting conf_percent_cutoff to 90 (was not specified, and --ont flag was used)")
else:
args.conf_percent_cutoff = 100
logger.warning("Setting conf_percent_cutoff to 100 (was not specified, and --ont flag was not used)")

args.expected_error_rate = ONT_E_RATE
logger.info(f"Set expected error rate to {args.expected_error_rate} because --ont flag was used")
args.ploidy = ONT_PLOIDY
logger.info(f"Set ploidy to {args.ploidy} because --ont flag used")

# conf_percent_cutoff == 100 means that we want to keep all variant calls,
# in which case there is no need to run the simulations
Expand Down
8 changes: 2 additions & 6 deletions src/mykrobe/cmds/genotype.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from mykrobe.typing import Genotyper
from mykrobe.utils import load_json
from mykrobe.version import __version__
from mykrobe import ONT_E_RATE

logger = logging.getLogger(__name__)

Expand All @@ -15,15 +16,10 @@ def run_main(parser, args):
args = parser.parse_args()
verbose = True
if args.ont:
args.expected_error_rate = 0.15
args.filters = ["LOW_GT_CONF"]
args.model = "kmer_count"
args.expected_error_rate = ONT_E_RATE
logger.debug(
"Setting expected error rate to %s (--ont)" % args.expected_error_rate
)
logger.debug(
"Removing LOW_PERCENT_COVERAGE filter (increases sensitivity - in particular for ONT data)"
)

if args.min_variant_conf is None:
args.min_variant_conf = 100
Expand Down
3 changes: 3 additions & 0 deletions src/mykrobe/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
DB_PREFIX = "atlas"
STOP = "*"
K = os.environ.get("KMER_SIZE", 21)
ONT_E_RATE = 0.08
ONT_PLOIDY = "haploid"
ILLUMINA_E_RATE = 0.001
8 changes: 6 additions & 2 deletions src/mykrobe/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,12 @@ def __init__(self, *args, **kwargs):
"--conf_percent_cutoff",
metavar="conf_percent_cutoff",
type=float,
help="Number between 0 and 100. Determines --min_variant_conf, by simulating variants and choosing the cutoff that would keep x%% of the variants. Default is 90 if --ont, otherwise --min_variant_conf is used as the cutoff",
default=-1,
help=(
"Number between 0 and 100. Determines --min_variant_conf, by simulating "
"variants and choosing the cutoff that would keep x%% of the variants "
"(default: %(default)d)"
),
default=100,
)
parser_amr.add_argument(
"-O",
Expand Down

0 comments on commit 0300bd8

Please sign in to comment.