Skip to content

Count reads dropped by --dedup as duplicates instead of "passed filter" (#638, #528) - #715

Open
cindykrafft wants to merge 1 commit into
OpenGene:masterfrom
cindykrafft:fix/issue-638-dedup-filter-counts
Open

cindykrafft wants to merge 1 commit into
OpenGene:masterfrom
cindykrafft:fix/issue-638-dedup-filter-counts

Conversation

@cindykrafft

Copy link
Copy Markdown

Fixes #638. Also fixes #528.

Cause. With --dedup, the decision to drop a duplicate (dedupOut) only gates the output; the filter category is recorded before it is consulted (config->addFilterResult(result, 1) in seprocessor.cpp, addFilterResult(max(result1, result2), 2) in peprocessor.cpp) with result == PASS_FILTER. So every read removed by --dedup is still counted as passed: "reads passed filter" on stderr and filtering_result.passed_filter_reads in the JSON/HTML disagree with summary.after_filtering.total_reads and with the output file by exactly the number of removed duplicates, and there is no category that reports those reads. The merged branch in --merge mode never checks dedupOut at all, so --merge --dedup removes nothing.

Fix. A new filter category FAIL_DUPLICATE (following FAIL_ADAPTER_DIMER): a read or pair that would pass but is dropped by --dedup is recorded under it in all four places a result is recorded (SE; PE merged, --include_unmerged, plain). Reads failing another filter keep that reason. It is reported as reads failed due to duplication: on stderr, "duplicated_reads" in the JSON filtering_result and reads duplicated: in the HTML summary, only when --dedup is on, so reports of runs without --dedup are unchanged. One output change: because the merged branch now records FAIL_DUPLICATE and writes only on PASS_FILTER, --merge --dedup drops duplicate merged pairs as documented — happy to split that into a separate PR if you prefer.

Test. scripts/test_issue_638_dedup_filter_counts.sh, in the style of test_issue_697_stdout_merge.sh: an SE run with every read twice asserts passed_filter_reads == after_filtering.total_reads == reads written and duplicated_reads == input − written; an interleaved --merge --dedup run asserts that no more than the distinct pairs are written and that the two counters sum to the input. It fails on master (FAIL: SE --dedup wrote 500 reads but reported passed_filter_reads=1000 duplicated_reads=-1 after_filtering.total_reads=500) and passes with this change.

Run. make -j8 (no warnings), ./fastp test (ALL PASSED), scripts/test_issue_697_stdout_merge.sh (PASS) and the new script (PASS), on Ubuntu with libisal 2.31.0, libdeflate 1.19, libhwy 1.0.7. Synthetic check: 4,000 SE reads (2,000 distinct) with --dedup now report passed 2000 / duplicated 2000 / after_filtering 2000 / written 2000 instead of 4000 / – / 2000 / 2000.

Found while working through open issues in Mytochondria, a volunteer project that verifies fixes for the software behind published results (methods and harnesses: https://github.com/cindykrafft/mytochondria/tree/main/audits/fastp)


Generated by Claude Code

…nGene#638, OpenGene#528)

With --dedup, a read (or pair) removed as a duplicate was still recorded as
PASS_FILTER, so "reads passed filter" on stderr and
filtering_result.passed_filter_reads in the JSON/HTML counted reads that were
never written, and disagreed with summary.after_filtering.total_reads and with
the output files. In --merge mode the merged branch never looked at the
deduplication flag at all, so --dedup removed nothing there.

Add FAIL_DUPLICATE: a read or pair that would otherwise pass but is dropped by
--dedup is now counted under it, reported as "reads failed due to duplication"
on stderr, "duplicated_reads" in the JSON filtering_result and "reads
duplicated" in the HTML summary (all only when --dedup is on), and merged
pairs that are duplicates are no longer written.

scripts/test_issue_638_dedup_filter_counts.sh reproduces both symptoms and
fails on the unmodified code.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TaHntBDKuZJpMAAMenkC44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deduplication not reported in the html report Discrepency in filtering restults and reads after filtering

1 participant