View source: R/plot_genoprob.R
plot_genoprob | R Documentation |
Plot the genotype probabilities for one individual on one chromosome, as a heat map.
plot_genoprob(
probs,
map,
ind = 1,
chr = NULL,
geno = NULL,
color_scheme = c("gray", "viridis"),
col = NULL,
threshold = 0,
swap_axes = FALSE,
...
)
## S3 method for class 'calc_genoprob'
plot(x, ...)
probs |
Genotype probabilities (as produced by |
map |
Marker map (a list of vectors of marker positions). |
ind |
Individual to plot, either a numeric index or an ID. |
chr |
Selected chromosome to plot; a single character string. |
geno |
Optional vector of genotypes or alleles to be shown (vector of integers or character strings) |
color_scheme |
Color scheme for the heatmap (ignored if |
col |
Optional vector of colors for the heatmap. |
threshold |
Threshold for genotype probabilities; only genotypes that achieve this value somewhere on the chromosome will be shown. |
swap_axes |
If TRUE, swap the axes, so that the genotypes are on the x-axis and the chromosome position is on the y-axis. |
... |
Additional graphics parameters passed to |
x |
Genotype probabilities (as produced by
|
None.
A number of graphics parameters can be passed via ...
. For
example, hlines
, hlines_col
, hlines_lwd
, and hlines_lty
to
control the horizontal grid lines. (Use hlines=NA
to avoid
plotting horizontal grid lines.) Similarly vlines
, vlines_col
,
vlines_lwd
, and vlines_lty
for vertical grid lines. You can
also use many standard graphics parameters like xlab
and xlim
.
These are not included as formal parameters in order to avoid
cluttering the function definition.
plot_genoprobcomp()
# load data and calculate genotype probabilities
iron <- read_cross2(system.file("extdata", "iron.zip", package="qtl2"))
iron <- iron[,"2"] # subset to chr 2
map <- insert_pseudomarkers(iron$gmap, step=1)
pr <- calc_genoprob(iron, map, error_prob=0.002)
# plot the probabilities for the individual labeled "262"
# (white = 0, black = 1)
plot_genoprob(pr, map, ind="262")
# change the x-axis label
plot_genoprob(pr, map, ind="262", xlab="Position (cM)")
# swap the axes so that the chromosome runs vertically
plot_genoprob(pr, map, ind="262", swap_axes=TRUE, ylab="Position (cM)")
# This is more interesting for a Diversity Outbred mouse example
## Not run:
file <- paste0("https://raw.githubusercontent.com/rqtl/",
"qtl2data/main/DOex/DOex.zip")
DOex <- read_cross2(file)
# subset to chr 2 and X and individuals labeled "232" and "256"
DOex <- DOex[c("232", "256"), c("2", "X")]
pr <- calc_genoprob(DOex, error_prob=0.002)
# plot individual "256" on chr 2 (default is to pick first chr in the probs)
plot_genoprob(pr, DOex$pmap, ind="256")
# omit states that never have probability >= 0.5
plot_genoprob(pr, DOex$pmap, ind="256", threshold=0.05)
# X chr male 232: just show the AY-HY genotype probabilities
plot_genoprob(pr, DOex$pmap, ind="232", chr="X", geno=paste0(LETTERS[1:8], "Y"))
# could also indicate genotypes by number
plot_genoprob(pr, DOex$pmap, ind="232", chr="X", geno=37:44)
# and can use negative indexes
plot_genoprob(pr, DOex$pmap, ind="232", chr="X", geno=-(1:36))
# X chr female 256: just show the first 36 genotype probabilities
plot_genoprob(pr, DOex$pmap, ind="256", chr="X", geno=1:36)
# again, can give threshold to omit genotypes whose probabilities never reach that threshold
plot_genoprob(pr, DOex$pmap, ind="256", chr="X", geno=1:36, threshold=0.5)
# can also look at the allele dosages
apr <- genoprob_to_alleleprob(pr)
plot_genoprob(apr, DOex$pmap, ind="232")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.