Split a genotype matrix into African and European ancestry-specific dosage matrices based on a parent-of-origin ancestry matrix.

split_diploid(gt_genotype, ancestry, gla = NULL, arm_id = NULL)

Arguments

gt_genotype

Integer matrix of genotypes (0, 1, 2) - Rows represent variants - Columns represent samples

ancestry

Integer matrix of ancestry codes (1, 2, 3) - Same dimensions as gt_genotype - Values: 1=EUR/EUR, 2=AFR/EUR (mixed), 3=AFR/AFR

gla

Optional shrinkage target: numeric matrix with one row per target group and two columns (AFR, EUR) of target proportions. A mixed heterozygote's split is shrunk toward its row's AFR share by the ambiguous share \(w\) of the variant's evidence. ancestry_split uses a single row of 1/2. When NULL (default), no shrinkage: the raw p1/p2 ratio is used, with a 0.5/0.5 fallback only when every carrier is ambiguous.

arm_id

Optional integer vector (length = nrow(gt_genotype)) giving each variant's row index into gla (0-based; all zeros for a one-row target). Required together with gla.

Value

List with two elements:

african

Matrix of African ancestry-specific dosages

european

Matrix of European ancestry-specific dosages

Examples

# Genotype matrix: 5 variants x 4 samples
gt <- matrix(c(2, 1, 0, 1, 2, 1, 0, 2, 1, 0,
               1, 1, 1, 0, 2, 1, 0, 1, 0, 1), nrow = 5, ncol = 4)

# Ancestry matrix: same dimensions
ancestry <- matrix(c(3, 2, 1, 3, 2, 1, 2, 2, 1, 1,
                     3, 1, 2, 1, 3, 2, 1, 2, 1, 3), nrow = 5, ncol = 4)

result <- split_diploid(gt, ancestry)
result$african
#>      [,1] [,2] [,3] [,4]
#> [1,]    2    0  1.0 0.75
#> [2,]    0    0  0.0 0.00
#> [3,]    0    1  0.5 0.50
#> [4,]    1    0  0.0 0.00
#> [5,]    1    0  2.0 1.00
result$european
#>      [,1] [,2] [,3] [,4]
#> [1,]    0    1  0.0 0.25
#> [2,]    1    0  1.0 0.00
#> [3,]    0    1  0.5 0.50
#> [4,]    0    1  0.0 0.00
#> [5,]    1    0  0.0 0.00