knownqpcr_unpaired: Estimate auxiliary parameters when the sample pairs are...

View source: R/03_known_ratio.R

knownqpcr_unpairedR Documentation

Estimate auxiliary parameters when the sample pairs are incomplete.

Description

A variant of knownqpcr() that accepts the Cq values concatenated into a vector (the argument Cq) accompanied with the experimental conditions (the arguments Digest and Gene). Their exact allele mixing ratios are known as trueY.

Usage

knownqpcr_unpaired(
  Digest,
  Gene,
  trueY,
  Cq,
  A = rep(1, length(Cq)),
  XInit = c(meanDNA = -10, targetScale = 0, baseChange = 0, sdMeasure = 1, zeroAmount =
    -5, EPCR = 0),
  method = "BFGS",
  pvalue = 0.05,
  trace = 0,
  report = 10,
  verbose = FALSE
)

Arguments

Digest

Numeric vector having the same length as Gene, trueY, and Cq. NA is not allowed. In the RED-ΔΔCq method, it specify the sample is intact (= 0) or digested with endonuclease (= 1). In other ΔΔCq-based analyses, there will be no control sample and all observations must be marked Digest = 1.

Gene

Numeric vector that specify each Cq measure (element of Cq) was taken with housekeeping (= 0) or target (= 1) locus. NA is not allowed.

trueY

A numeric vector. trueY[i] signifies the exact frequency of the mutant allele in the ith sample. The values must be between 0 and 1, and NA is not allowed. To improve the estimation accuracy, it is better to include the settings y == 0 (pure S solution) and y == 1 (pure R) in your dataset.

Cq

Measured Cq values. This argument is a numeric vector and can contain NAs. The vector length must be the same as Digest, Gene, and trueY (i.e., missing values must be filled with NA).

A

Optionally, you can specify relative DNA content between the samples, as a numeric vector having the same length as Cq. If present, A must not include missing values. It is the counterpart of the N argument in freqpcr(), whereas an element of A is not restricted to integer. Because the concentration as a whole is also adjusted with the parameter meanDNA (see Value section), A is used exclusively to reflect the relative contents between the sample solutions. Otherwise, A should be left unspecified (the default is 1 for all replicates).

XInit

Optionally, the named vector specifies the initial parameter values to be optimized. Defined in the natural log scale; e.g. zeroAmount = -5 corresponds to the residue rate exp(-5) = 0.007. Keeping the default is highly recommended.

method

A string specifying the optimization algorithm used in optim(). The default is BFGS, which is plausible in most situation.

pvalue

The two-sided confidence interval is calculated at the last iteration at given significance level. Default is 0.05, which returns the 95% Wald's CI (2.5 to 97.5 percentile) based on the Hessian matrix.

trace

Non-negative integer. If positive, optim() outputs trace information. The default is 0 (no information).

report

The frequency of reports if trace is positive. Defaults to every 10 iterations.

verbose

Send messages to stdout? Default is FALSE.

Value

A table containing the estimated parameter values. The format is same as knownqpcr().

See Also

Other estimation procedures: freqpcr(), knownqpcr(), sim_dummy()

Examples

# A dummy Cq dataset: four mixing ratios with four replicates.
# K:2, scaleDNA:1e-11, targetScale:1.5, baseChange:0.3, zeroAmount:1e-3,
# sdMeasure:0.3, and EPCR:0.95. Assuming a RED-DeltaDeltaCq analyses.
trueY <- c(rep(0.1, 4), rep(0.25, 4), rep(0.5, 4), rep(1, 4))
housek0 <- c( 19.39, 19.78, 19.28, 19.58,  18.95, 19.91, 19.66, 19.96,
              20.05, 19.86, 19.55, 19.61,  19.86, 19.27, 19.59, 20.21 )
target0 <- c( 19.16, 19.08, 19.28, 19.03,  19.17, 19.67, 18.68, 19.52,
              18.92, 18.79, 18.8, 19.28,   19.57, 19.21, 19.05, 19.15 )
housek1 <- c( 21.61, 21.78, 21.25, 21.07,  22.04, 21.45, 20.72, 21.6,
              21.51, 21.27, 21.08, 21.7,   21.44, 21.46, 21.5, 21.8 )
target1 <- c( 24.3, 24.22, 24.13, 24.13,   22.74, 23.14, 23.02, 23.14,
              21.65, 22.62, 22.28, 21.65,  20.83, 20.82, 20.76, 21.3 )

# Incomplete observation dataset, prepared as the "long" format.
# If the undegested (Digest == 0) samples were only analyzed when trueY == 1.
d.long.all <- data.frame(
    trueY=rep(trueY, 4), Digest=c(rep(0, 16 + 16), rep(1, 16 + 16)),
    Gene=c(rep(0, 16), rep(1, 16), rep(0, 16), rep(1, 16)),
    A=rep(1, 16*4), Cq=c(housek0, target0, housek1, target1)  )
d.long <- d.long.all[d.long.all$Digest == 1 | d.long.all$trueY == 1, ]
print(d.long)

knownqpcr_unpaired( Digest=d.long$Digest, Gene=d.long$Gene,
                    trueY=d.long$trueY, Cq=d.long$Cq, A=d.long$A )

# In general DeltaDeltaCq analyses, the experimental design will not include
# dedicated control samples (Digest == 0).
d.long <- d.long.all[d.long.all$Digest == 1, ]
knownqpcr_unpaired( Digest=d.long$Digest, Gene=d.long$Gene,
                    trueY=d.long$trueY, Cq=d.long$Cq, A=d.long$A )

freqpcr documentation built on March 18, 2022, 7:25 p.m.