Description Usage Arguments Details Value Author(s) References See Also Examples
Uses the forward-backward algorithm to estimate ancestry along a given chromosome for a given genotyped diploid.
1 | fb_diploid(snp_locations, p0, p1, p_assign, scale)
|
snp_locations |
a numeric vector specifying the locations of each snp (in bps). This vector is assumed to be ordered (sorted from smallest to largest snp). |
p0 |
a vector specifying the number of reads that mapped to parent 0. p0 is assumed to be in the smae order as snp_locations. |
p1 |
a vector specifying the number of reads that mapped to parent 1. p1 is assumed to be in the smae order as snp_locations. |
p_assign |
a value specifying the assignment probabilty (see details). |
scale |
a numeric specifying the the genome-wide recombination rate (Morgans / bp). |
This is an extension of fb_haploid
with three hidden states:
two homozygous states and a heterozygous state.
a dataframe with the following columns:
snp_locations
p0
p1
The emission matrix (3 columns) specifying the emmision probability of belong to the only parent 0 (emiss.1), both parents (emiss.1), and only parent 2 (emiss.3)
the forward probability matrix (3 columns) giving the scaled forward probabilities of belong to the only parent 0 (forward.1), both parents (forward.2), and only parent 2 (forward.3)
the backward probability matrix (3 columns) giving the scaled backward probabilities of belong to the only parent 0 (backward.1), both parents (backward.2), and only parent 2 (backward.3)
Fscale
The forward scaling factor for each snp
Bscale
The backward scaling factor for each snp
posterior probability matrix (3 columns) posterior probabilities for belong to each parental state
states_inferred a vector of length snp_locations giving the state with the highest posterior.
lnL a numeric giving the total likelihood of the data (see fb_haploid
).
Tyler D. Hether
Hether, T.D., C. G. Wiench1, and P.A. Hohenlohe (in review). 2015. Novel molecular and analytical tools for efficient estimation of rates of meiotic crossover, non-crossover and gene conversion
Drubin, R. S. Eddy, A. Krogh, and G. Mitchison. 1998. Biological Sequence Analysis: Probabilistic Models of proteins and nucleic acids. Cambridge University Press, Cambridge CB2 8RU, UK.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | set.seed(1234567) # For reproducibility
n_spores <- 1 # number of spores
l <- 75 # number of snps to simulate
c <- 3.5e-05 # recombination rate between snps (Morgan/bp)
snps <- c(1:l)*1.3e4 # snps are evenly spaced 20kbp apart
p_a <- 0.95 # assignment probability
coverage <- 2.1 # mean coverage
# Now simulate two haploids
sim1 <- sim_en_masse(n.spores=n_spores, scale=c, snps=snps,
p.assign=p_a, mu.rate=0, f.cross=0.8, f.convert=0.3,
length.conversion=2e3, coverage=coverage)
sim2 <- sim_en_masse(n.spores=n_spores, scale=c, snps=snps,
p.assign=p_a, mu.rate=0, f.cross=0.8, f.convert=0.3,
length.conversion=2e3, coverage=coverage)
# Now merge the two haploids to make a diploid
p0 <- sim1$p0+sim2$p0
p1 <- sim1$p1+sim2$p1
res <- fb_diploid(snp_locations=sim1$Snp, p0=p0, p1=p1, p_assign=p_a, scale=c)
res
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.