Commit 6f814eb9 authored by Saman Sarraf's avatar Saman Sarraf
Browse files

updated README by adding more details

parent e2f75b8a
Loading
Loading
Loading
Loading
+2 KiB (8 KiB)

File changed.

No diff preview for this file type.

+1 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
  <component name="VcsDirectoryMappings">
    <mapping directory="$PROJECT_DIR$" vcs="Git" />
    <mapping directory="$PROJECT_DIR$/MultiModalCommunityDetection" vcs="Git" />
  </component>
</project>
 No newline at end of file
+84 −47
Original line number Diff line number Diff line
@@ -63,68 +63,105 @@ MINT is designed for scalable and interpretable community detection, with applic

## Quick Start
### Minimal Working Example
  ```Python
  # Import MINT
  from MINT import data_standardization, snf, genlouvain, visualization

  # Load dataset
  # (Provide a sample dataset path)

  # Standardize data
  standardized_data = data_standardization.standardize(data)

  # Perform Similarity Network Fusion
  fused_network = snf.snf(standardized_data)

  # Detect communities using Generalized Louvain
  communities = genlouvain.detect_communities(fused_network)

  # Visualize results
  visualization.plot_communities(fused_network, communities)
  ```Bash
  # Change directory to the toolbox folder (cd MultiModalCommunityDetection)
  # Run the following command showing all the options in the toolbox
  python main.py --help
  # Using a given JSON file configured for an analysis, MINT executes the steps in JSON.
  python main.py --json ../GL.json 
  python main.py --json ../SNF.json
  ```
### Command Line Arguments for MINT
| Short Argument | Long Argument  | Description |
|----------------|----------------|-------------|
| `-j`  | `--json`         | JSON Configuration from JSON file |
| `-nm` | `--numbermodal`  | Number of modalities |
| `-ns` | `--numbersubj`   | Number of subjects (consistent across modalities) |
| `-f`  | `--filetype`     | Type of files (either csv or excel) |
| `-cp` | `--csvpath`      | List of CSV files (one per modality), comma-separated |
| `-ep` | `--excelpath`    | List of Excel files (one per modality) OR one Excel file with data in multiple sheets |
| `-sn` | `--sheetname`    | List of sheet names (comma-separated, one sheet per modality) |
| `-cl` | `--colnames`     | List of columns to include (optional, defaults to all columns) |
| `-nr` | `--norm`         | List of modalities (by index) requiring normalization |
| `-nt` | `--normtype`     | Normalization method (either minmax or max) |
| `-m`  | `--method`       | Community detection method: `snf` (Similarity Network Fusion) or `gl` (Generalized Louvain) |
| `-sf` | `--snfpath`      | Path to store SNF results (CSV) |
| `-gp` | `--glpath`       | Path to store GenLouvain results (CSV) |
| `-nc` | `--numbercluster`| Number of clusters for SNF |
| `-v`  | `--verbose`      | Display figures (True/False) |
| `-co` | `--featcoef`     | Coefficient for top feature selection |
| `-cv` | `--crossvaltype` | Cross Validation Method (default = 4)<br> 1 = all subjects<br>2 = centroid<br>3 = centroid replacement<br>4 = k-fold |
| `-lf` | `--listfeat`     | List of user-defined features (overrides feature ranking algorithms) |

NB: The table above helps you understand the features available in MINT; however, you can also use the JSON templates provided with the toolbox and run the analysis using the JSON option, instead of specifying all arguments directly on the command line.

NB: MINT does not create any folders automatically. Any folders specified in the JSON file must be manually created by the user before running the command. 
### JSON configuration file for pipeline automation.
The following is an example of a JSON configuration file with parameters set. To fully understand the purpose and function of each parameter, please refer to the Command Line Arguments Table above, or run the help option of the toolbox from the command line, as previously mentioned. 
  ```markdown
  {
    "NUMBERMODAL": 5,
    "NUMBERSUBJ": 206,
    "FILETYPE": "excel",
    "CSVPATH": [],
    "EXCELPATH": ["/ABC/XYZ/Modality_1.xlsx",
        "/ABC/XYZ/Modality_2.xlsx",
        "/ABC/XYZ/Modality_3.xlsx",
        "/ABC/XYZ/Modality_4.xlsx",
    "/ABC/XYZ/Modality_5.xlsx"],
    "SHEETNAME": [],
    "COLNAMES": [],
    "NORM": [2,3,4,5],
    "NORMTYPE": "minmax",
    "METHOD": "snf",
    "SNFPATH": "/DEF/SNF_Results.csv",
    "GLPATH": [],
    "NUMBERCLUSTER": 3,
    "VERBOSE": true,
    "FEATCOEF": 1,
    "CROSSVALTYPE": 4,
    "LISTFEAT": [],
    "CROSSREP": 100,
    "KFOLD": 10,
    "CVRESULT": "/LMN/SNF_Results_CV.csv",
    "MODNAME": ["Modality_1","Modality_2","Modality_3","Modality_4","Modality_5"],
    "CORR": "spearman",
    "THRESH": 0.30,
    "SNFIG": "/LMN/FIG/",
    "NORMROW": true,
    "OUTLIER": false,
    "OUTLIERPARAMS": [3, "median"],
    "QUALITYCONTORL":true,
    "OPTIMIZATION":"all"}
  ```
## Usage Guide

### Input Data Format

Supports CSV, JSON, and GraphML.
Example CSV structure:
csv

CopyEdit

ID, Modality1, Modality2, Modality3

1, 0.5, 0.7, 0.8

2, 0.6, 0.9, 0.85

## JSON configuration file for pipeline automation.
### Configuration Parameters

- modality_weight: Adjusts importance of each data source.
- num_clusters: Defines the number of communities.
- threshold: Sets minimum edge weight for graph construction.


- Input data (modalities) must be provided as CSV or Excel files.
- Each file must include feature headers, similar to a Pandas DataFrame.
- If using separate files for each modality, or a single Excel file with multiple sheets, ensure that the JSON configuration file is correctly set up to reference each file or sheet.
- The number of subjects must be identical across all modalities, and this value must be accurately specified in the JSON configuration file.

### Output Format

Assuming all three steps including SNF/GL, cross validation and optimization are set in the JSON configuration, MINT will generate 5 CSV files saved in the destitation as follows:
- Original SNF or GL result file including all modalities as well as the community detection.
- Cross validation of the original results
- Optimization results including only optimal modalities as well as community detection based on the optimal modalities. 
- Cross validation of the optimal community detection. 
- SNF will generate spectral clustering figures; therefore, it is necessary to set the path in the JSON file.
![Modality.png](examples/Modality.png)![SNF.png](examples/SNF.png)
## Citation

If you use MINT in your research, please cite:

```bibtex
@article{yourpaper2024,

  author = {Your Name et al.},

  title = {MINT: A Multimodal Community Detection Toolbox},

  journal = {Journal Name},

  year = {2024},

  volume = {X},

  pages = {XX-XX},

  doi = {DOI_LINK}
}
```

examples/.DS_Store

0 → 100644
+6 KiB

File added.

No diff preview for this file type.

examples/GL.json

0 → 100644
+30 −0
Original line number Diff line number Diff line
{
    "NUMBERMODAL": 4,
    "NUMBERSUBJ": 143,
    "FILETYPE": "excel",
    "CSVPATH": [],
    "EXCELPATH": ["/ABC/XYZ/With_covariates.xlsx"],
    "SHEETNAME": ["Modality_1","Modality_2","Modality_3","Modality_4","Modality_5"],
    "COLNAMES": [],
    "NORM": [1,2,3,4],
    "NORMTYPE": "minmax",
    "METHOD": "gl",
    "SNFPATH": [],
    "GLPATH": "/ABC/XYZ/GL_results.csv",
    "NUMBERCLUSTER": 2,
    "VERBOSE": true,
    "FEATCOEF": 1,
    "CROSSVALTYPE": 4,
    "LISTFEAT": [],
    "CROSSREP": 100,
    "KFOLD": 10,
    "CVRESULT": "/ABC/XYZ/GL_02222025/GL_results_CV.csv,
    "MODNAME": ["Mod_1","Mod_2","Mod_3","Mod_4","Mod_5"],
    "CORR": "spearman",
    "THRESH": 0.30,
    "SNFIG": false,
    "NORMROW": true,
    "OUTLIER": false,
    "OUTLIERPARAMS": [3, "median"],
    "QUALITYCONTORL":true,
    "OPTIMIZATION":"all"}
Loading