|
MASFENON
Multi-Agent Adaptive Simulation Framework for Evolution in Networks of Networks
|
This part of the documentation serves as a practical guide for users who wish to explore the technical details of the MASFENON framework and learn how to operate it effectively. Here we provide an overview of MASFENON usage, including:
The purpose of this section is not only to document operational procedures, but also to support reproducibility of the experiments described in the thesis and to help future users adapt MASFENON to their own research use cases.
For readers seeking more in-depth technical documentation of the internal implementation (class structures, methods, source code references, etc.), the complete and always up-to-date Doxygen-generated documentation is publicly available at:
👉 https://josura.github.io/MASFENON/
This online resource provides detailed developer-oriented documentation, including C++ class hierarchies, function descriptions, code examples, and internal module dependencies. It is recommended for advanced users and developers intending to extend the framework or integrate it into custom workflows.
MASFENON (Multiagent Adaptive Simulation Framework for Evolution in Networks of Networks) is a standalone simulation framework designed to handle complex dynamic systems through modular multi-agent interaction. It was originally developed as part of the c2c-sepia project and has now been extracted as a clean, optimized version.
program_options is installed if neededHelp Message:
Example Run:
Custom scaling functions (dissipation, conservation, etc.) can be modified in src/CustomFunctions.
Propagation functions can be customized in src/computation/PropagationModelCustom.
This project is released under the Creative Commons Attribution 4.0 International License.
For issues, please use the GitHub issues page: https://github.com/josura/MASFENON/issues
This section documents the command-line interface (CLI) inputs, expected file formats, and configuration parameters of the MASFENON framework. Options are provided via Boost.Program_options. Boolean switches are disabled by default unless explicitly set.
At minimum, the framework requires:
Exactly one of the following must be specified for graphs:
--fUniqueGraph <file> OR --graphsFilesFolder <folder>Exactly one of the following should be specified for perturbations:
--fInitialPerturbationPerType <file> OR --initialPerturbationPerTypeFolder <folder>Optionally, inter-type interactions, node descriptions, and a list of subtypes can be provided.
Graph (edge list): graph.tsv
Initial perturbation (homogeneous): initialPerturbationHomogeneous.tsv
Initial perturbation (heterogeneous): initialPerturbation-typeN.tsv
Inter-type interactions: typesInteraction.tsv
Subtypes list (optional): subtypes.txt
Node descriptions (optional):
--nodeDescriptionFile <file>--nodeDescriptionFolder <folder>Each file should list node identifiers (and optionally annotations). If not provided, nodes are inferred from edges.
--fUniqueGraph <string>--graphsFilesFolder <string>--fInitialPerturbationPerType <string>--initialPerturbationPerTypeFolder <string>--typeInteractionFolder <string>--nodeDescriptionFile <string>--nodeDescriptionFolder <string>--subtypes <string>--intratypeIterations <int>--intertypeIterations <int>--timestep <double> → Δt Total simulated time: T = I_inter × Δt--quantizationMethod <string> (single or multiple)Dissipation
--dissipationModel <string>: none | power | random | periodic | scaled | custom--dissipationModelParameters <vector<double>>Conservation
--conservationModel <string>: none | scaled | random | custom--conservationModelParameters <vector<double>>Propagation
--propagationModel <string>: default | scaled | neighbors | customScaling | customScalingNeighbors | customPropagation--propagationModelParameters <vector<double>>--saturation--saturationTerm <double> → bounds [-s, s]--customSaturationFunction--conservateInitialNorm--undirectedEdges--undirectedTypeEdges--sameTypeCommunication--virtualNodesGranularity <string> (type, node, typeAndNode)--virtualNodesGranularityParameters <vector<string>>--resetVirtualOutputs--loggingOptions <string>: all (default) or none--verbose--treatWarningAsError--resumeCheckpoint--outputFolder <string>--outputFormat <string> (singleIteration or iterationMatrix)--saveAugmentedNetworks--savePerformance <string>| Option | Type | Default | Notes |
|---|---|---|---|
fUniqueGraph | string | — | Single graph file; XOR with graphsFilesFolder. |
graphsFilesFolder | string | — | Folder of graphs. |
fInitialPerturbationPerType | string | — | Single perturbation file. |
initialPerturbationPerTypeFolder | string | — | Folder of perturbation files. |
typeInteractionFolder | string | — | Inter-type edges folder. |
nodeDescriptionFile | string | — | Node names (common graph). |
nodeDescriptionFolder | string | — | Node names (per-graph). |
subtypes | string | — | Optional subtype list. |
intratypeIterations | int | — | >0 |
intertypeIterations | int | — | >0 |
timestep | double | — | Δt |
quantizationMethod | string | — | single | multiple |
dissipationModel | string | none | See list above. |
dissipationModelParameters | vector<double> | — | Model-dependent. |
conservationModel | string | none | See list above. |
conservationModelParameters | vector<double> | — | Model-dependent. |
propagationModel | string | default | See list above. |
propagationModelParameters | vector<double> | — | Model-dependent. |
saturation | flag | off | Enable clipping. |
saturationTerm | double | 1.0 | Requires --saturation. |
customSaturationFunction | flag | off | User-defined. |
conservateInitialNorm | flag | off | Norm constraint. |
undirectedEdges | flag | off | Intra-graph undirected. |
undirectedTypeEdges | flag | off | Inter-type undirected. |
sameTypeCommunication | flag | off | Same-type virtual node. |
resetVirtualOutputs | flag | off | Zeroed each iteration. |
virtualNodesGranularity | string | type | type | node | typeAndNode |
virtualNodesGranularityParameters | vector<string> | — | Reserved. |
loggingOptions | string | all | all | none |
verbose | flag | off | Extra logs. |
treatWarningAsError | flag | off | Fail on warning. |
resumeCheckpoint | flag | off | Resume run. |
outputFolder | string | — | Required for outputs. |
outputFormat | string | singleIteration | Iteration output mode. |
saveAugmentedNetworks | flag | off | Save augmented graphs. |
savePerformance | string | off | Save runtime summary. |
If there are problems with the options, file, or consistency, the program will throw exceptions with explanatory error messages, or print warnings. Use --verbose for more details.
In addition to the general-purpose simulation parameters, MASFENON includes a dedicated fitting workflow for calibrating the simulation to experimental single-cell data. In the current implementation, this process has been applied to fit the model to the AT1 cell metabolite layer in scRNA-seq data.
The fitting pipeline iteratively adjusts the dissipation, propagation, and conservation model parameters to minimize the mean squared error (MSE) between simulated outputs and experimental data at specific timepoints. The process is controlled by a main Bash script, which:
The fitting workflow depends on the following scripts:
simulation_custom_parameters.sh** compute-MSE-metabolites.py** createNewParametersFromMSEtable.sh** The main fitting script supports two execution modes:
Manual Range Mode
All three parameter families (dissipation, propagation, conservation) share the same starting min, max, and number of intervals.
Resume Mode
Reads previous simulation results from <OutputFolder>, computes the MSE tables, and generates new ranges from them. Useful to continue fitting without restarting from scratch.
Each epoch proceeds as follows:
epoch_<n> subfolder inside <OutputFolder>.Run the simulation with current parameter ranges:
Compute MSE values for each timepoint:
From the MSE table of the selected fitting timepoint (e.g., 10h), extract top configurations and generate updated parameter ranges:
min, max, and intervals for each parameter family from the generated file.The fitting process requires:
A Python virtual environment with dependencies for compute-MSE-metabolites.py. The main script activates it via:
For each epoch, the output folder contains:
Example: 3-epoch manual range fitting starting from 0.1–1.0 with 5 intervals:
The final MSE results and the best parameters are stored in out_fitting.
In addition to the global fitting workflow, a second (non-public) script exists for fine-grained parameter tuning. Instead of computing MSE on aggregated outputs, this script:
This method is useful for:
In addition to numerical outputs, MASFENON includes interactive visualization tools for exploring simulation results.
Two visualization scripts are available:
c2c-sepia/scripts/python/temporalSingleCell/plotResults_withLR.py).MASFENON/scripts/python/visualization/visualizationWebPageComplete.py).This tool provides an interactive web interface for visualizing all simulated networks and their temporal evolution. Implemented in Flask and Plotly, it allows:
The app uses:
<OutputDirectory>/<type>.tsv<AugmentedGraphDirectory>/<type>.tsv<InputValuesDirectory>/<type>.tsvAt startup, the app:
.tsv output files.node_traces_for_networks.pkledge_traces_for_networks.pkldict_for_plot.pkl/ → main interface with slider/read_types → list of network types/types/<type> → set active network/plot/<timepoint> → figure JSON for current type at timepoint/plot_singular/<type>/<timepoint> → figure JSON for specific type/timepoint#888), hover = weightYlGnBu reversed scale, size ∈ [4,22]spring_layoutThen open http://127.0.0.1:5000 in a browser.
Before the standalone release of MASFENON, its initial development and related experiments, scripts, and input preparation pipelines were maintained in the c2c-sepia repository.
This legacy repository still contains:
It was designed for cell-to-cell communication simulations with enriched pathways, using annotated scRNA-seq data and multi-agent system (MAS) principles, extended with parallel and distributed computation.
Dependencies and build process are nearly identical to MASFENON. The legacy repo now mainly contains domain-specific scripts for CCC simulation.
The MASFENON repository also provides scripts for:
These are not detailed here since:
README files.For comprehensive instructions, refer to those sources.