# How to prepare an input file for MMP

See a tutorial video on how to use the Multiple Manhattan Plot (MMP) tool from the [27th September 2022 Users' Meeting video](https://www.finngen.fi/en/members/recordings/finngen-data-users-meeting-27th-sep-2022).

Prepare an input file for the Multiple Manhattan Plot (MMP) tool on your local machine. MMP uses GWAS summary data that is [available in Green Library](/finngen-data-specifics/green-library-data-aggregate-data/how-can-you-download-green-data.md) for [FinnGen core analysis GWAS results](/finngen-data-specifics/green-library-data-aggregate-data/core-analysis-results-files/gwas-results-format.md) and for [Custom GWAS tools results](/working-in-the-sandbox/which-tools-are-available/untitled.md). You can also use your own or external summary stats as input. For summary stats created with other tools (e.g. [Pipelines](/working-in-the-sandbox/running-analyses-in-sandbox.md)) make a [data download request](/working-in-the-sandbox/quirks-and-features/how-to-download-results-from-your-ivm.md) to get the summary data out of the Sandbox and into the Green Downloads bucket. Do not use FinnGen Sandbox for MMP input file preparation as it will slow down your analysis due to the need for [data download requests](/working-in-the-sandbox/quirks-and-features/how-to-download-results-from-your-ivm.md) and cause extra admin work.

The program MMP::io that creates the input file for MMP is available at:\
<https://github.com/FINNGEN/mmpio/#readme>

See also a [presentation of New FinGen tools and their application to example diseases from User's meeting 28th March 2023 recording ](https://www.finngen.fi/en/members/recordings/finngen-data-users-meeting-28th-march-2023)(at 25min 23sec) including usage of Multiple Manhattan Plot tool.

<figure><img src="/files/X6XHbQGQhId4axXkge5s" alt="overview of MMP::io"><figcaption></figcaption></figure>

## Step 1: Download the program

Download the MMP::io binary program from GitHub:

1. Go to MMP::io release page: <https://github.com/FINNGEN/mmpio/releases>
2. Download the program matching your platform
3. Extract this .tar file (e.g. `tar -xf mmpio-linux-x86-64.tar`)
4. You should now have a `mmpio` file and a `config.json.sample` file in your working directory

## **Step 2: Configure your input GWAS summary stats**

MMP::io needs to know where to find your GWAS summary stats, and what column names are used for chromosome, reference, etc.

This is done by:

1. Copying the file `config.json.sample` to `config.json`
2. Editing this `config.json` with the paths to the GWAS summary stats and info about the column names

Here is an example of what the config.json file can look like once correctly edited:

```
{
  "inputs":
    [
      {
        "tag": "FGFractCountAllAges",
        "filepath": "gwas/FRACTURECOUNT/FRACTURECOUNT.gz",
        "col_chrom": "#chrom",
        "col_pos": "pos",
        "col_ref": "ref",
        "col_alt": "alt",
        "col_pval": "pval",
        "col_beta": "beta",
        "col_af": "af_alt",
        "pval_threshold": 1e-06, 
        "fine_mapping_filepath": null
      },
      {
        "tag": "FGFractCountBin18Y1998",
        "filepath": "gwas/FRACTBIN18Y1998/finngen_R9_sandbox_custom_gwas_FRACTBIN18Y1998_FRACTBIN18Y1998.gz",
        "col_chrom": "#chrom",
        "col_pos": "pos",
        "col_ref": "ref",
        "col_alt": "alt",
        "col_pval": "pval",
        "col_beta": "beta",
        "col_af": "af_alt",
        "pval_threshold": 1e-06,
        "fine_mapping_filepath": null
      }
    ],
  "heterogeneity_tests": []
}
```

## Step 3: Run the program

On the common line, go to the directory containing the files `mmpio` and `config.json`. Then run the program:

```
./mmpio
```

The program will read all variants below the given significance threshold in each configured summary stat file. It will then take the union of these variants and print out stats from each summary stat file for the union of the variants (NA will be printed if a variant is missing in a summary stat).

While MMP::io is running it will output something like this:

```
[1/3] Checking variant selection...
- processing FGFractCountAllAges
- processing FGFractCountBin18Y1998
* done FGFractCountBin18Y1998
* done FGFractCountAllAges
[2/3] Getting variant statistics...
- processing FGFractCountAllAges
- processing FGFractCountBin18Y1998
* done FGFractCountBin18Y1998
* done FGFractCountAllAges
[3/3] Writing output to mmp.tsv ...
```

When the program is finnished you will have a `mmp.tsv` file that ready for [use in MMP](https://geneviz.aalto.fi/MMP/dashboard/).

If you needed you can change the configuration in `config.json` and run MMP::io again with `./mmp`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.finngen.fi/working-outside-the-sandbox/multiple-manhattan-plot-mmp/how-to-prepare-an-input-file-for-mmp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
