boxplotCandidateQtl: Boxplot of QTL

View source: R/quantgen.R

boxplotCandidateQtlR Documentation

Boxplot of QTL

Description

Make a boxplot of a candidate QTL.

Usage

boxplotCandidateQtl(
  y,
  X,
  snp,
  simplify.imputed = TRUE,
  xlab = "SNP genotypes",
  maf.xlab = TRUE,
  ylab = "Phenotypes",
  main.title = NULL,
  show.points = FALSE,
  jit.fact = 1,
  varwidth = TRUE,
  notch = TRUE,
  suppress.warnings = TRUE,
  regline.intercept = NA,
  regline.slope = NA,
  regline.col = "red",
  regline.lty = 1,
  regline.legend = NULL,
  alleles = NULL,
  title.line = NA,
  counts.xticks = FALSE,
  mtext.y.line = 3,
  mtext.y.cex = 1,
  verbose = 1,
  ...
)

Arguments

y

vector of phenotypes with genotype names

X

matrix of bi-allelic SNP genotypes encoded in allele doses in [0,2], with genotypes in rows and SNPs in columns; missing values should be encoded as NA

snp

character with SNP name corresponding to the candidate QTL to plot

simplify.imputed

if TRUE, imputed genotypes will be transformed back to 0,1,2

xlab

label of the x-axis

maf.xlab

if TRUE, the minor allele frequency will appear in the label of the x-axis

ylab

label of the y-axis

main.title

main title

show.points

if TRUE, individual points will be shown, with jitter, especially useful if some genotypic classes have very low counts

jit.fact

jitter factor used if show.points is TRUE

varwidth

if TRUE, the boxes are drawn with widths proportional to the square-roots of the number of observations in the groups

notch

if TRUE, a notch is drawn in each side of the boxes (see boxplot)

suppress.warnings

if TRUE, suppressWarnings is used for boxplot

regline.intercept

intercept of the regression line

regline.slope

slope of the regression line

regline.col

color of the regression line

regline.lty

style of the regression line

regline.legend

legend of the regression line

alleles

vector of characters of length 2, the second element being the allele which copies are counted in X

title.line

line at which the main title should appear

counts.xticks

if TRUE, the sample size of each genotypic class will be added to the x-axis ticks

mtext.y.line

line at which the y-axis label should appear

mtext.y.cex

cex of the y-axis label

verbose

verbosity level (0/1)

...

other arguments to boxplot

Value

invisible list with y and x used to make the boxplot (same order, with no missing data)

Author(s)

Timothee Flutre

Examples

## Not run: ## simulate genotypes
set.seed(1859)
I <- 200
P <- 2000
X <- simulGenosDose(nb.genos=I, nb.snps=P)

## make fake SNP coordinates
snp.coords <- data.frame(coord=1:ncol(X),
                         chr="chr1",
                         row.names=colnames(X),
                         stringsAsFactors=FALSE)

## simulate phenotypes (only additive effects)
modelA <- simulBvsr(Q=1, X=X, pi=0.01, pve=0.7, sigma.a2=1)

## test SNPs one by one with the univariate LMM
fit.u <- gemma(model="ulmm", y=modelA$Y[,1], X=X, snp.coords,
               W=modelA$W, out.dir=tempdir(), clean="all")

## diagnostic plots
plotHistPval(pvalues=fit.u$tests$p_wald)
cols <- rep("black",ncol(X)); cols[modelA$gamma==1] <- "red"
pvadj.AA <- qqplotPval(fit.u$tests$p_wald, col=cols, ctl.fdr.bh=TRUE,
                       plot.signif=TRUE)

## look at the best candidate QTL
snp <- rownames(fit.u$tests[order(fit.u$tests$p_wald),])[1]
boxplotCandidateQtl(y=modelA$Y[,1], X=X, snp=snp, main=snp, notch=FALSE,
                    show.points=TRUE)
fit <- lm(modelA$Y[,1] ~ X[,snp])
abline(fit, col="red")
abline(a=fit.u$global.mean["beta.hat"] - mean(X[snp]) * fit.u$tests[snp,"beta"],
       b=fit.u$tests[snp,"beta"])
legend("topright", legend=c("lm","gemma"), col=c("red","black"), lty=1, bty="n")

## End(Not run)

timflutre/rutilstimflutre documentation built on Feb. 7, 2024, 8:17 a.m.