% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot_snpasso.R
\name{plot_snpasso}
\alias{plot_snpasso}
\title{Plot SNP associations}
\usage{
plot_snpasso(
  scan1output,
  snpinfo,
  genes = NULL,
  lodcolumn = 1,
  show_all_snps = TRUE,
  chr = NULL,
  add = FALSE,
  drop_hilit = NA,
  col_hilit = "violetred",
  col = "darkslateblue",
  gap = NULL,
  minlod = 0,
  sdp_panel = FALSE,
  strain_labels = names(qtl2::CCcolors),
  ...
)
}
\arguments{
\item{scan1output}{Output of \code{\link[=scan1]{scan1()}} using
SNP probabilities derived by
\code{\link[=genoprob_to_snpprob]{genoprob_to_snpprob()}}.}

\item{snpinfo}{Data frame with SNP information with the following
columns (the last three are generally derived from with
\code{\link[=index_snps]{index_snps()}}):
\itemize{
\item \code{chr} - Character string or factor with chromosome
\item \code{pos} - Position (in same units as in the \code{"map"}
attribute in \code{genoprobs}.
\item \code{sdp} - Strain distribution pattern: an integer, between
1 and \eqn{2^n - 2} where \eqn{n} is the number of strains, whose
binary encoding indicates the founder genotypes
\item \code{snp} - Character string with SNP identifier (if
missing, the rownames are used).
\item \code{index} - Indices that indicate equivalent
groups of SNPs.
\item \code{intervals} - Indexes that indicate which marker
intervals the SNPs reside.
\item \code{on_map} - Indicate whether SNP coincides with a marker
in the \code{genoprobs}
}}

\item{genes}{Optional data frame containing gene information for
the region, with columns \code{start} and \code{stop} in Mbp, \code{strand}
(as \code{"-"}, \code{"+"}, or \code{NA}), and \code{Name}. If included, a
two-panel plot is produced, with SNP associations above and
gene locations below.}

\item{lodcolumn}{LOD score column to plot (a numeric index, or a
character string for a column name). Only one value allowed.}

\item{show_all_snps}{If TRUE, expand to show all SNPs.}

\item{chr}{Vector of character strings with chromosome IDs to plot.}

\item{add}{If TRUE, add to current plot (must have same map and
chromosomes).}

\item{drop_hilit}{SNPs with LOD score within this amount of the maximum SNP association will be highlighted.}

\item{col_hilit}{Color of highlighted points}

\item{col}{Color of other points}

\item{gap}{Gap between chromosomes. The default is 1\% of the total genome length.}

\item{minlod}{Minimum LOD to display. (Mostly for GWAS, in which
case using \code{minlod=1} will greatly increase the plotting speed,
since the vast majority of points would be omittted.}

\item{sdp_panel}{Include a panel with the strain distribution patterns for the highlighted SNPs}

\item{strain_labels}{Labels for the strains, if \code{sdp_panel=TRUE}.}

\item{...}{Additional graphics parameters.}
}
\value{
None.
}
\description{
Plot SNP associations, with possible expansion from distinct snps to all snps.
}
\section{Hidden graphics parameters}{

A number of graphics parameters can be passed via \code{...}. For
example, \code{bgcolor} to control the background color,\code{altbgcolor}
to control the background color on alternate chromosomes,
\code{altcol} to control the point color on alternate chromosomes,
\code{cex} for character expansion for the points (default 0.5),
\code{pch} for the plotting character for the points (default 16),
and \code{ylim} for y-axis limits.
If you are including genes and/or SDP panels, you can use
\code{panel_prop} to control the relative heights of the panels,
from top to bottom.
}

\examples{
\dontrun{
# load example DO data from web
file <- paste0("https://raw.githubusercontent.com/rqtl/",
               "qtl2data/main/DOex/DOex.zip")
DOex <- read_cross2(file)

# subset to chr 2
DOex <- DOex[,"2"]

# calculate genotype probabilities and convert to allele probabilities
pr <- calc_genoprob(DOex, error_prob=0.002)
apr <- genoprob_to_alleleprob(pr)

# query function for grabbing info about variants in region
snp_dbfile <- system.file("extdata", "cc_variants_small.sqlite", package="qtl2")
query_variants <- create_variant_query_func(snp_dbfile)

# SNP association scan
out_snps <- scan1snps(apr, DOex$pmap, DOex$pheno, query_func=query_variants,
                      chr=2, start=97, end=98, keep_all_snps=TRUE)

# plot results
plot_snpasso(out_snps$lod, out_snps$snpinfo)

# can also just type plot()
plot(out_snps$lod, out_snps$snpinfo)

# plot just subset of distinct SNPs
plot(out_snps$lod, out_snps$snpinfo, show_all_snps=FALSE)

# highlight the top snps (with LOD within 1.5 of max)
plot(out_snps$lod, out_snps$snpinfo, drop_hilit=1.5)

# query function for finding genes in region
gene_dbfile <- system.file("extdata", "mouse_genes_small.sqlite", package="qtl2")
query_genes <- create_gene_query_func(gene_dbfile)
genes <- query_genes(2, 97, 98)

# plot SNP association results with gene locations
plot(out_snps$lod, out_snps$snpinfo, drop_hilit=1.5, genes=genes)

# plot SNP asso results with genes plus SDPs of highlighted SNPs
plot(out_snps$lod, out_snps$snpinfo, drop_hilit=2, genes=genes, sdp_panel=TRUE)
}

}
\seealso{
\code{\link[=plot_scan1]{plot_scan1()}}, \code{\link[=plot_coef]{plot_coef()}}, \code{\link[=plot_coefCC]{plot_coefCC()}}
}
