Generate a runnable Quarto (.qmd) mrmhub workflow
Source:R/build-workflow.R
generate_workflow_qmd.RdAssembles a self-contained Quarto document that imports data and metadata and
runs the selected processing steps, in canonical order, using the same
function calls and defaults as the package tutorials. This is a pure function
(no file I/O, no Shiny) so it can be tested and scripted directly; the
interactive build_workflow() app calls it to power its live preview.
Arguments
- spec
A list describing the workflow. Recognised fields:
importerOne of
"mrmhub","masshunter","skyline","csv_long","csv_wide". Default"mrmhub".data_pathPath to the data file as it should appear in the generated document.
metadata_route"embedded","msorganiser","tables", or"none". Default"embedded".metadata_pathPath to the metadata file (when not embedded).
stepsCharacter vector of step ids to include (the ids defined in
workflow_steps()).drift_methodDrift model for the drift step:
"gaussian"(default),"spline", or"loess".ref_qc_types,reference_sample_idOptional reference QC type(s) and reference sample id for drift/batch/calibration. The corrected feature variable is derived automatically as the highest processing level reached by the selected steps.
column_mappingNamed character vector for
importer = "csv_long", mapping canonical names to file columns, e.g.c(analysis_id = "Sample", feature_id = "Compound", feature_area = "Area").variable_name,analysis_id_col,first_feature_columnArguments for
importer = "csv_wide".output_xlsxPath for the exported report. Default
"results.xlsx".formatsCharacter vector of Quarto output formats, any of
"html","docx","pdf"."pdf"is rendered sans-serif. Default"html".save_rdsLogical; also save the object as
.rds. DefaultFALSE.titleDocument title. Default
"MRMhub Workflow".
Examples
cat(generate_workflow_qmd(list(
importer = "mrmhub",
data_path = "MRMhub_demo.tsv",
steps = c("normalize_istd", "quantify_istd")
)))
#> ---
#> title: "MRMhub Workflow"
#> toc: true
#> execute:
#> warning: true
#> format:
#> html: default
#> ---
#>
#> This workflow was generated by `mrmhub::build_workflow()`. Adjust file paths and parameters as needed, then run each chunk.
#>
#> ## Setup
#>
#> ```{r}
#> library(mrmhub)
#> ```
#>
#> ## Import data
#>
#> Create the experiment container and import the raw results.
#>
#> ```{r}
#> mexp <- MRMhubExperiment()
#> mexp <- import_data_mrmhub(mexp, path = "MRMhub_demo.tsv", import_metadata = TRUE)
#> ```
#>
#> ## Normalize by internal standard
#>
#> Divide each feature by its assigned internal standard to correct for extraction and injection variability.
#>
#> ```{r}
#> mexp <- normalize_by_istd(mexp)
#> ```
#>
#> ## Quantify against internal-standard concentrations
#>
#> Convert normalized signals to concentrations using the spiked internal-standard amounts.
#>
#> ```{r}
#> mexp <- quantify_by_istd(mexp)
#> ```
#>
#> ## Export results
#>
#> Write the processed results to an Excel report.
#>
#> ```{r}
#> save_report_xlsx(mexp, path = "results.xlsx")
#> ```