> 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-to-run-genome-wide-association-studies-gwas/conditional-analysis/unmodifiable-conditional-analysis-pipeline.md).

# Unmodifiable Conditional Analysis pipeline

## Summary

Unmodifiable pipelines are predefined workflows that cannot be modified by the user. The advantage of running unmodifiable pipelines compared to modifiable pipelines is that you will get results directly to the green library and the User results PheWeb browser. No download requests are needed, because results of unmodifiable pipeline have been verified not to contain any individual-level data. Running the finemapping unmodifiable pipeline is very similar to running finemapping in the modifiable pipelines, with some small restrictions. The unmodifiable finemapping pipeline can be accessed in the sandbox from The **pipelines app -> unmodifable workflow -> Unmodifiable Conditional (DF13/14**). For more information about the Pipelines tool, check the [Pipelines tool documentation](https://docs.finngen.fi/working-in-the-sandbox/which-tools-are-available/pipelines).

This pipeline version (from R14) combines in a single wdl the previous two separate wdls for finemapped regions and custom regions alike.

## How it Works

The pipeline can run in two modes, chosen automatically from the number of columns in pheno\_region\_input:

* 1 column (list of endpoints): the pipeline selects regions automatically based on variant p-values (see Region discovery below).
* 4 columns (endpoint/region/variant combinations): the pipeline does conditional analysis on the listed regions.

### Binary/quant automatic detection

The pipeline now automatically detects whether a phenotype is binary or quantiative and applies the matching regenie parameters accordingly. This means that users can now pass as inputs mixed phenotypes in one place without needing separate inputs and separate runs. Firth correction is applied automatically to variants with p-value below firth\_thres (default 0.01) when the endpoint is binary.&#x20;

### Region discovery

Region discovery (1-column input only). For each endpoint, candidate regions are built around the lead variants with p-value below 5e-8 in the summary statistics, using the same region definition as the finemapping pipeline (window set by `finemap_regions.window`, overlapping regions merged, maximum width 10 Mb, MHC excluded). If `add_hla is true`, the HLA region (chr6:29-34 Mb) is added as an extra region. Only regions on the chromosomes listed in chroms are kept. Within each region, the most significant variant becomes the starting point of a conditional chain, but only if its -log10(p) is above `locus_mlogp_threshold`; regions with no such variant are skipped.

### Minimum sample size

Before any analysis, the pipeline checks that each endpoint has enough samples with complete covariate data (no NA in any of the listed covariates). Binary endpoints need at least 5 cases and 5 controls; quantitative endpoints need at least 5 samples with a non-missing value. Adding phenotypes of this type will cause the whole pipeline to fail.

### Method

Each region is then analysed independently with regenie, using only the variants inside the region. In the first step, the analysis is conditioned on the starting variant(s). If the most significant remaining variant has -log10(p) above `conditioning_mlogp_threshold`, it is added to the set of conditioning variants and regenie is run again, now conditioning on all of them. This repeats until no variant passes the threshold or `max_steps steps` have been run. Each variant added this way is reported as an independent signal in the outputs, with its effect size and p-value both before and after conditioning.

## Summary of inputs

* `regenie_conditional_merged_sb.pheno_region_input`: The endpoint input,tab-separated, no header. This can be either:
  * A list of endpoints, one per line, to be analysed. For each endpoint, the pipeline will automatically extract the regions based on the variants' p-values.
  * A tab-separated file with endpoint-region pairs. There should be 4 columns. The columns should contain, in order:
    * The endpoint name
    * The chromosome of the region, numerical (23 for X)
    * The region, in format "chromosome:start-end"
    * The variants to condition on, comma-separated in format chr\_pos\_ref\_alt (e.g. chr6\_35376598\_G\_A; use chrX for chromosome 23
* `regenie_conditional_merged_sb.sumstats_root`: path to the summary statistics (bgzipped, with tabix index .tbi in the same folder). `PHENO` will be replaced by the phenotype names. All summary statistic files have to be in the same folder. The files must have the standard FinnGen column names (#chrom, pos, ref, alt, pval, mlogp, beta, sebeta, af\_alt).
* `regenie_conditional_merged_sb.null_root`: path to the endpoint step 1 null model files, i.e. the LOCO prediction files (\*.loco.gz). `PHENO` will be replaced by the phenotype names. Note that all files have to be in the same folder. The null model must come from a step 1 run of the same trait type (binary/quantitative) that the pipeline will detect for the endpoint.
* `regenie_conditional_merged_sb.add_hla`: Include HLA region or not
* `regenie_conditional_merged_sb.prefix`: the prefix of the output
* `regenie_conditional_merged_sb.pheno_file`: Endpoint cases\&controls file, in same format as e.g. analysis covariates file
* `regenie_conditional_merged_sb.cov_file`: covariates file, in same format as e.g. analysis covariates file
* `regenie_conditional_merged_sb.covariates`: Comma-separated list of covariates to include in the analysis, e.g. "SEX\_IMPUTED,AGE\_AT\_DEATH\_OR\_END\_OF\_FOLLOWUP,PC{1:10}". All covariates must exist in cov\_file. For each endpoint, the pipeline drops covariates with fewer than 10 non-zero values among the samples with that endpoint (e.g. a batch covariate with no samples in the endpoint), to prevent regenie from failing.
* `regenie_conditional_merged_sb.chroms`: Comma-separated list of chromosomes to include, e.g. "1,2,3,...,22,23" (23 for X). Only used with the 1-column input (region discovery); regions supplied in a 4-column input are always analysed, whatever their chromosome.
* `regenie_conditional_merged_sb.regenie_conditional.max_steps`: Maximum number of conditioning steps per region (default 10). The chain stops at this point even if significant variants remain.
* `regenie_conditional_merged_sb.regenie_conditional.min_mac`: Minor allele count (MAC) filter for variants, variants with MAC less than threshold will not be included in output.
* `regenie_conditional_merged_sb.regenie_conditional.min_info`: INFO filter for variants; variants with INFO below this threshold are not tested and will not be included in the output.
* `regenie_conditional_merged_sb.regenie_conditional.firth_thres`: P-value threshold for Firth correction (default 0.01). Only applies to binary endpoints: variants with p-value below this threshold are Firth-corrected. Has no effect on quantitative endpoints.
* `regenie_conditional_merged_sb.locus_mlogp_threshold`: -log10(p) threshold for the starting variant of each region (1-column input only). A region is analysed only if its most significant variant is above this threshold.
* `regenie_conditional_merged_sb.conditioning_mlogp_threshold`: -log10(p) threshold for continuing the conditional chain. After each step, the most significant remaining variant is added to the conditioning set only if it is above this threshold; otherwise the chain stops.

These are options for the region selection algorithm. They can be changed for users who are familiar with the [pipeline](https://docs.finngen.fi/working-in-the-sandbox/running-analyses-in-sandbox/how-to-run-finemapping-pipeline.md), but we recommend not touching them

* `regenie_conditional_merged_sb.finemap_regions.rsid_col`: ""
* `regenie_conditional_merged_sb.finemap_regions.x_chromosome`: "true"
* `regenie_conditional_merged_sb.finemap_regions.window`: "1500000"
* `regenie_conditional_merged_sb.finemap_regions.scale_se_by_pval`: "false"
* `regenie_conditional_merged_sb.finemap_regions.p_threshold`: "0.00000005"
* `regenie_conditional_merged_sb.finemap_regions.max_region_width`: "10000000"
* `regenie_conditional_merged_sb.finemap_regions.window_shrink_ratio`: "0.9"

## Outputs

There are seven outputs, the first two of which are of interest for viewing them and the last 3 are for importing the data to userresults pheweb browser.

* `all_hits` . One file per endpoint (.independent\_snps.txt) containing all conditional chains for that endpoint. Each chain starts with the starting variant of the region, followed by one row per independent signal found by conditioning. Columns:&#x20;
  * VARIANT: the variant&#x20;
  * BETA,SE,MLOG10P: its values in the original (unconditioned) summary statistics&#x20;
  * BETA\_cond,SE\_cond,MLOG10P\_cond: its values after conditioning (NA for the starting variant)&#x20;
  * VARIANT\_cond: the variants it was conditioned on (NA for the starting variant)

<table><thead><tr><th width="232.4444580078125">VARIANT</th><th width="128">BETA</th><th width="128">SE</th><th width="128">MLOG10P</th><th>BETA_cond</th><th>SE_cond</th><th>MLOG10P_cond</th><th width="550.2222900390625">VARIANT_cond</th></tr></thead><tbody><tr><td>chr1_17381854_G_A</td><td>-0.0371</td><td>0.0064</td><td>8.2425</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr2_161145756_T_A</td><td>-0.0429</td><td>0.0073</td><td>8.3533</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr2_196338002_G_A</td><td>0.059</td><td>0.0095</td><td>9.2624</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr3_18633152_A_C</td><td>0.044</td><td>0.0067</td><td>10.3279</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr3_16811234_G_A</td><td>-0.0367</td><td>0.0065</td><td>7.7032</td><td>-0.0328</td><td>0.0066</td><td>6.1828</td><td>chr3_18633152_A_C</td></tr><tr><td>chr3_43656252_G_A</td><td>0.0759</td><td>0.01</td><td>13.5747</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr3_44176307_AAAG_A</td><td>0.7812</td><td>0.1679</td><td>5.4822</td><td>0.9816</td><td>0.1974</td><td>6.1793</td><td>chr3_43656252_G_A</td></tr><tr><td>chr3_158237129_A_G</td><td>0.0388</td><td>0.0065</td><td>8.6487</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr3_177171295_G_A</td><td>0.0843</td><td>0.0133</td><td>9.588</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr4_59388159_A_G</td><td>-0.0403</td><td>0.0071</td><td>7.8402</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr5_104451467_A_C</td><td>0.0383</td><td>0.0066</td><td>8.1869</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr5_120730291_A_G</td><td>-0.0437</td><td>0.0066</td><td>10.5128</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr5_121149217_A_C</td><td>0.6199</td><td>0.1257</td><td>6.086</td><td>0.7808</td><td>0.1422</td><td>7.3998</td><td>chr5_120730291_A_G</td></tr><tr><td>chr5_144466903_T_C</td><td>0.0374</td><td>0.0065</td><td>8.1641</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr5_153777668_A_C</td><td>-0.0381</td><td>0.0065</td><td>8.3132</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr5_153129992_T_G</td><td>-0.0329</td><td>0.0065</td><td>6.3568</td><td>-0.032</td><td>0.0065</td><td>6.0592</td><td>chr5_153777668_A_C</td></tr><tr><td>chr6_51715850_T_C</td><td>-0.0567</td><td>0.0103</td><td>7.4145</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr6_151880872_T_C</td><td>-0.0474</td><td>0.0065</td><td>12.4306</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr6_164751626_G_A</td><td>-0.038</td><td>0.0063</td><td>8.717</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr9_36999372_C_T</td><td>0.0348</td><td>0.0063</td><td>7.419</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr9_95537395_T_A</td><td>0.0565</td><td>0.0102</td><td>7.4833</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr10_21600368_A_AAC</td><td>-0.0515</td><td>0.0085</td><td>8.819</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr10_104842738_C_CT</td><td>-0.0411</td><td>0.007</td><td>8.2919</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr11_28582122_A_G</td><td>-0.0389</td><td>0.0066</td><td>8.3234</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr11_99647795_T_C</td><td>0.0431</td><td>0.0069</td><td>9.5016</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr11_113324873_A_G</td><td>-0.038</td><td>0.0064</td><td>8.5837</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr11_115118275_G_A</td><td>-0.0407</td><td>0.007</td><td>8.312</td><td>-0.0398</td><td>0.007</td><td>7.9104</td><td>chr11_113324873_A_G</td></tr><tr><td>chr11_113050349_C_T</td><td>0.0364</td><td>0.0064</td><td>7.8798</td><td>0.0331</td><td>0.0064</td><td>6.5628</td><td>chr11_113324873_A_G,chr11_115118275_G_A</td></tr><tr><td>chr12_60397384_T_A</td><td>-0.0372</td><td>0.0065</td><td>8.0402</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr14_70749996_T_C</td><td>-0.227</td><td>0.0359</td><td>9.5829</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr15_73812581_C_A</td><td>-0.0584</td><td>0.0105</td><td>7.6144</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr16_21667465_T_C</td><td>0.0434</td><td>0.0073</td><td>8.6185</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr16_65751219_A_G</td><td>0.0357</td><td>0.0064</td><td>7.614</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr16_72134342_T_G</td><td>0.0485</td><td>0.0063</td><td>13.8185</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr16_71324662_TCTGCTAATAGGAGTGA_T</td><td>0.0829</td><td>0.0128</td><td>10.054</td><td>0.0728</td><td>0.0131</td><td>7.582</td><td>chr16_72134342_T_G</td></tr><tr><td>chr18_53199573_T_C</td><td>0.0497</td><td>0.0063</td><td>14.3777</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr18_55212207_T_C</td><td>0.0778</td><td>0.0148</td><td>6.843</td><td>0.0759</td><td>0.015</td><td>6.3537</td><td>chr18_53199573_T_C</td></tr><tr><td>chr18_76052843_T_C</td><td>0.0474</td><td>0.0085</td><td>7.6577</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chr19_49457409_G_T</td><td>0.0795</td><td>0.0136</td><td>8.3038</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chrX_93697357_A_G</td><td>0.4882</td><td>0.0889</td><td>7.3997</td><td>nan</td><td>nan</td><td>nan</td><td>nan</td></tr><tr><td>chrX_93934138_A_G</td><td>0.7061</td><td>0.1479</td><td>5.7454</td><td>1.0262</td><td>0.1883</td><td>7.2998</td><td>chrX_93697357_A_G</td></tr></tbody></table>

`chr3_18633152_A_C` is the first hit to have a valid conditional chain with the secondary hit `chr3_16811234_G_A`, for which `BETA`, `SE` and `MLOG10P` are provided both for the original (input) sumstats and the conditioned one. In this case, one can see that the values did not change significantly after conditioning, but it can happen that variants go from being non significant to significant or that betas change considerably.

* `all_chains`. The same chains as all\_hits, but one file per region instead of merged per endpoint.
* `all_outputs`. This file is simply the collection of all regenie outputs and it's meant for debugging in case something went wrong
* `all_logs`. The regenie logs of all conditioning steps, combined per endpoint. Meant for debugging in case something went wrong.
* `metadata` : metadata file for identifying an existing already imported result in userresults pheweb browser.
* `sql_import` : File for importing the results to userresults pheweb browser
* `import_conditional_files` : conditional results to be imported into the userresults PheWeb browser<br>
