pcoa_plot | R Documentation |
Plots results of a PCoA, e.g., scatterplot, screeplot, and cumulative
explained variance plots. Takes pcoa
object as the main input.
pcoa_plot(
pcoaObj,
type = "scatter",
axisIndex = NULL,
plotColours = NULL,
plotLook = "ggplot",
legendPos = "top"
)
pcoaObj |
Prcomp object: A PCA of genotype data fitted using the
|
type |
Character: What type of plot to make: a scatterplot ( |
axisIndex |
Integer: The PC axes to plot. If |
plotColours |
Character: A vector of colours to use for plotting,
but is an optional argument. Default = |
plotLook |
Character: The look of the plot. Default = |
legendPos |
Character: Where should the legend be positioned? Default is
|
pops |
Character: A vector of population IDs, should match the
rows in |
Returns a ggplot object.
library(genomalicious)
data(data_PoolFreqs)
data(data_PoolInfo)
# Note columns in data_PoolFreqs
colnames(data_PoolFreqs)
# We need to add in the number of diploid individuals, $INDS
newFreqData <- left_join(data_PoolFreqs, data_PoolInfo)
head(newFreqData)
# Fit the PCoA
PCOA <-pcoa_freqs(newFreqData)
# Plot scatter with default settings
pcoa_plot(PCOA, type='scatter')
# Plot scatter with custom colours and a classic look
pcoa_plot(
PCOA,
type='scatter',
plotColours=c(Pop1='gray30', Pop2='royalblue', Pop3='palevioletred3', Pop4='plum2'),
plotLook='classic'
)
# Explained variance
pcoa_plot(PCOA, type='scree')
# Cumulative variance with custom colour
pcoa_plot(PCOA, type='cumvar', plotColours='royalblue')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.