Skip to content

Commit

Permalink
clarify logic for bc matching thresholds
Browse files Browse the repository at this point in the history
  • Loading branch information
kedhammar committed May 28, 2024
1 parent 91c17e4 commit aa9c959
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 6 additions & 5 deletions anglerfish/anglerfish.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,15 @@ def run_demux(args):
log.info(f" run uuid {run_uuid}")
min_distance = ss.minimum_bc_distance()
if args.max_distance is None:
if min_distance > 1:
args.max_distance = 2
else:
args.max_distance = 1
# Default: Set the maximum distance for barcode matching to 0, 1 or 2
# depending on the smallest detected edit distance between indices in the samplesheet
args.max_distance = min(min_distance - 1, 2)
log.info(f"Using maximum edit distance of {args.max_distance}")
if args.max_distance >= min_distance:
log.error(
f" Edit distance of barcodes in samplesheet are less than the minimum specified {args.max_distance}>={min_distance}"
f" The maximum allowed edit distance for barcode matching (={args.max_distance})"
+ f"is greater than the smallest detected edit distance between indices in samplesheet (={min_distance})"
+ ", which will result in ambiguous matches."
)
exit()
log.debug(f"Samplesheet bc_dist == {min_distance}")
Expand Down
4 changes: 3 additions & 1 deletion anglerfish/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ def run(
typer.Option(
"--max-distance",
"-m",
help="Manually set maximum edit distance for BC matching, automatically set this is set to either 1 or 2",
help="Manually set maximum allowed edit distance for index matching,"
+ "by default this is set to 0, 1 or 2 based on the minimum detected"
+ "index distance in the samplesheet.",
),
] = 2,
max_unknowns: Annotated[
Expand Down

0 comments on commit aa9c959

Please sign in to comment.