> For the complete documentation index, see [llms.txt](https://docs.finngen.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.finngen.fi/working-in-the-sandbox/running-analyses-in-sandbox/how-much-does-running-a-workflow-cost.md).

# How much does running a workflow cost?

This page gives ballpark numbers for estimating analysis costs as of R14.

The cost of different workflows is highly dependent on the type of the analysis. Some analyses are relatively fixed in cost, while others are highly dependent on inputs.

Examples of fixed costs analysis include GWAS, which generally speaking do a same amount of work. Doing a GWAS study of a single endpoint is essentially always the same amount of work, as the GWAS has to be done on the entire imputed genotype. Other analyses, such as finemapping or conditional analysis, have more variable costs, with costs depending heavily on inputs.

#### Regenie

Pipelines: E.g. UnmodifiableRegenieDF13,UnmodifiableRegenieDF14

Currently the cost for doing a GWAS with Regenie for approximately 500,000 samples is about **15-30 euros**, depending on preemption rates for the workers. The main part of this cost is step 2 of the analysis, which accounts for more than 95% of the cost. The costs have been estimated by assuming:

* Approximately 60 minutes per one step2 task
* 535 chunks to calculate
* tasks mainly finish without preemption, with approximately 1.5X overhead due to preemption

#### Finemap

Pipelines: E.g. UnmodifiableFinemapDF13, UnmodifiableFinemapDF14

The cost for finemapping relies heavily on the GWAS data to be finemapped. Both the amount of genome-wide significant loci in the GWAS results and their width affect the finemapping costs.

When finemapping a summary statistic, we select the regions from a summary statistic that have genome-wide significant variants, and finemap those individually. This is because finemapping a whole summary statistic would be computationally infeasible. When two genome-wide significant loci are in close proximity, we combine the regions containing these loci and finemap this larger region. You can find more information about region selection in finemapping [here](https://finngen.gitbook.io/documentation/methods/finemapping). In essence, having a lot of genome-wide significant variants close by (<1.5MB) will lead to them being in the same region, creating larger regions.

The main driver for cost in finemapping is the amount of variants in a region. Since we have to calculate in-sample LD between every variant in a region, the computations needed for calculating LD for a region depend on the size of the region, as does the memory usage. Likewise, when finemapping with SuSiE, the model has to consider the effects of all of the variants together, meaning larger regions take more memory and time to model.

LD computation costs show quadratic growth  based on the amount of variants in a region. For R14 endpoints, you can expect a single region's LD computation to cost between 0.5-10 euros. For example, a region with 20,000 variants would cost approximately 0.5 euros, and a region with 50,000 variants should cost approximately 3-4 euros, as the region is 2.5X larger, so the cost should be 2.5^2=6.25X larger. A region with 100,000 variants, which is about the largest region we can finemap, would cost approximately 6-8 euros under this model.\
\
SuSiE costs scale somewhere between quadratically and cubically based on region variant amount, as SuSie memory consumption grows approximately quadratically by region size, and SuSie runtime also grows somewhat linearly depending on the region size. For R14 endpoints, you can expect a single region's finemapping with SuSiE to cost between 0.05 and 10 euros, with all but the largest regions costing less than 1-2 euros. For an R14 endpoint and a region of 20,000 variants, SuSie costs approximately 0.03 euros, and for a region of 55,000 variants, Susie costs approximately 0.55 euros. This is more than a strictly quadratic growth, but less than if the relationship was purely cubic.

Finemapping with FINEMAP is very resource-efficient compared to both SuSiE and LD calculation, and should not matter much in the final cost of a finemapping workflow.

Therefore, a typical finemapping workflow with e.g. 10 finemapped regions can cost anywhere between **5 and 150 euros**, with typical endpoints costing less than **30 euros**. The large range is due to the quadratic or worse relationship of variant amount in region to cost. The region sizes predict the total cost of the workflow quite well, so manually selecting regions should give an accurate estimate for the cost of the pipeline.

#### Conditional analysis

Pipelines: E.g. UnmodifiableRegenieConditionalDF13, UnmodifiableRegenieConditionalDF14

Conditional analysis costs rely on the GWAS data to be analysed, but they are typically much lower than finemapping. Since conditional analysis does not require the calculation of LD, the cost of conditionally analysing a single region is similar to performing GWAS analysis on that region with some multiple depending on how many independent signals there are in that region.

As an example, let's assume that we have 10 regions of approximately 50,000 variants per region. Let's also assume that each region has a lot of signals left after conditioning, so we will assume that we perform the conditional association analysis 10 times per region (the default maximum in the pipeline). This is similar to running each region 10 times, so we have approxiamtely 10\*10\*50,000= 5,000,000 variants to analyse. A regular GWAS has approximately 20,000,000 variants to analyse, so we can expect this conditional analysis to cost approximately one fourth of the typical GWAS, or 4-8 euros. Since there are usually less independent signals in a region than 10, a real conditional analysis with 10 regions is likely to cost less than the numbers presented here.
