plot_pca: Plot PCA

Description Usage Arguments Details Examples

View source: R/plots.R

Description

Plots either the first 2 or 3 principal components, with the data points labelled accordng to chosen meta data in the mip data set.

Usage

1
plot_pca(pca, num_components = 2, meta_var = "Country")

Arguments

pca

output of pca_mip_data

num_components

numeric for number of components used. Default = 2

meta_var

character for the desired meta variable to be used for labelling the scatterplot. Default = "Country".

Details

Using the output of pca_mip_data and a specified variable within the mip data set, e.g the country of sample collection, a scatterplot of the data is produced. Either the first 2 or 3 components can be used, as specified with 'num_components'. The chosen 'meta_var' must be a variable found within the mip data set (this is included as the last element in the object returned by pca_mip_data).

Examples

1
2
3
4
5
6
7
8
dat <- dummy_data()
dat <- filter_misc(dat = dat)
dat <- filter_coverage(dat = dat, min_coverage = 2)
dat <- melt_mip_data(dat = dat)
dat <- impute_mip_data(dat = dat)
pca <- pca_mip_data(dat = dat)
plot_pca(pca, num_components = 2, meta_var = "Country")
plot_pca(pca, num_components = 3, meta_var = "Study")

mrc-ide/mipmapper documentation built on May 20, 2019, 3:27 p.m.