Skip to content

Fix summary-exclusion flags filtering individual plots (#1438) - #1439

Open
Gero1999 wants to merge 9 commits into
mainfrom
1438-bug/summary-exclusion-individual-plots
Open

Fix summary-exclusion flags filtering individual plots (#1438)#1439
Gero1999 wants to merge 9 commits into
mainfrom
1438-bug/summary-exclusion-individual-plots

Conversation

@Gero1999

@Gero1999 Gero1999 commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Issue

Closes #1438

Description

Summary-exclusion flags (PKSUMXF for ADNCA, PPSUMXF for ADPP) were applied to every TLG graph, so individual concentration plots (pkcg01) and combined plots (pkcg02) hid summary-excluded records. The documented intent (#1018, #1436) is that these flags remove records from summary tables and mean plots only, while keeping them everywhere records are inspected individually.

The old routing (tlg_data_key()) was a binary listing-vs-everything switch: listings got unfiltered data, everything else (all tables and all graphs) got filtered data. That scope quietly widened from "mean plots" to "graphs" in #1356.

This inverts the default: only summary/mean functions self-filter, and the filtered/_all boundary split is retired so there is a single source of truth per dataset.

Changes:

  • Add filter_summary_excluded() in R/utils-tlg.R. It auto-detects the relevant flag (PKSUMXF/PPSUMXF), is a no-op when absent, scopes each dataset to its own flag (no cross-filtering), and uses dplyr::filter() so column label attributes survive the row subset.
  • Call it at the top of the summary/mean functions only: t_pkct01, t_pkpt03_col, t_pkpt07_norm, t_pkpt08_uri, t_pkpt11_gmr, pkcg03 (mean conc), and p_pkpg01_cum/p_pkpg02_doseprop/p_pkpg03_boxp. Their delegators (_dose, _tad, _MP_col, p_pkpg01_per, p_pkpg04/06, g_pkcg03_*, p_pkcg03_*_dose) inherit automatically.
  • Individual (pkcg01) and combined (pkcg02) plots and all listings now receive raw data.
  • Retire tlg_data_key() and filter_tlg_excluded(); tab_tlg.R exposes one unfiltered source per dataset.

Because filtering now lives in the TLG functions, the exported R script path gets the correct behaviour too.

Combined plots (pkcg02) decision: kept unfiltered. pkcg02 overlays individual subject traces, so records are still being inspected individually.

Unrelated naming bug found while testing (#1448): adding name-based assertions surfaced a pre-existing bug on mainpkcg01/pkcg02 named their output list from adnca[["id_plot"]], but id_plot only exists on the intermediate adnca_grouped, so the list came back unnamed. No prior test checked plot names, so it went unnoticed. Fixed here by naming from adnca_grouped (tracked separately in #1448).

Definition of Done

  • Individual plots show summary-excluded records
  • Decision made for combined plots (pkcg02: unfiltered)
  • Summary tables and mean plots still filter
  • Listings unchanged (unfiltered)
  • Per-dataset scoping preserved (no cross-filter)
  • Works in the exported R script path (functions self-filter)
  • Misleading "mean plots" routing comments corrected
  • Tests assert individual-retains vs summary-drops

How to test

Flag a record with PKSUMXF == "Y" (ADNCA) or PPSUMXF == "Y" (ADPP) and confirm in the TLG tab that:

  • it still appears in individual (pkcg01) and combined (pkcg02) plots and in listings, and
  • it is dropped from summary tables (t_pkct01, t_pkpt*) and mean plots (pkcg03, p_pkpg*).

Contributor checklist

  • Code passes lintr checks
  • Code passes all unit tests
  • New logic covered by unit tests
  • New logic is documented
  • App or package changes are reflected in NEWS
  • Package version is incremented
  • R script works with the new implementation (if applicable)
  • Settings upload works with the new implementation (if applicable)
  • If any .scss change was done, run data-raw/compile_css.R
  • If a package dependency was added/changed, run data-raw/test_suggests_hidden.R

Notes to reviewer

R is not available in this environment, so tests/lintr were verified statically (line-length and brace/paren balance) rather than executed; please run devtools::test() and lintr::lint_package() locally.

main has been merged into this branch and conflicts in inst/shiny/modules/tab_tlg.R and tests/testthat/test-tab_tlg.R resolved (kept the single unfiltered ADPP source from this branch and folded in the ADPP "run NCA first" notification from #1335).

Two test failures from the first CI run are addressed: the g_pkcg01 name assertion failed due to the #1448 naming bug (fixed here), and the t_pkct01 exclusion test expected an n == 0 row for a fully-excluded cell — the table drops empty groups, so the test now asserts the row is absent.

Summary/mean TLG functions now self-filter PKSUMXF/PPSUMXF; individual
and combined plots and listings receive unfiltered data. Retire the
filtered/_all boundary split.
@Gero1999
Gero1999 marked this pull request as ready for review August 24, 2026 12:20
Base automatically changed from 1436-enhancement/summary-exclusion-flags to main August 26, 2026 14:14
Resolve conflicts in inst/shiny/modules/tab_tlg.R and
tests/testthat/test-tab_tlg.R: keep the single unfiltered ADPP data
source from this branch and fold in the ADPP not-run notification
from main (#1335).
Gero1999 and others added 7 commits August 26, 2026 15:10
…n test

pkcg01/pkcg02 named their output list from adnca[["id_plot"]], but
id_plot only exists on adnca_grouped, so the list came back unnamed.
Name from adnca_grouped instead (#1448).

Adjust the t_pkct01 summary-exclusion test: flagging every row of a cell
removes the group entirely (empty groups are not emitted), so assert the
row is absent rather than expecting an n == 0 row (#1438).
The unnamed-list bug is internal (the app consumes plots by index, not
name) and predates v0.1.0, so it is not a user-facing change for this
release. It remains tracked in #1448 and the fix commit.
Add .github/skills/news-curation/SKILL.md, a decision gate for whether a
change belongs in NEWS.md (user-observable? regression this cycle?
foldable? correctness/safety carve-in) and how to phrase entries.

Reference it from the AGENTS.md PR workflow so NEWS.md is re-checked
whenever a PR is opened or updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant