smoothPolarizedGenotypes {diemr} | R Documentation |
Smooth Polarized Genotype States
Description
This function smooths polarized genotype states using a Laplace kernel density estimation. It calculates a smoothed version of the genotype states over specified physical extent of genomic content around a site. At each genomic position, the function returns a weighted mode of the genomic state.
Usage
smoothPolarizedGenotypes(
genotypes,
includedSites,
ChosenSites = "all",
windows = NULL,
windowSize = 250000,
...
)
Arguments
genotypes |
A character matrix comprising of _012 encodings. |
includedSites |
A character path to a file with columns |
ChosenSites |
A logical vector indicating which sites are to be included in the analysis. |
windows |
A two-column numeric matrix with indices of start and end positions for
windows for all markers indicated by |
windowSize |
A numeric window size for metric conversion in base-pairs. |
... |
Additional arguments to be passed to rank2map if |
Details
Ensure that ChosenSites
match those used to import polarized genotypes.
The function uses a truncated and scaled Laplace kernel to weight the genotype states within a window around each marker position, based on physical positions of the markers.
The Laplace kernel weights are calculated for physical positions of the sites centered at the site being smoothed as:
\frac{10}{19} \exp\left(\frac{-x}{b}\right),
when x < 0
, and as:
\frac{10}{19} \exp\left(\frac{x}{b}\right),
when x \geq 0
,
where x
is the position, and b
is the scale parameter of the Laplace kernel.
The scale parameter is equal to:
b = \frac{\text{windowSize}}{2 \ln(20)}.
See Also
Examples
## Not run:
# Run this example in a working directory with write permissions
myo <- system.file("extdata", "myotis.vcf", package = "diemr")
vcf2diem(myo, "myo")
fit <- diem("myo-001.txt", ChosenInds = 1:14)
gen <- importPolarized("myo-001.txt", changePolarity = fit$markerPolarity, ChosenInds = 1:14)
h <- apply(gen, 1, \(x) pHetErrOnStateCount(sStateCount(x)))[1, ]
gen2 <- smoothPolarizedGenotypes(genotypes = gen,
includedSites = "myo-includedSites.txt", windowSize = 50)
plotPolarized(gen, h)
plotPolarized(gen2, h)
## End(Not run)