create.pgs.boxplot | R Documentation |
Plot boxplots of PGS data outputted by apply.polygenic.score
.
If phenotype columns are provided, multiple boxplots are plotted for automatically detected categories for each categorical variable.
create.pgs.boxplot(
pgs.data,
pgs.columns = NULL,
phenotype.columns = NULL,
add.stripplot = TRUE,
jitter.factor = 1,
output.dir = NULL,
filename.prefix = NULL,
file.extension = "png",
tidy.titles = FALSE,
alpha = 0.5,
width = 10,
height = 10,
xaxes.cex = 1.5,
yaxes.cex = 1.5,
titles.cex = 1.5,
border.padding = 1
)
pgs.data |
data.frame PGS data as formatted by |
pgs.columns |
character vector of column names indicating which columns in |
phenotype.columns |
character vector of phenotype columns in |
add.stripplot |
logical whether to add a stripplot to the boxplot, defaults to |
jitter.factor |
numeric factor by which to scale the jitter (noise) applied to stripplot points, defaults to 1 |
output.dir |
character directory to save output plots |
filename.prefix |
character prefix for output filenames |
file.extension |
character file extension for output plots |
tidy.titles |
logical whether to reformat PGS plot titles to remove periods |
alpha |
numeric alpha value for stripplot points, defaults to 0.5 |
width |
numeric width of output plot in inches |
height |
numeric height of output plot in inches |
xaxes.cex |
numeric size for all x-axis labels |
yaxes.cex |
numeric size for all y-axis labels |
titles.cex |
numeric size for all plot titles |
border.padding |
numeric padding for plot borders |
If no output directory is provided, a multipanel lattice plot object is returned, otherwise a plot is written to the indicated path and NULL
is returned.
set.seed(100);
pgs.data <- data.frame(
PGS = rnorm(100, 0, 1)
);
temp.dir <- tempdir();
# Basic Plot
create.pgs.boxplot(
pgs.data,
output.dir = temp.dir,
filename.prefix = 'basic-plot',
width = 6,
height = 6
);
# Plot multiple PGS outputs
pgs.data$PGS.with.normalized.missing <- rnorm(100, 1, 1);
create.pgs.boxplot(pgs.data, output.dir = temp.dir);
# Plot non-default PGS columns
pgs.data$PGS.custom <- rnorm(100, 2, 1);
create.pgs.boxplot(pgs.data, pgs.columns = 'PGS.custom', output.dir = temp.dir);
# Plot phenotype categories
pgs.data$sex <- sample(c('male', 'female'), 100, replace = TRUE);
create.pgs.boxplot(
pgs.data,
output.dir = temp.dir,
filename.prefix = 'multiple-pgs',
phenotype.columns = 'sex'
);
# Plot multiple phenotypes
pgs.data$letters <- sample(letters[1:5], 100, replace = TRUE);
create.pgs.boxplot(
pgs.data,
output.dir = temp.dir,
filename.prefix = 'multiple-phenotypes',
phenotype.columns = c('sex', 'letters')
);
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.