Skip to content

replacing vip::vi() call with internal functionality - #31

Open
amcim wants to merge 1 commit into
mainfrom
vip-replace
Open

replacing vip::vi() call with internal functionality#31
amcim wants to merge 1 commit into
mainfrom
vip-replace

Conversation

@amcim

@amcim amcim commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

The vip package was removed from CRAN and that is problematic for Bioconductor submission. We made the decision to replace the use of the package with our own functionality.

The relevant call to vip was vip::vi() in extractTopFeats(), which returns the features a model found most important for predicting AMR phenotype. Its output is what gets written to the *_top_features.tsv files and plotted by plotTopFeatsVI(). As such, this was replaced with with an internal .viGlmnet().

That call goes through a few functions in vip:

  • vi(): wrapper; computes importance, drops NAs, sorts by decreasing importance
  • vi_model(): S3 generic that picks the extraction method for the model type
  • vi_model.model_fit(): unwraps the parsnip fit to the underlying engine object
  • vi_model.glmnet(): pulls the coefficients out of the glmnet fit and returns them as Variable, Importance (absolute coefficient), and Sign (POS/NEG)

This implemntation takes the fitted glmnet engine, drops the intercept, and returns a tibble of Variable, Importance (|coefficient|), and Sign, sorted by decreasing importance.

I also added some tests which check that .viGlmnet() returns what vip::vi() did(the three columns, sorted by decreasing importance, with Importance equal to the absolute coefficient at the minimum lambda), and that multi-class fits return per-class columns instead of erroring.

One thing about this approach is that this currently only works for glmnet, which is the only engine we use currently. If we want to add more models later we will need to expand this functionality.

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