dapc_plot | R Documentation |
Plot the results of a DAPC. Includes options to produce scatterplot,
probability plots, and correct assignment heat maps. Expects output produced
from the function genomalicious::dapc_fit
.
dapc_plot(
dapcList,
type,
plotLook = "ggplot",
axisIndex = NULL,
popBarScale = 1,
sampleShow = TRUE,
sampleOrder = "by_id",
plotColours = NULL,
legendPos = "top"
)
dapcList |
List: A list object generated from |
type |
Character: The type of plot to produce. If |
plotLook |
Character: The plot theme, only applicable when
|
axisIndex |
Integer: The LD axes to plot. If |
popBarScale |
Numeric: A scaling value for the population guide bar,
only applicable when |
sampleShow |
Logical: Should the sample names be displayed in the
probability plot? Only applicable when |
sampleOrder |
Logical: Should the samples be ordered by their IDs
('by_id') or by their estimated probability ('by_probs') in the probability
plot? Only applicable when |
plotColours |
Character: A vector of colours to use. If |
legendPos |
Character: Where should the legend be positioned? Default is
|
If you want to produce a DAPC scatterplot (type=='scatter'
) or
a probability plot (type=='probs'
), then this function receives the
output of dapc_fit(..., type='fit')
. If instead, you have performed
as assignment analysis with dapc_fit(..., type='loo_cv')
or
dapc_fit(..., type='traint_test')
, then you want to parameterise with
type=='assign'
.
In the probability plot is requested (type=='probs'
), you can choose
to order samples by their estimated probabilities for their designated
population by setting sampleOrder='by_probs'
. The default is
sampleOrder='by_id'
, in which case, samples are ordered
alpha-numerically by populations and their sample ID, i.e., the command:
data.table::setorder(.., POP, SAMPLE)
.
Returns a ggplot object.
library(genomalicious)
data("data_Genos")
# DAPC fit on all samples
DAPC.fit <- dapc_fit(data_Genos, pcPreds=3, method='fit')
# DAPC using training and testing partitions
DAPC.tt <- dapc_fit(data_Genos, pcPreds=3, method='train_test')
# Scatterplot, LD1 and LD2, with default colours, and ggplot look
dapc_plot(DAPC.fit, type='scatter', axisIndex=c(1,2))
# Scatterplot, LD2 and LD3, with manual colours, and classic look
dapc_plot(DAPC.fit, type='scatter', axisIndex=c(2,3), plotLook='classic',
plotColours=c(Pop1='#08c7e0', Pop2='#4169e1', Pop3='#e46adf', Pop4='#ce0073')
)
# Screeplot
dapc_plot(DAPC.fit, type='scree', )
# Probability plot, default colours
dapc_plot(DAPC.fit, type='probs')
# Probability plot, manual colours, population bar rescaled, sample names
turned off, and legend turned off.
dapc_plot(DAPC.fit, type='probs', popBarScale=5,
plotColours=c(Pop1='#08c7e0', Pop2='#4169e1', Pop3='#e46adf', Pop4='#ce0073'),
sampleShow=FALSE, legendPos='none'
)
# Assignment heatmap, default colours
dapc_plot(DAPC.tt, type='assign')
# Assignment heatmap, manual colours, and legend repositioned to top
dapc_plot(DAPC.tt, type='assign', plotColours=c('white', 'grey50', 'grey20'),
legendPos='top')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.