.freqpcr_loglike {freqpcr}R Documentation

Log-likelihood of obtaining Cq values under given parameter set.

Description

The internal function is called from the optimizer, nlm(), running in freqpcr(). It defines the log-likelihood by obtaining the two \DeltaCq values (differences in the four Cq measurements) provided that the allele mixing ratio for each bulk sample is given together with other parameters. This function is vectorized over multiple bulk samples.

Usage

.freqpcr_loglike(
  X,
  N,
  DCW,
  DCD,
  zeroAmount,
  para.fixed = NULL,
  beta = TRUE,
  diploid = FALSE,
  dummyDCW = FALSE
)

Arguments

X

Numeric vector that stores the parameter values to be optimized via nlm(): P in logit scale and K, targetScale, sdMeasure, and EPCR in log scale.

N

Sample sizes as a numeric vector. N[i] signifies the number of individuals (both for haploidy and diploidy) contained in the ith bulk sample.

DCW, DCD

Numeric vectors having the same length as N. They store the measured values of the two \DeltaCq: DCW (= target0 - housek0) and DCD (= target1 - housek1). They can contain NA (simply ignored in the calculation).

zeroAmount

(In RED-\Delta\DeltaCq method) residue rate of restriction enzyme digestion, or (in general \Delta\DeltaCq analyses) small portion of the off-target allele on the target locus of the test sample, which will be amplified in the PCR. It needs to be always specified by the user as a number between 0 and 1, usually near 0.

para.fixed

Named numeric vector that stores the fixed parameters inherited from freqpcr(), if specified. By default (NULL), all the parameters (P, K, targetScale, sdMeasure, and EPCR) are unknown. Unlike X, each element value is set in linear scale.

beta

Whether to use the beta distribution to approximate the sample allele ratio instead of specifying individual gamma distribution for each of the allelic DNA amounts? Default is TRUE, which accelerates the calculation.

diploid

Is the target organism diploidy? Default is FALSE, assuming haploidy. Current implementation of diploidy assumes i.i.d. between the amounts of R and S chromosomes owned by a heterozygote individual, which is unlikely in many animals but necessary for the calculation in a realistic time.

dummyDCW

Whether the \DeltaCq values of the control samples are dummy or not.

Value

Scalar of the log likelihood.


[Package freqpcr version 0.4.0 Index]