Learn R Programming

BIGr (version 0.6.2)

solve_composition_poly: Compute Genome-Wide Breed Composition

Description

Computes genome-wide breed/ancestry composition using quadratic programming on a batch of animals.

Usage

solve_composition_poly(
  Y,
  X,
  ped = NULL,
  groups = NULL,
  mia = FALSE,
  sire = FALSE,
  dam = FALSE,
  ploidy = 2
)

Value

A data.frame or list of data.frames (if groups is !NULL) with breed/ancestry composition results

Arguments

Y

numeric matrix of genotypes (columns) from all animals (rows) in population coded as dosage of allele B {0, 1, 2, ..., ploidy}

X

numeric matrix of allele frequencies (rows) from each reference panel (columns). Frequencies are relative to allele B.

ped

data.frame giving pedigree information. Must be formatted "ID", "Sire", "Dam"

groups

list of IDs categorized by breed/population. If specified, output will be a list of results categorized by breed/population.

mia

logical. Only applies if ped argument is supplied. If true, returns a data.frame containing the inferred maternally inherited allele for each locus for each animal instead of breed composition results.

sire

logical. Only applies if ped argument is supplied. If true, returns a data.frame containing sire genotypes for each locus for each animal instead of breed composition results.

dam

logical. Only applies if ped argument is supplied. If true, returns a data.frame containing dam genotypes for each locus for each animal instead of breed composition results.

ploidy

integer. The ploidy level of the species (e.g., 2 for diploid, 3 for triploid, etc.).

References

Funkhouser SA, Bates RO, Ernst CW, Newcom D, Steibel JP. Estimation of genome-wide and locus-specific breed composition in pigs. Transl Anim Sci. 2017 Feb 1;1(1):36-44.

Examples

Run this code
# Example inputs for solve_composition_poly (ploidy = 4)

# (This would typically be the output from allele_freq_poly)
allele_freqs_matrix <- matrix(
  c(0.625, 0.500,
    0.500, 0.500,
    0.500, 0.500,
    0.750, 0.500,
    0.625, 0.625),
  nrow = 5, ncol = 2, byrow = TRUE,
  dimnames = list(paste0("SNP", 1:5), c("VarA", "VarB"))
)

# Validation Genotypes (individuals x SNPs)
val_geno_matrix <- matrix(
  c(2, 1, 2, 3, 4,  # Test1 dosages for SNP1-5
    3, 4, 2, 3, 0), # Test2 dosages for SNP1-5
  nrow = 2, ncol = 5, byrow = TRUE,
  dimnames = list(paste0("Test", 1:2), paste0("SNP", 1:5))
)

# Calculate Breed Composition
composition <- solve_composition_poly(Y = val_geno_matrix,
                                      X = allele_freqs_matrix,
                                      ploidy = 4)
print(composition)

Run the code above in your browser using DataLab