maplet-function-composition
Summary
Compose modular metabolomics analysis pipelines by chaining maplet functions using pipe operators (%>% or |>) to connect data loading, annotation, statistical analysis, visualization, and reporting steps without intermediate variable assignment. Output is a SummarizedExperiment container that serves as a central repository for data, analysis steps, and results.
When to use
Use this skill when you have metabolomics data that requires sequential processing through multiple analytical steps (e.g., loading raw data, annotating metabolites, computing statistics, generating plots) and you want to construct a reproducible, self-contained pipeline that avoids temporary variables and multiple intermediate assignments.
When NOT to use
- When you need to perform ad-hoc exploratory analysis with frequent branching or conditional logic that does not fit a linear pipeline structure.
- When input data is already structured as a SummarizedExperiment and does not require maplet's data-loading function.
- When analysis steps must be executed in parallel or require custom intermediate variable inspection that is incompatible with strict pipe composition.
Inputs
- Raw metabolomics data file (format supported by maplet data-loading function)
- R environment with maplet, SummarizedExperiment, and magrittr or base R pipe operators installed
Outputs
- SummarizedExperiment object containing data, analysis steps, and results
- RDS file (via saveRDS()) containing the final SummarizedExperiment object
How to apply
Initialize a SummarizedExperiment container by calling maplet's data-loading function with your metabolomics dataset. Chain subsequent maplet functions (annotation, statistical analysis, visualization, reporting) using either the %>% pipe operator from magrittr or the |> operator from base R. Each pipe passes the SummarizedExperiment object forward to the next function, which modifies it in place by adding analysis results or annotations. Execute the entire pipeline script in R and persist the final SummarizedExperiment object using saveRDS(). The pipe operator enables smooth connections between steps without needing temporary variables or multiple assignments.
Related tools
- maplet (Primary package providing functions for data loading, annotation, statistical analysis, visualization, and reporting that are composed into pipelines via pipe operators.) — https://github.com/krumsieklab/maplet
- SummarizedExperiment (Bioconductor container class that serves as the central data structure passed through the pipeline; holds data, assays, colData, rowData, and metadata.) — https://bioconductor.org/packages/release/bioc/vignettes/SummarizedExperiment/inst/doc/SummarizedExperiment.html
- magrittr (Provides the %>% pipe operator used to chain maplet functions together without temporary variables.) — https://magrittr.tidyverse.org/
- base R (Provides the |> native pipe operator (alternative to magrittr) for function composition.)
Examples
result_se <- load_data(data) %>% annotate_metabolites() %>% compute_statistics() %>% visualize_results(); saveRDS(result_se, 'pipeline_output.rds')
Evaluation signals
- The final SummarizedExperiment object is successfully created and contains non-empty assay data, colData (sample annotations), and rowData (feature annotations).
- The RDS file generated by saveRDS() is readable and can be restored using readRDS() without errors.
- Pipeline script executes end-to-end without intermediate variable assignments; all function calls are connected by pipe operators.
- Analysis results (statistical output, visualization metadata, annotations) are present in the SummarizedExperiment object's metadata slots or assays.
- Pipeline is reproducible: running the same script on the same input data produces identical SummarizedExperiment contents.
Limitations
- maplet is in active development; commits without release tags are not guaranteed to be stable (per README note).
- Strict pipe composition can complicate debugging if intermediate results need inspection; workarounds require breaking the pipe.
- Function naming conventions are strict and enforced; contributed functions may be rejected if they violate naming rules (section 3.2.1 of maplet Reference Guide).
- No changelog is publicly available, making version-to-version compatibility tracking difficult.
Evidence
- [readme] Pipe operator definition and composition: "maplet is designed to work with a pipe operator - either the popular %>% operator from the magrittr package or the recently introduced |> from base R. This operator allows for smooth connections"
- [readme] SummarizedExperiment as central container: "SummarizedExperiment (SE), which serves as a central repository for each pipeline's data, analysis steps, and results."
- [readme] maplet function suite: "maplet provides a suite of functions for interacting with this container including but not limited to data loading, annotation, statistical analysis, visualization, and reporting."
- [readme] Pipeline characteristics: "The combination of these elements allows for the creation of pipelines which are simple to follow, highly modular, and easily reproducible."
- [intro] Task workflow steps: "Chain at least one additional maplet function (e.g., annotation or statistical analysis) using the %>% pipe operator from magrittr."