set.seed(1)
n <- 100 # sample size
K <- 6 # ploidy
## generate some fake genotypes when LD = 0.
ga <- stats::rbinom(n = n, size = K, prob = 0.5)
gb <- stats::rbinom(n = n, size = K, prob = 0.5)
head(ga)
head(gb)
## generate some fake genotype likelihoods when LD = 0.
gamat <- t(sapply(ga, stats::dnorm, x = 0:K, sd = 1, log = TRUE))
gbmat <- t(sapply(gb, stats::dnorm, x = 0:K, sd = 1, log = TRUE))
head(gamat)
head(gbmat)
## Haplotypic LD with genotypes
ldout1 <- ldest(ga = ga,
gb = gb,
K = K,
type = "hap")
head(ldout1)
## Haplotypic LD with genotype likelihoods
ldout2 <- ldest(ga = gamat,
gb = gbmat,
K = K,
type = "hap")
head(ldout2)
## Composite LD with genotypes
ldout3 <- ldest(ga = ga,
gb = gb,
K = K,
type = "comp")
head(ldout3)
## Composite LD with genotype likelihoods and normal model
ldout4 <- ldest(ga = gamat,
gb = gbmat,
K = K,
type = "comp",
model = "norm")
head(ldout4)
## Composite LD with genotype likelihoods and general categorical model
ldout5 <- ldest(ga = gamat,
gb = gbmat,
K = K,
type = "comp",
model = "flex",
se = FALSE)
head(ldout5)
ldout1[["D"]]
ldout2[["D"]]
ldout3[["D"]]
ldout4[["D"]]
ldout5[["D"]]
Run the code above in your browser using DataLab