get_baf: Calculate B-Allele Frequency (BAF) from Theta Values

View source: R/standardization.R

get_bafR Documentation

Calculate B-Allele Frequency (BAF) from Theta Values

Description

This function calculates the B-allele frequency (BAF) from normalized theta values, using cluster centers that represent genotype classes. BAF is computed by linearly interpolating the theta values between adjacent genotype cluster centroids.

Usage

get_baf(theta_subject, centers_theta, ploidy)

Arguments

theta_subject

A numeric vector of theta values to be standardized. These typically represent allelic ratios or normalized intensity values for a set of samples.

centers_theta

A numeric vector of length 'ploidy + 1', representing the estimated cluster centers (centroids) for each genotype class. These values should be sorted in increasing order from homozygous reference to homozygous alternative.

ploidy

An integer indicating the ploidy level of the organism (e.g., '2' for diploid).

Details

The approach is based on the methodology described by Wang et al. (2007), and is commonly used in SNP genotyping to infer allele-specific signal intensities.

Value

A numeric vector of BAF values ranging from 0 to 1

Note

The 'centers_theta' vector must contain exactly 'ploidy + 1' values, and must be sorted in ascending order. If 'theta_subject' values fall outside the range, BAFs are capped at 0 or 1 accordingly.

References

Wang, K., Li, M., Hadley, D., Liu, R., Glessner, J., Grant, S. F. A., Hakonarson, H., & Bucan, M. (2007). PennCNV: An integrated hidden Markov model designed for high-resolution copy number variation detection in whole-genome SNP genotyping data. Genome Research, 17(11), 1665–1674. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1101/gr.6861907")}

Examples

theta <- c(0.1, 0.35, 0.6, 0.95)
centers <- c(0.1, 0.5, 0.9)
get_baf(theta, centers, ploidy = 2)


Qploidy documentation built on June 8, 2025, 10 a.m.