Learn R Programming

starmie (version 0.1.2)

plotBar: Generate a barplot of a Structure or Admixture run.

Description

Generate a barplot of a Structure or Admixture run.

Usage

plotBar(x, populations = NULL, plot = TRUE, facet = TRUE)

Arguments

x
an object of type struct or admix or a Q-matrix
populations
a data.frame that contains the sample number as the first column and the population as the second.
plot
if FALSE returns a data.frame for customised plots
facet
whether or not to split the barplot by cluster. This is recommended.

Examples

Run this code
# Read file using K = 6 and plot results
k6_data <- exampleStructure("barplot")
# Generate standard 'structure' barplot
plotBar(k6_data, facet = FALSE)
# adding group information
set.seed(212)
pops <- data.frame(id = k6_data$ancest_df[,1],
population = sample(letters[1:3], nrow(k6_data$ancest_df), replace = TRUE))
# our facetted structure plot
plotBar(k6_data, pops)
# standard 'structure' bar plot
plotBar(k6_data, pops, facet = FALSE)
#' admixture example
k3_data <- exampleAdmixture()[[3]]
plotBar(k3_data)

Run the code above in your browser using DataLab