Skip to contents

create_PCA_plot() returns the scatterplot or biplot, based on the PCA.

Usage

create_PCA_plot(
  dat,
  type = "sample_type",
  group_by = "sample_type",
  types_to_display = "all",
  threshold = NULL,
  interactive = TRUE
)

Arguments

dat

a raw_data object, the output of the read_data() function. The data have to be completed, for example using the complete_data() function.

type

a character denoting which type of PCA plot should be created. Default to "scatter". Type "biplot" shows eigenvectors.

group_by

character; default to "sample_type", which makes a plot for quality control. When set as "group", a PCA plot with respect to the groups of samples with type 'Sample' is created.

types_to_display

a vector of sample type names specifying which types should be shown on the plot when type = "sample_type". Defaults to all.

threshold

a value indicating the minimum correlation between a variable and any component, required for this variable to be included on the PCA biplot.

interactive

logical. If TRUE (default), a ggiraph interactive plot is returned; otherwise, a standard ggplot object is produced.

Examples

path <- get_example_data("small_biocrates_example.xls")
dat <- read_data(path)
dat <- complete_data(dat, "limit", "limit", "limit")
#> Completing 109 < LOD values...
#> Completing 6 < LLOQ values...
#> Completing 9 < ULOQ values...
create_PCA_plot(dat)
#> Joining with `by = join_by(tmp_id)`
#> Too few points to calculate an ellipse
#> Too few points to calculate an ellipse
#> Too few points to calculate an ellipse
#> Too few points to calculate an ellipse
#> Warning: Removed 4 rows containing missing values or values outside the scale range
#> (`geom_path()`).
create_PCA_plot(dat, type = "biplot", threshold = 0.3) #> Joining with `by = join_by(tmp_id)`
dat <- add_group(dat, "group") dat <- complete_data(dat, "limit", "limit", "limit") #> Completing 109 < LOD values... #> Completing 6 < LLOQ values... #> Completing 9 < ULOQ values... create_PCA_plot(dat, group_by = "group") #> Joining with `by = join_by(tmp_id)`
create_PCA_plot(dat, type = "biplot", group_by = "group", threshold = 0.3) #> Joining with `by = join_by(tmp_id)`