Skip to contents

plot_pca() is a GGplot2 implementation for plotting two principal components from a PCA analysis, visualized as a scatter.

Usage

plot_pca(
  data = NULL,
  variables = c("PC1", "PC2"),
  labels = TRUE,
  label_size = 3,
  ...
)

Arguments

data

tidyproteomics data object

variables

a character vector of the 2 PCs to plot. Acceptable values include (PC1, PC2, PC3 ... PC9). Default c('PC1','PC2').

labels

a boolean

label_size

a numeric

...

passthrough for ggsave see plotting

Value

a (tidyproteomics data-object | ggplot-object)

Examples

library(dplyr, warn.conflicts = FALSE)
library(tidyproteomics)
hela_proteins <- hela_proteins %>%
  normalize(.method = c("scaled", "median", "linear", "limma", "loess")) %>%
  select_normalization()
#>  Normalizing quantitative data
#>  ... using scaled shift
#>  ... using scaled shift [140ms]
#> 
#>  ... using median shift
#>  ... using median shift [132ms]
#> 
#>  ... using linear regression
#>  ... using linear regression [237ms]
#> 
#>  ... using limma regression
#>  ... using limma regression [508ms]
#> 
#>  ... using loess regression
#>  ... using loess regression [1.3s]
#> 
#>  Selecting best normalization method
#>  Selecting best normalization method ... done
#> 
#>   ... selected loess
#>  Selecting best normalization method
#>  Selecting best normalization method ... done
#> 
#>   ... selected loess

hela_proteins %>% plot_pca()


# a different PC set
hela_proteins %>% plot_pca(variables = c("PC2", "PC3"))


# a PC scree plot
hela_proteins %>% plot_pca("scree")