9  Results Report

The mapa package provides two powerful functions for exporting and reporting your functional module analysis results: export_functional_module() for data export and report_functional_module() for comprehensive report generation. These functions help you share your findings through structured data files and professional reports.

library(mapa)
Important

Prerequisites: Before generating reports, ensure you have completed your MAPA analysis workflow including:

  • Enrichment analysis: enrich_pathway() or do_gsea()
  • Pathway similarity calculation: merge_pathways() or get_bioembedsim()
  • Optional: Optimal clustering parameters determination: determine_optimal_clusters()
  • Clustering: get_functional_modules()
  • Optional: LLM interpretation: llm_interpret_module()

The functions in this chapter work with the final functional_module object from your analysis.

9.1 Overview

The reporting functions serve different purposes:

Function Purpose Output
export_functional_module() Export analysis results to CSV files Individual UTF-8 CSV files for each analysis component
report_functional_module() Generate comprehensive analysis reports HTML/PDF/Word/Markdown reports with embedded plots and tables

9.2 Data Export with export_functional_module()

The export_functional_module() function exports all analysis results to individual CSV files, making your data easily accessible for further analysis or sharing with collaborators.

9.2.1 Basic Usage

# Export all results to CSV files
export_functional_module(
  object = functional_modules,
  path = "mapa_results"
)

This creates a directory structure with individual CSV files for each analysis component in your current working directory:

mapa_results/
├── enriched_pathway_go.csv
├── enriched_pathway_kegg.csv  
├── enriched_pathway_reactome.csv
├── enriched_module_go.csv
├── enriched_module_kegg.csv
├── enriched_module_reactome.csv
├── enriched_functional_module.csv
└── llm_module_interpretation.csv

9.2.2 Output Files Description

Pathway-Level Results: enriched_pathway_*.csv: enrichment analysis results from ORA or GSEA

Module-Level Results: enriched_module_*.csv: modules from database-specific clustering (SimCluster)

Functional Module Results:

  • enriched_functional_module.csv: Cross-database functional modules
  • llm_module_interpretation.csv: LLM-generated module interpretations (if available)
Tip

Working with Exported Data: The CSV files can be easily imported into Excel, R, Python, or other analysis tools. Column names and data types are preserved for seamless downstream analysis.

9.3 Comprehensive Report Generation with report_functional_module()

The report_functional_module() function creates professional, publication-ready reports that combine your analysis results with automated visualizations and interpretations.

9.3.1 Basic Usage

# Generate an HTML report
report_functional_module(
  object = functional_modules,
  path = "reports",
  type = "html"
)

This creates a report directory in your current working directory:

reports/Report/
├── mapa_report.html

9.3.2 Report Contents

The generated report automatically includes:

Analysis Summary:

  • Parameters: Overview of enrichment analysis parameters and results
  • Object information: Summary statistics for each database and analysis level, and processing timeline and method details

Visualizations:

  • Top enriched pathways bar charts
  • Database-specific module bar charts (if applicable)
  • Functional module bar charts with LLM names (if available)
  • Similarity networks for all analysis levels

Data Tables:

  • One of Enrichment results for functional modules or LLM interpretation results with confidence scores (if available)

9.3.3 Directory Management

The function automatically manages output directories:

# First report
report_functional_module(object, path = "results")
# Creates: results/Report/

# Second report  
report_functional_module(object, path = "results") 
# Creates: results/Report_2/

# Third report
report_functional_module(object, path = "results")
# Creates: results/Report_3/

This prevents accidental overwrites while maintaining organized output.

9.4 Troubleshooting Common Issues

  • LaTeX/PDF Issues:

    # Check LaTeX installation
    Sys.which("pdflatex")
    
    # Install TinyTeX if empty result
    install.packages("tinytex")
    tinytex::install_tinytex()
    
    # Alternative: use HTML for immediate results
    report_functional_module(object, type = "html")
  • Missing Dependencies: The function will provide informative error messages about missing packages and suggest installation commands.

9.5 Next Steps

With your results exported and reports generated, you now have comprehensive documentation of your functional module analysis. These outputs provide the foundation for:

  • Further Analysis: Use exported CSV files for custom analyses or integration with other tools
  • Collaboration: Share HTML reports with colleagues for easy viewing and discussion
  • Publication: Use PDF reports and exported data for manuscript preparation
  • Presentation: Extract visualizations and key findings for presentations

The MAPA workflow is now complete, providing you with actionable insights into the functional organization of your biological data.