plot_PCAs | R Documentation |
This function plots samples on all pairwise sets of specified PCA axes. Points can have their shape and/or color set by variables provided in a design object.
plot_PCAs(
scores_design_pca,
PCs = 1:3,
pvars.labs = "PC#",
color_by_var = NULL,
color_by_var_levels = NULL,
color_var_lab = NULL,
my_cols = c("blue", "red"),
na_col = "grey50",
pch_by_var = NULL,
pch_by_var_levels = NULL,
pch_var_lab = NULL,
my_pch = NULL,
text_by_var = NULL,
plot_text_and_pch = FALSE,
text_by_var_size = 1,
add_legend = TRUE,
file_prefix = NULL,
plotdims = c(9, 9),
point_order = "random"
)
scores_design_pca |
a matrix or data frame containing the principal component scores and (optionally) any other sample annotation to be used in plotting. Typically generated by running |
PCs |
a numeric vector of principal component axes to include in plotting. Defaults to 1:3, which will cause the function to plot PC1 vs. PC2, PC1 vs. PC3, and PC2 vs. PC3. |
pvars.labs |
(optional) character vector containing axis labels. Can be generated by running PCA with |
color_by_var |
(optional) character string or integer identifying the column in |
color_by_var_levels |
(optional) character vector defining the order of elements in the variable used for coloring points; this order is used for the plot legend and to match the order of colors (if provided). If not provided, levels of the variable are ordered by order of appearance in |
color_var_lab |
(optional) string to be used as the title for the color legend. |
my_cols |
(optional) vector of colors to use for plotting. If |
na_col |
color to use for NA values of |
pch_by_var |
(optional) character string or integer identifying the column in |
pch_by_var_levels |
(optional) character vector defining the order of elements in the variable used for point shapes; this order is used for the plot legend and to match the order of shapes (if provided). If not provided, levels of the variable are ordered by order of appearance in |
pch_var_lab |
(optional) string to be used as the title for the point shape legend. |
my_pch |
vector of shapes to use for plotting. Required if plotting points by shape; if not provided, all points will be plotted as dots. Must contain at least as many elements as the number of unique elements in |
text_by_var |
(optional) character string or integer identifying the column in |
plot_text_and_pch |
boolean, whether to plot both text labels and points. If |
text_by_var_size |
numeric, the scaling factor for the text labels; passed as |
add_legend |
boolean, whether to include legend(s) on the plot for points plotted by variables. |
file_prefix |
a character string. If provided, the function outputs a pdf of the plot, named "file_prefixother_stuff.pdf", where other_stuff includes the PCs being plotted and variables for shape or color plotting. If |
plotdims |
a numeric vector, the size (in inches) of the plotting object. Applies only if |
point_order |
character string, specifying how to order the points. Currently accepted values are "random", which randomizes the order of the points, and "input", which sends the points to ggplot as they are in the input data frame. Defaults to "random". |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.