create.pgs.density.plot | R Documentation |
Plot density curves of PGS data outputted by apply.polygenic.score
.
If phenotype columns are provided, multiple density curves are plotted for automatically detected categories for each categorical variable.
create.pgs.density.plot(
pgs.data,
phenotype.columns = NULL,
output.dir = NULL,
filename.prefix = NULL,
file.extension = "png",
tidy.titles = FALSE,
width = 10,
height = 10,
xaxes.cex = 1.5,
yaxes.cex = 1.5,
titles.cex = 1.5,
key.cex = 1,
border.padding = 1
)
pgs.data |
data.frame PGS data as formatted by |
phenotype.columns |
character vector of phenotype columns in |
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 |
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 |
key.cex |
numeric size of color key legend |
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.density.plot(
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.density.plot(pgs.data, output.dir = temp.dir);
# Plot phenotype categories
pgs.data$sex <- sample(c('male', 'female', 100, replace = TRUE));
create.pgs.density.plot(
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.density.plot(
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.