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 2 x K numeric matrix (rows "p"/"q", columns population names) of per-arm global local ancestry proportions, as produced by ancestry_split internally. When NULL (default), GLA shrinkage is disabled and behavior matches the original p1/p2 estimator exactly, including its 0.5/0.5 singleton fallback.

arm_id

Optional integer vector (length = nrow(gt_genotype)) giving each variant's row index into gla (0-based). 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