---
title: "Single-trait Fine-mapping with FineBoost"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Single-trait Fine-mapping with FineBoost}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  dpi = 50
)
```


This vignette demonstrates how to perform single-trait fine-mapping analysis using FineBoost, a specialized single-trait version of ColocBoost, 
with both individual-level data and summary statistics. Specifically focusing on the 2nd trait with 2 causal variants (194 and 589) from the 
`Ind_5traits` and `Sumstat_5traits` datasets included in the package.

```{r setup}
library(colocboost)
```


# 1. Fine-mapping with individual-level data

In this section, we demonstrate how to perform fine-mapping using individual-level genotype (`X`) and phenotype (`Y`) data. 
This approach uses raw data directly to identify causal variants.


```{r load-example-individual}
# Load example data
data(Ind_5traits)
X <- Ind_5traits$X[[2]]
Y <- Ind_5traits$Y[[2]]

res <- colocboost(X = X, Y = Y)
colocboost_plot(res)
```


# 2. Fine-mapping with summary statistics

This section demonstrates fine-mapping analysis using summary statistics along with a proper LD matrix. 

```{r load-example-sumstat}
# Load example data
data(Sumstat_5traits) 
sumstat <- Sumstat_5traits$sumstat[[2]]
LD <- get_cormat(Ind_5traits$X[[2]])

res <- colocboost(sumstat = sumstat, LD = LD)
colocboost_plot(res)
```


# 3. LD-free fine-mapping with one causal variant assumption

In scenarios where LD information is unavailable, FineBoost can still perform fine-mapping under the assumption that there is a single causal variant. 
This approach is less computationally intensive but assumes that only one variant within a region is causal.

```{r ld-free}
# Load example data
res <- colocboost(sumstat = sumstat)
colocboost_plot(res)
```


**Note**: Weak learners SEL in FineBoost may capture noise as putative signals, potentially introducing false positives to our findings. 
To identify and filter spurious signals, we use a fine-tuned threshold of $\Delta L_l$ based on extensive simulations to balance sensitivity and specificity.
This threshold is set to 0.025 by default for ColocBoost when detect the colocalization, but we suggested a less conservative threshold of 0.015 for FineBoost
when performing single-trait fine-mapping analysis (`check_null_max = 0.015` as we suggested).
