Skip to content

Improving documentation and CN reliability - #21

Merged
Cristianetaniguti merged 8 commits into
mainfrom
development
Dec 1, 2026
Merged

Cristianetaniguti merged 8 commits into
mainfrom
development

Conversation

@Cristianetaniguti

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Critical bugs allow strongly contradicted CN calls to survive reliability filtering and can alter inferred sex by treating masked depth as evidence of absence.

6 open issues
What changed in this PR

Updates Qploidy2’s copy-number reliability scoring and downstream interpretation, while consolidating analysis documentation and bundled agent skills.

Changes:

  • Adds shared reliability scoring, failed-fit handling, and depth-based sex-chromosome evidence.
  • Updates summaries, exports, plotting options, and regression coverage.
  • Refreshes tutorials, function documentation, offline skill installation, and package configuration.
File Description
vignettes/​Qploidy2_workflow.Rmd Adds a compact, offline analysis walkthrough.
tests/​testthat/​test-standardization.R Tests reconstruction of standardization inputs.
tests/​testthat/​test-re_standardize.R Updates the expected ploidy distribution.
tests/​testthat/​test-install_claude_skills.R Tests skill copying, overwrites, and validation.
tests/​testthat/​test-hmm_cn.R Tests batching, sex evidence, and failed fits.
README.md Refreshes quick start, documentation, and installation guidance.
R/​utils.R Adds missing-safe mode and called-fraction helpers.
R/​standardization.R Adds input extraction and depth-filter percentages.
R/​segre_test_cnv.R Selectively suppresses chi-square approximation warnings.
R/​plots_hmm_results_all_samples.R Highlights conflicting sex-chromosome evidence.
R/​plot_karyotype.R Adds depth evidence and optional segment labels.
R/​nQuack_integration.R Integrates reliability scoring and sex-depth metadata.
R/​install_claude_skills.R Copies bundled skills without network access.
R/​hmm_utils.R Adds Y/W depth-presence scoring and validation.
R/​export_results.R Updates reliability summaries and PennCNV chromosome matching.
R/​em_hmm_cn.R Distinguishes missing BAF evidence from failed fits.
R/​cn_reliability.R Introduces shared reliability calculations and components.
R/​call_dosages.R Records package version in VCF headers.
NEWS.md Documents behavior changes and compatibility considerations.
NAMESPACE Exports standardized2raw().
man/​write_hmm_CN.Rd Documents batched output and return values.
man/​summarize_cn_mode.Rd Documents reliability summaries and coverage thresholds.
man/​standardized2raw.Rd Documents reconstructed inputs and their limitations.
man/​standardize.Rd Clarifies depth-filter counts and totals.
man/​plot_karyotype.Rd Documents segment labels and sex-depth annotations.
man/​mode.Rd Documents missing-value handling.
man/​merge_cn_summary_with_estimates.Rd Updates the merged summary schema.
man/​karyotype_notation.Rd Documents sex inference and masked-marker handling.
man/​install_claude_skills.Rd Documents offline skill installation.
man/​hmm_estimate_CN.Rd Documents reliability components and new defaults.
man/​hmm_estimate_CN_nQuack.Rd Documents scoring changes and sex-depth options.
man/​filter_hmm_CN.Rd Documents revised thresholds and sample-wide filtering.
man/​export_mappoly.Rd Documents minimum called-fraction behavior.
man/​count_types.Rd Documents reliability flags and sex-aware classification.
man/​compare_cn_track_summary.Rd Documents sex warnings and caption control.
man/​cn_reliability_score.Rd Documents the shared scoring formula.
man/​baf_peak_position_z.Rd Documents the BAF peak-position check.
man/​baf_peak_dispersion.Rd Documents the BAF dispersion measure.
inst/​WORDLIST Adds terminology used in documentation.
inst/​skills/​qploidy2-input-prep/​SKILL.md Adds standard skill metadata.
inst/​skills/​qploidy2-analysis/​SKILL.md Defines a reliability-first analysis workflow.
inst/​skills/​qploidy2-analysis/​references/​plots.md Adds plotting guidance and interpretation.
inst/​skills/​qploidy2-analysis/​references/​hmm-options.md Explains model, window, and sex-chromosome options.
inst/​skills/​qploidy2-analysis/​references/​export.md Adds batching and export guidance.
inst/​skills/​qploidy2-analysis/​references/​diagnostics.md Adds targeted troubleshooting and refinement guidance.
inst/​CITATION Adds a version-aware Qploidy2 software citation.
docs/​QuickStart_template.Rmd Updates reliability explanations and filtering thresholds.
docs/​Qploidy.R Removes the legacy tutorial script.
DESCRIPTION Updates version, dependency constraint, and vignette builder.
CLAUDE.md Points to shared contributor instructions.
AGENTS.md Adds shared package-development guidance.
.Rbuildignore Excludes app assets and agent configuration.
.github/​workflows/​R-CMD-check.yaml Replaces push triggers with PR checks for both branches.

Review effort: Balanced

Comment thread R/cn_reliability.R Resolved
Comment thread R/hmm_utils.R Resolved
Comment thread README.md Resolved
Copilot AI balanced review requested due to automatic review settings December 1, 2026 13:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Reliability scoring can let contradicted or unsupported calls pass filtering, while treating filtered depth as observed absence can produce incorrect sex inference.

6 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Only apply the depth fallback when has_z is true

R/​cn_reliability.R:237

When baf_only = TRUE, both HMM callers pass mu = NULL, but this formula still credits depth because depth defaults to 1. A window with no heterozygous BAF support can therefore score up to 0.9 * post_max and pass the default 0.5 filter when neighbouring windows make its posterior confident. Include the depth fallback only when has_z is true.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings December 1, 2026 16:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

BAF-only reliability scoring treats unmodeled depth as supporting evidence, allowing windows with neither local BAF support nor modeled depth evidence to pass the default filter.

No open issues 🎉

4 previously missed issues

In code that hasn't changed since last review

High severity Exclude unmodeled depth from BAF-only scoring

R/​cn_reliability.R:213

When baf_only = TRUE, both HMM callers pass mu = NULL, but depth remains 1 here and still contributes through the depth fallback in the final formula. A window with no heterozygotes and a smoothed posterior of 0.99 therefore scores 0.891 and passes the default filter despite having neither local BAF support nor modeled depth evidence. Disable the depth contribution when depth was not modeled, rather than treating an unavailable depth check as perfect support.

Medium severity Raise minimum dplyr version to 1.1.1

DESCRIPTION:40

The new relationship = "many-to-many" join in plot_karyotype() requires dplyr 1.1.1, but this constraint still permits 1.1.0. With that permitted version, plotting fails because the join does not accept relationship. Please raise the minimum to 1.1.1, where this argument was introduced (https://opensource.posit.co/blog/2023-03-22_dplyr-1-1-1/).

Medium severity Apply the coverage rule in non-sex-aware plots

R/​filter_hmm_CN.R:289

This new coverage rule is not applied by the non-sex-aware classification in compare_cn_track_summary() (R/plots_hmm_results_all_samples.R:520–553), which still classifies chromosomes from any remaining calls. For example, a sample with two fully called CN4 chromosomes and a third chromosome retaining only a small CN6 window is now euploid in count_types() but aneuploid in the population plot; filter_type consequently selects different samples. Apply the same coverage rule in the plot, preferably by sharing the classification path for both sex-aware and ordinary samples.

Medium severity Handle all-masked windows before karyotype notation

R/​filter_hmm_CN.R:302

For a sex-aware result without by_marker, if every window is masked, kn_df remains NULL: the fallback only constructs it when a nonmissing call exists. Passing it to karyotype_notation() then fails at rep("autosome", nrow(df)), rather than leaving the samples unclassified. Please handle the no-calls case before invoking notation, returning an empty classification with the usual result schema.

6 resolved since last review

Review effort: Balanced

@Cristianetaniguti
Cristianetaniguti merged commit 6371ffb into main Dec 1, 2026
6 checks passed
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.

2 participants