Skip to contents

Calculates the beta-binomial concentration parameter (K) for each segment based on local sequencing depth and a fitted dispersion model.

Usage

EstimateK(result, theta_fit, maf)

Arguments

result

Data frame. Segment-level results, must include columns Chromosome, Start, and End.

theta_fit

List or data frame. Fitted dispersion model, must include breaks (numeric vector of depth bin edges) and theta_table (data frame with columns depth_bin and theta).

maf

Data frame. Allelic count data for all SNPs, must include columns chr, Pos, ref_count, and alt_count.

Value

The input result data frame with additional columns:

depth

Median SNP depth for the segment.

depth_bin

Depth bin index for the segment.

theta

Estimated dispersion parameter for the segment.

K

Estimated beta-binomial concentration parameter for the segment.

Details

For each segment, the function extracts all SNPs within the segment boundaries from the maf data, calculates the median depth, assigns a depth bin according to theta_fit$breaks, joins the corresponding theta value from theta_fit$theta_table, and computes K using the formula \(K = \frac{\text{depth}}{1 + \text{depth} \cdot \theta} - 1\).