Skip to content

importBugphyzz(): includeDroppedAsr adds back the ASR rows the export removed (1.7.12) - #289

Merged
lwaldron merged 2 commits into
develfrom
include-dropped-asr
Nov 8, 2026
Merged

lwaldron merged 2 commits into
develfrom
include-dropped-asr

Conversation

@lwaldron

@lwaldron lwaldron commented Nov 8, 2026

Copy link
Copy Markdown
Member

Companion to the bugphyzzExports PR that writes bugphyzz_asr_dropped.csv.gz (the imputed annotations the export's thresholds or rarely/never rule removed, with their validation score).

importBugphyzz(version = "devel", includeDroppedAsr = TRUE, mccThreshold = 0.6) downloads that file, binds its rows into the binary, multistate and numeric tables by Attribute_type, and then applies the thresholds as before, so a threshold below the export's 0.7/0.5 can be evaluated against known ground truth (waldronlab/bugphyzz-manuscript#15). A Zenodo version with includeDroppedAsr = TRUE stops with a message, since releases carry only the filtered data.

Test: the Zenodo refusal, and the binding against a small gzipped fixture with .getResource mocked. The download path needs the side file on devel, which the next export produces.

Drafted with Claude Code.

… removed (1.7.12)

With version = "devel" or a commit hash, read bugphyzz_asr_dropped.csv.gz
from bugphyzzExports and bind it in before applying mccThreshold and
r2Threshold, so thresholds below the export's can be evaluated. Zenodo
versions refuse the option.

Co-authored-by: Claude Code <noreply@anthropic.com>
Comment thread R/bugphyzz.R Outdated
} else {
dplyr::filter(dropped, Attribute_type == type)
}
dplyr::bind_rows(output[[i]], dplyr::select(part, -Validation))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bind_rows() is fragile here. read.csv() infers column types separately for the dropped file and for the main tables. Any column that is entirely NA in the dropped file (for example Attribute_value or a range column for the numeric subset) is read as logical. The same column is character or numeric in output[[i]], so bind_rows() fails with "Can't combine ..1$X and ..2$X ". An NCBI_ID that is integer in one file and character in the other fails the same way.

The test fixture has only a few columns, so it can't catch this. Fix it by reading the file with the same colClasses as the main tables. Alternatively, coerce the dropped columns to the types of output[[i]] before binding, for example by reading everything as character and using readr::type_convert. Add a test where one of the dropped columns is all NA.

Also, dplyr::select(part, -Validation) errors if a future export omits Validation. Use dplyr::select(part, -dplyr::any_of("Validation")).

con <- gzfile(tmp, "w"); cat("# header\n", file = con)
write.table(dropped, con, sep = ",", row.names = FALSE, append = TRUE, col.names = TRUE)
close(con)
local_mocked_bindings(.getResource = function(...) tmp)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The test only calls .addDroppedAsr() directly. Nothing tests the feature through importBugphyzz(includeDroppedAsr = TRUE, mccThreshold = ...), which is the behaviour the PR describes: dropped rows get a Validation score from the join and are then kept or removed by a lower threshold. Please add a test that mocks .downloadResource and .getResource and checks that a dropped ASR row appears at mccThreshold = 0.3 and is absent at the default 0.7. Also cover the interaction with excludeRarely. The fixture also lacks Frequency, NCBI_ID and the other real columns, so it doesn't exercise type compatibility with the main tables.

@claude

claude Bot commented Nov 8, 2026

Copy link
Copy Markdown

Issues worth addressing, most important first:

  1. R/bugphyzz.R .addDroppedAsr(): bind_rows() can fail on column type mismatches. read.csv() infers types for the dropped file independently of the main tables. A column that is entirely NA in the dropped file is read as logical, and an NCBI_ID read as integer in one file and character in the other has the same effect. Either case makes bind_rows() error on real data. Use matching colClasses, or coerce to the types of output[[i]] before binding. Also use any_of("Validation") in the select().
  2. Tests: nothing exercises importBugphyzz(includeDroppedAsr = TRUE) end to end. That would show whether dropped rows are kept or removed by a lower mccThreshold and by excludeRarely. The fixture also has too few columns to expose the type issue in item 1.
  3. Minor: the dropped file is cached under the fixed name bugphyzz_asr_dropped.csv.gz regardless of version. Switching between devel and a commit hash without forceDownload = TRUE silently reuses the old file. The existing resources have the same pattern, but it is easier to hit here because the side file must stay in sync with the main tables.

The roxygen and Rd documentation for the new argument, the NEWS entry and the version bump look fine.

…; cache per version; end-to-end test

Co-authored-by: Claude Code <noreply@anthropic.com>
@lwaldron

lwaldron commented Nov 8, 2026

Copy link
Copy Markdown
Member Author
  1. The side file is read with colClasses = "character" and each column is coerced to the class it has in the main table before bind_rows(); columns absent from the main table are dropped (any_of("Validation") included).
  2. New test through importBugphyzz(version = "devel", includeDroppedAsr = TRUE) with .downloadResource, .getResource and .validationData mocked and full-width fixtures: a dropped aerobic row is absent at 0.7, present at 0.6, its never sibling only when excludeRarely = FALSE, Score stays numeric, and includeDroppedAsr = FALSE is unchanged.
  3. Cache name now includes the version (bugphyzz_asr_dropped_<version>.csv.gz).

Drafted with Claude Code.

@codecov

codecov Bot commented Nov 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.56%. Comparing base (a47be34) to head (23975ed).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##            devel     #289      +/-   ##
==========================================
+ Coverage   42.32%   44.56%   +2.23%     
==========================================
  Files           5        5              
  Lines         893      929      +36     
==========================================
+ Hits          378      414      +36     
  Misses        515      515              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@lwaldron
lwaldron merged commit 148853b into devel Nov 8, 2026
5 checks passed
@lwaldron
lwaldron deleted the include-dropped-asr branch November 8, 2026 02:34
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.

1 participant