multi_lrt: Parallelized likelihood ratio test for segregation...

View source: R/multi.R

multi_lrtR Documentation

Parallelized likelihood ratio test for segregation distortion.

Description

Uses the future package to implement parallelization support for the likelihood ratio tests for segregation distortion. This function only works for tetraploids, and cannot account for outliers. For higher ploidies and more functionality, see seg_multi().

Usage

multi_lrt(
  g,
  p1,
  p2,
  drbound = 1/6,
  pp = TRUE,
  dr = TRUE,
  alpha = 0,
  xi1 = 1/3,
  xi2 = 1/3,
  nullprop = FALSE
)

Arguments

g

One of two inputs

  • A matrix of genotype counts. The rows index the loci and the columns index the genotypes.

  • An array of genotype log-likelihoods. The rows index the loci, the columns index the individuals, and the slices index the genotypes. Log-likelihoods are base e (natural log).

p1

One of three inputs

  • A vector of parent 1's genotypes.

  • A matrix of parent 1's genotype log-likelihoods. The rows index the loci and the columns index the genotypes. Logs are in base e (natural log).

  • NULL (only supported when using genotype likelihoods for the offspring)

p2

One of three inputs

  • A vector of parent 1's genotypes.

  • A matrix of parent 1's genotype log-likelihoods. The rows index the loci and the columns index the genotypes. Logs are in base e (natural log).

  • NULL (only supported when using genotype likelihoods for the offspring)

drbound

The upper bound on the double reduction rate.

pp

Is (partial) preferential pairing possible (TRUE) or not (FALSE)?

dr

Is double reduction possible (TRUE) or not (FALSE)?

alpha

If dr = FALSE, this is the known rate of double reduction.

xi1

If pp = FALSE, this is the known preferential pairing parameter of parent 1.

xi2

If pp = FALSE, this is the known preferential pairing parameter of parent 2.

nullprop

Should we return the null proportions (TRUE) or not (FALSE)?

Value

A data frame with the following elements:

statistic

The likelihood ratio test statistic

p_value

The p-value of the likelihood ratio test.

df

The degrees of freedom of the test.

alpha

The MLE of the double reduction rate. Do not use for real work.

xi1

The MLE of the first parent's partial preferential pairing parameter. Do not use for real work.

xi2

The MLE of the second parent's partial preferential pairing parameter. Do not use for real work.

p1

(Estimate of) the first parent's genotype.

p2

(Estimate of) the second parent's genotype.

snp

The name of the SNP.

Parallel Computation

The multi_lrt() function supports parallel computing. It does so through the future package.

You first specify the evaluation plan with plan() from the future package. On a local machine, this is typically just future::plan(future::multisession, workers = nc) where nc is the number of workers you want. You can find the maximum number of possible workers with availableCores(). You then run multi_lrt(), then shut down the workers with future::plan(future::sequential).

Author(s)

David Gerard

See Also

  • lrt_men_g4() Single locus LRT for segregation distortion when genotypes are known.

  • lrt_men_gl4() Single locus LRT for segregation distortion when using genotype likelihoods.

Examples


## Assuming genotypes are known (typically a bad idea)
glist <- multidog_to_g(
  mout = ufit,
  ploidy = 4,
  type = "all_g",
  p1 = "indigocrisp",
  p2 = "sweetcrisp")
p1_1 <- glist$p1
p2_1 <- glist$p2
g_1 <- glist$g
multi_lrt(g = g_1, p1 = p1_1, p2 = p2_1)

## Using genotype likelihoods (typically a good idea)
glist <- multidog_to_g(
  mout = ufit,
  ploidy = 4,
  type = "all_gl",
  p1 = "indigocrisp",
  p2 = "sweetcrisp")
p1_2 <- glist$p1
p2_2 <- glist$p2
g_2 <- glist$g
multi_lrt(g = g_2, p1 = p1_2, p2 = p2_2)

## Offspring genotype likelihoods and parent genotypes known
multi_lrt(g = g_2, p1 = p1_1, p2 = p2_1)

## Offspring genotype likelihoods and no information on parent genotypes
multi_lrt(g = g_2, p1 = NULL, p2 = NULL)

## Parallel computing is supported through the future package
# future::plan(future::multisession, workers = 2)
# multi_lrt(g = g_2, p1 = p1_2, p2 = p2_2)
# future::plan(future::sequential)



segtest documentation built on July 1, 2025, 1:07 a.m.