@@ -183,16 +183,55 @@ check_consistent <- function(point, prior,
183183}
184184
185185# ' "Workflow" version of run.meta.analysis.pft
186+ # ' #' Run Bayesian meta-analysis for a single PFT (file-based wrapper)
186187# '
187- # ' Thin wrapper around `meta_analysis_standalone` that also reads/writes files
188- # ' and registers results in the PEcAn database.
188+ # ' Thin wrapper around [meta_analysis_standalone()] that reads trait data and
189+ # ' priors from disk, runs the meta-analysis, and saves results back to disk.
190+ # ' Also registers result files in the BETYdb posteriors table.
191+ # '
192+ # ' @details
193+ # ' **Upstream contract (reads from `pft$outdir`):**
194+ # ' \describe{
195+ # ' \item{`trait.data.Rdata`}{Named list of data frames produced by
196+ # ' [get.trait.data.pft()]. Loaded into `trait_env$trait.data`.}
197+ # ' \item{`prior.distns.Rdata`}{Data frame of prior distributions produced by
198+ # ' [get.trait.data.pft()]. Loaded into `prior_env$prior.distns`.}
199+ # ' }
200+ # '
201+ # ' **File-based side effects (saved to `pft$outdir`):**
202+ # ' \describe{
203+ # ' \item{`trait.mcmc.Rdata`}{Contains `trait.mcmc`: a named list of
204+ # ' `mcmc.list` objects (one per trait) with posterior MCMC samples from
205+ # ' JAGS. Each element has columns `beta.o` (overall mean) and optionally
206+ # ' `sd.o` (overall SD).}
207+ # ' \item{`post.distns.MA.Rdata`}{Contains `post.distns`: a data frame with
208+ # ' one row per trait and columns `distn`, `parama`, `paramb`, `n`
209+ # ' summarizing the fitted posterior distribution.}
210+ # ' \item{`post.distns.Rdata`}{Symlink to `post.distns.MA.Rdata`.}
211+ # ' \item{`jagged.data.Rdata`}{Contains `jagged.data`: a named list of data
212+ # ' frames (one per trait) after the greenhouse screening and JAGSification
213+ # ' transform applied by [jagify()].}
214+ # ' }
215+ # '
216+ # ' **Downstream contract:** The files `trait.mcmc.Rdata` and
217+ # ' `post.distns.Rdata` are expected by [get.parameter.samples()] (in
218+ # ' `PEcAn.uncertainty`), which loads them to generate ensemble and sensitivity
219+ # ' analysis samples. This implicit file-based coupling is a refactoring target.
220+ # '
221+ # ' **Note:** The core computation is performed by [meta_analysis_standalone()],
222+ # ' which accepts and returns R objects directly — see its documentation for
223+ # ' the pure-function interface.
189224# '
190225# ' @param pft (list) PFT list object, as defined in settings. Must include the
191226# ' following: `outdir`, `name`, `posteriorid`
192227# ' @param dbfiles (character) directory where previous results are found
193228# ' @param dbcon (DBI connection object) BETY database connection object
194- # ' @param update (boolean; default = TRUE) If `TRUE`, replace existing
195- # ' posteriors with new ones
229+ # ' @param update (boolean; default = FALSE) If `TRUE`, replace existing
230+ # ' posteriors with new ones
231+ # '
232+ # ' @return The `pft` list (invisibly), or `NA` if no trait data are available.
233+ # ' The function's primary outputs are communicated through files saved in
234+ # ' `pft$outdir`, not through the return value.
196235# '
197236# ' @inheritParams meta_analysis_standalone
198237run.meta.analysis.pft <- function (pft , iterations , random = TRUE , threshold = 1.2 , dbfiles , dbcon , use_ghs = TRUE , update = FALSE ) {
@@ -299,19 +338,22 @@ run.meta.analysis.pft <- function(pft, iterations, random = TRUE, threshold = 1.
299338} # run.meta.analysis.pft
300339
301340# #--------------------------------------------------------------------------------------------------##
302- # #' Run meta analysis
341+ # #' Run meta-analysis across all PFTs
342+ # #'
343+ # #' Iterates over a list of PFTs and runs [run.meta.analysis.pft()] for each
344+ # #' one. This is the main entry point called by [runModule.run.meta.analysis()].
303345# #'
304346# #' This will use the following items from settings:
305- # #' - settings$pfts
306- # #' - settings$database$bety
307- # #' - settings$database$dbfiles
308- # #' - settings$meta.analysis$update
347+ # #' - ` settings$pfts`
348+ # #' - ` settings$database$bety`
349+ # #' - ` settings$database$dbfiles`
350+ # #' - ` settings$meta.analysis$update`
309351# #'
310352# #' @param pfts the list of pfts to get traits for
311353# #' @param database database connection parameters
312354# #' @param update logical: Rerun the meta-analysis if result files already exist?
313355# #' @param threshold Gelman-Rubin convergence diagnostic, passed on to
314- # #' \code{\link{ pecan.ma.summary}}
356+ # #' [ pecan.ma.summary()]
315357# #' @inheritParams meta_analysis_standalone
316358# #' @inheritParams run.meta.analysis.pft
317359# #'
0 commit comments