View source: R/smoothPolarizedGenotypes.r
| smoothPolarizedGenotypes | R Documentation |
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.
smoothPolarizedGenotypes(
genotypes,
includedSites,
ChosenSites = "all",
windows = NULL,
windowSize = 250000,
...
)
genotypes |
A character matrix with _012 encoding of genotypes. Rows represent individuals, columns represent markers. |
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 |
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, meaning that the site x is upstream of the site being smoothed, and as:
\frac{10}{19} \exp\left(\frac{x}{b}\right),
when x \geq 0, meaning that the site is downstream.
The value x is the position of a neighbouring site relative to the site being
smoothed, and b is the scale parameter of the Laplace kernel.
The scale parameter is equal to:
b = \frac{\text{windowSize}}{2 \ln(20)}.
A matrix with smoothed genotypes, rows representing individuals and columns sites.
rank2map, unbiasedWeightedStateChoice
## 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 <- hybridIndex(gen)
gen2 <- smoothPolarizedGenotypes(
genotypes = gen,
includedSites = "myo-includedSites.txt", windowSize = 50
)
plotPolarized(gen, h)
plotPolarized(gen2, h)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.