View source: R/plot-pgs-rank.R
create.pgs.rank.plot | R Documentation |
Plot PGS percentile rank of each sample outputted by apply.polygenic.score()
as a barplot, plot missing genotypes if any are present, plot corresponding decile and quartile markers as a heatmap, optionally plot phenotype covariates as color bars.
create.pgs.rank.plot(
pgs.data,
phenotype.columns = NULL,
missing.genotype.style = "count",
categorical.palette = NULL,
binary.palette = NULL,
output.dir = NULL,
filename.prefix = NULL,
file.extension = "png",
width = 8,
height = 8,
xaxis.cex = 1.2,
yaxis.cex = 1,
titles.cex = 1.2,
border.padding = 1
)
pgs.data |
data.frame PGS data as formatted by |
phenotype.columns |
character vector of column names in pgs.data containing phenotype covariates to plot as color bars. Default is |
missing.genotype.style |
character style of missing genotype barplot. Default is "count". Options are "count" or "percent". |
categorical.palette |
character vector of colors to use for categorical phenotype covariates. Default is |
binary.palette |
character vector of colors to use for binary and continuous phenotype covariates. Each color is contrasted with white to create a color ramp or binary categories.
Default is |
output.dir |
character directory path to write plot to file. Default is |
filename.prefix |
character prefix for plot filename. |
file.extension |
character file extension for plot file. Default is "png". |
width |
numeric width of plot in inches. |
height |
numeric height of plot in inches. |
xaxis.cex |
numeric size of x-axis labels. |
yaxis.cex |
numeric size of y-axis labels. |
titles.cex |
numeric size of plot titles. |
border.padding |
numeric padding around plot border. |
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.
For clarity, certain plot aspects change when sample size exceeds 50:
x-axis labels are no longer displayed
missing (NA) values are not labeled with text in heatmaps but are color-coded with a legend
Colors for continuous and binary phenotypes are chosen from the binary color palettes in BoutrosLab.plotting.general::default.colours()
.
Colors for categorical phenotypes are chosen by default from the qualitative color palette in BoutrosLab.plotting.general::default.colours()
.
set.seed(200);
percentiles <- get.pgs.percentiles(rnorm(200, 0, 1));
pgs.data <- data.frame(
Indiv = paste0('sample', 1:200),
percentile = percentiles$percentile,
decile = percentiles$decile,
quartile = percentiles$quartile,
n.missing.genotypes = sample(1:10, 200, replace = TRUE),
percent.missing.genotypes = sample(1:10, 200, replace = TRUE) / 100,
continuous.pheno = rnorm(200, 1, 1),
categorical.pheno = sample(letters[1:5], 200, replace = TRUE),
binary.pheno = sample(c(0,1), 200, replace = TRUE)
);
temp.dir <- tempdir();
create.pgs.rank.plot(
pgs.data,
phenotype.columns = c('continuous.pheno', 'categorical.pheno', 'binary.pheno'),
missing.genotype.style = 'percent',
output.dir = temp.dir,
filename.prefix = 'example-rank-plot'
);
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.