stephenslab / flashr

R package for Empirical Bayes Factor Analysis.
https://stephenslab.github.io/flashr
BSD 3-Clause "New" or "Revised" License
49 stars 11 forks source link

Improved interface #84

Closed willwerscheid closed 6 years ago

willwerscheid commented 6 years ago

This pull request includes several major interface changes:

  1. What was previously called a flash object is now a flash_fit object. The new flash object, which is what nearly all of the exported functions return (namely, flash, flash_add_greedy, flash_backfit, flash_add_factors_from_data, flash_add_fixed_factors, flash_add_fixed_loadings, and flash_zero_out_factor; the exceptions, for obvious reasons, are flash_set_data, flash_fill, and flash_sampler), contains a flash_fit field, as well as fields with summary info (nfactors, pve, ldf, fitted_values) and a fit_history (a list, one element for each fit, each of which contains fields type (greedy or backfit), kset, niter, obj_track -- the objective function after each iteration --, and diff_track -- the "diff" after each iteration). Note that the fitting process works exactly as before -- that is, a flash object can be re-fit directly without first extracting the flash_fit object. So the only difference from the point of the view of the user is that the summary information is returned with every fit, and an ongoing history of the fit is maintained along with the object.
  2. Since the summary info is now returned with the flash object, the get_ functions have been removed from the interface. This closes #55.
  3. The flash_add_ functions now include a backfit option, which defaults to TRUE, and accepts additional backfitting arguments via .... Thus, by default, all of the above fitting functions return a fitted flash object. If backfit is set to FALSE, then f$objective is set to NA (since the calculated objective is not valid until a backfit has occurred). This fixes #81 and closes #49.
  4. The new flash object obviates the need for a S3 summary method, so this has been removed. The print method has been retained.
  5. The plotting functions have been rewritten to resemble the plots in Wang and Stephens, and have been combined into a S3 plot method. This fixes #43 .
  6. flash_greedy_workhorse and flash_backfit_workhorse functions have been created, which contain parameters stopping_rule (with options objective, factors, loadings, and all_param, the latter three of which stop after the elements of the l_2-normalized factors/loadings/both no longer change by more than tol) and verbose_output, which allows more flexibility over what is displayed to the user during the fitting process. This fixes #72.
  7. flash_init_lf is no longer exported as it will be rarely needed and the same thing can be achieved via add_factors_from_data. flash_update_precision is no longer exported. This fixes #51.

Finally, I've re-organized the R folder so that functions are in more intuitive places and files have more descriptive names.

codecov-io commented 6 years ago

Codecov Report

Merging #84 into master will decrease coverage by 0.77%. The diff coverage is 82.3%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #84      +/-   ##
==========================================
- Coverage   85.79%   85.01%   -0.78%     
==========================================
  Files          17       22       +5     
  Lines        1028     1255     +227     
==========================================
+ Hits          882     1067     +185     
- Misses        146      188      +42
Impacted Files Coverage Δ
R/update_precision.R 100% <ø> (ø) :arrow_up:
R/flash.R 57.14% <ø> (-33.77%) :arrow_down:
R/objective.R 100% <ø> (ø) :arrow_up:
R/update_factors.R 100% <ø> (ø)
R/get_functions.R 61.4% <ø> (-15.79%) :arrow_down:
R/ebnm_functions.R 67.64% <ø> (ø) :arrow_up:
R/print.R 0% <0%> (ø)
R/add_fixed.R 100% <100%> (ø)
R/add_from_data.R 100% <100%> (ø)
R/flash_object.R 100% <100%> (ø)
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5770333...e073478. Read the comment docs.