fix: predictCoding on empty ranges returns AAStringSet for REFAA/VARAA (#86)#92
fix: predictCoding on empty ranges returns AAStringSet for REFAA/VARAA (#86)#92jmg421 wants to merge 4 commits into
Conversation
|
I bumped the version, installed the branch corresponding to this PR, and found Are you running R CMD check on the package after your changes? |
|
If the PRs are somehow cumulative please close the ones that should not be verified independently. |
Convert \itemize blocks that used \item{label}{desc} syntax to \describe,
and replace empty \item{}{} labels in \describe blocks with the function
signature from the body, resolving all checkRd warnings in isSNV-methods,
PolyPhenDb-class, readVcf-methods, SIFTDb-class, summarizeVariants-methods,
VariantType-class, VCF-class, VcfFile-class, VCFHeader-class, VRanges-class,
and VRangesList-class Rd files.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
09df700 to
e9748a2
Compare
Bioconductor#86) When query has no overlap with the CDS, .localCoordinates() returns a zero-length GRanges. Previously an early return on length(txlocal)==0 caused REFAA and VARAA to be absent from mcols(), returning NULL instead of empty AAStringSet objects. This breaks downstream operations like reverse() and subseq() on the result columns. Fix: - Remove early return so the full mcols-building code runs even when txlocal is empty, naturally producing zero-length AAStringSet columns - Fix GENEID=NA_character_ -> rep(NA_character_, length(txlocal)) so DataFrame() construction works correctly at zero length Test: extend test_predictCoding_empty to assert REFAA and VARAA are AAStringSet with length 0.
There was a problem hiding this comment.
Pull request overview
Fixes predictCoding() behavior when the query has no CDS overlap by ensuring REFAA/VARAA (and related metadata) are still present as empty AAStringSet columns, preventing downstream failures on empty results. The PR also includes broad Rd documentation \item{} formatting cleanups and bumps the package version.
Changes:
- Remove the early return on
length(txlocal) == 0so empty outputs still getREFAA/VARAAinitialized as emptyAAStringSet. - Fix zero-length
DataFrame()construction by makingGENEIDlength-consistent withtxlocal. - Extend unit tests to assert
REFAA/VARAAare emptyAAStringSet(plus assorted documentation formatting updates and a version bump).
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
R/methods-predictCoding.R |
Removes empty-result early return and fixes GENEID length so empty results still include REFAA/VARAA. |
inst/unitTests/test_predictCoding-methods.R |
Adds assertions for empty AAStringSet REFAA/VARAA on empty results. |
man/VRangesList-class.Rd |
Rd \describe/\item formatting cleanup. |
man/VRanges-class.Rd |
Rd \describe/\item formatting cleanup (includes a touched line with a remaining typo). |
man/VCFHeader-class.Rd |
Rd \describe/\item formatting cleanup. |
man/VcfFile-class.Rd |
Rd \describe/\item formatting cleanup and restructuring of arguments list. |
man/VCF-class.Rd |
Rd \describe/\item formatting cleanup and restructuring of accessor documentation. |
man/VariantType-class.Rd |
Rd \describe/\item formatting cleanup. |
man/summarizeVariants-methods.Rd |
Rd list structure updated (\itemize → \describe). |
man/SIFTDb-class.Rd |
Rd \describe/\item formatting cleanup. |
man/readVcf-methods.Rd |
Rd list structure updated (\itemize → \describe) for genome argument details. |
man/PolyPhenDb-class.Rd |
Rd \describe/\item formatting cleanup. |
man/isSNV-methods.Rd |
Rd list structure updated (\itemize → \describe). |
DESCRIPTION |
Version bump to 1.59.2. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| When \code{from} is a \code{GRanges}, metadata columns of | ||
| \code{ref}, \code{alt}, \code{refDepth}, \code{altDepth}, | ||
| \code{totalDepth} and \code{sampleNames} are transfered to | ||
| \code{totalDepth} and \code{sampleNames} are transfered to |
This expectation likely became outdated after removing the early return in .predictCodingGRangesList(): on an empty result, .localCoordinates() contributes 8 metadata columns and .predictCodingGRangesList() appends 6 more (GENEID/CONSEQUENCE/REFCODON/VARCODON/REFAA/VARAA), so mcols(current) should have 14 columns rather than 8. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
I think this PR is ready to be merged - with this fix to the mcols number of columns test (85de342), the check error is resolved for me locally. |
Problem
When
predictCoding()is called with a query that has no overlap with any CDS (e.g. a non-coding variant),.localCoordinates()returns a zero-lengthGRanges. The early-exit guard at that point returnedtxlocaldirectly — beforeREFAA/VARAAcolumns were ever added tomcols(). This caused downstream operations likereverse()orsubseq()on those columns to throw errors.Reproducer from #86:
Fix
Two changes in
R/methods-predictCoding.R:Remove the early return on
length(txlocal) == 0— let execution fall through to the fullmcols()-building block, which naturally produces zero-lengthAAStringSetcolumns viaAAStringSet(rep("", length(txlocal))).Fix scalar
GENEID— changeGENEID=NA_character_toGENEID=rep(NA_character_, length(txlocal))soDataFrame()construction is valid at zero length.Test
Extended
test_predictCoding_emptyininst/unitTests/test_predictCoding-methods.Rto assert:mcols(result)$REFAAis anAAStringSetmcols(result)$VARAAis anAAStringSetlength == 0LFixes #86.