# How to run finemapping pipeline

## Introduction

By [finemapping](/background-reading/finemapping.md), we mean identifying the variants with the highest probability of being causal from your GWAS summary statistics. In the Sandbox, we have a pipeline for doing this using summary statistics. The pipeline calculates linkage disequilibrium (LD) between variants in the locus using [LDstore2](http://www.christianbenner.com) and then using LD matrices and summary statistics finemaps each genome-wide significant (P<5E-8) locus in the supplied summary statistics using a combination of [FINEMAP](http://www.christianbenner.com) and [SuSiE](https://github.com/stephenslab/susieR). A detailed description of the pipeline can be found from the [Github repository](https://github.com/FINNGEN/finemapping-pipeline).

Alternatively, users can provide their own custom regions to finemap instead of the automatic selection for regions with genome-wide significant variants.

## Running finemapping in sandbox

There are multiple ways to run the finemapping pipeline with your custom GWAS results but we strongly recommend the unmodifiable finemapping pipeline (see below).

This pipeline has some pros: Your results will be automatically exported to the green library without a need for a download request and the outputs can be automatically incorporated to Userresults browser (for latest release). The pipeline is also usually the most up to date.

However, there are some reasons why you might not want to run the unmodifiable finemapping pipeline:

* You do NOT want the outputs to be automatically exported
* You need to modify the pipeline

In those cases, the modifiable finemapping pipeline is an excellent choice.

### Unmodifiable finemapping pipeline (R12 and later)

With the introduction of unmodifiable pipelines, the easiest and recommended way to get your custom GWAS endpoint finemapped is with the [unmodifiable finemapping pipeline](/working-in-the-sandbox/running-analyses-in-sandbox/how-to-run-finemapping-pipeline/unmodifiable-finemapping-pipeline.md). Using this pipeline , your results are automatically uploaded to the [userresults Pheweb](https://userresults.finngen.fi/) and automatically transferred to the green library so that no download request is needed.

### Modifiable finemapping pipeline (R12 and earlier)

We recommend the [unmodifiable finemapping pipeline](/working-in-the-sandbox/running-analyses-in-sandbox/how-to-run-finemapping-pipeline/unmodifiable-finemapping-pipeline.md) to run custom GWAS finemapping, which will suit most users' needs. However, we still provide access to the finemapping scripts (see [Modifiable Finemapping pipeline](/working-in-the-sandbox/running-analyses-in-sandbox/how-to-run-finemapping-pipeline/modifiable-finemapping-pipeline.md)), which may be useful for earlier (pre-R12) releases or if you wish to further customise the finemapping options.

## Additional information

* For information on the contents and format of the finemapping pipeline output files, please see [Finemapping results format](/finngen-data-specifics/green-library-data-aggregate-data/core-analysis-results-files/finemapping-results-format.md).
* For a demonstration on how to run Finemapping, please watch the presentation given by Bridget Riley-Gillis in the February 8th 2022 FinnGen Users' meeting. [Link to recording](https://tt.eduuni.fi/sites/hy-finngen/All/Shared%20Documents/FinnGen%20Users'%20meetings/Fg_users_mtg_080222)


---

# 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-in-the-sandbox/running-analyses-in-sandbox/how-to-run-finemapping-pipeline.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.
