Learn R Programming

conStruct (version 1.0.6)

make.structure.plot: Make STRUCTURE output plot

Description

make.structure.plot makes a STRUCTURE-style plot from the output from a conStruct analysis.

Usage

make.structure.plot(
  admix.proportions,
  mar = c(2, 4, 2, 2),
  sample.order = NULL,
  layer.order = NULL,
  sample.names = NULL,
  sort.by = NULL,
  layer.colors = NULL
)

Value

This function has only invisible return values.

Arguments

admix.proportions

A matrix of admixture proportions, with one row per sample and one column per layer.

mar

A vector of plotting margins passed to par. Default is c(2,4,2,2), which tends to look good.

sample.order

A vector giving the order in which sample admixture proportions are to be plotted, left to right. If NULL, samples are plotted in the order they occur in admix.proportions.

layer.order

A vector giving the order in which layers are plotted, bottom to top. If NULL, layers are plotted in the order they occur in admix.proportions.

sample.names

Vector of names to be plotted under each sample's admixture proportion bar plot. The index of a sample's name should be the same as the index of the sample's row in admix.proportions. If NULL, no names are printed.

sort.by

An integer giving the column index of the admix.proportions matrix to be used in determining sample plotting order. If specified, samples are plotted from left to right in increasing order of their membership in that layer. If NULL, samples are plotted in the order they occur in admix.proportions.

layer.colors

A vector of colors to be used in plotting results for different layers. Users must specify one color per layer. If NULL, the plot will use a pre-specified vector of colors.

Details

This function takes the output from a conStruct analysis and makes a STRUCTURE-style plot, where each sample is represented as a stacked bar plot, and the length of the bar plot segments of each color represent that sample's admixture proportion in that layer.

Examples

Run this code
# \dontshow{
	admix.props <- matrix(c(0.086,0.000,0.500,0.505,0.099,0.052,0.024,0.007,0.800,0.000,0.216,0.744,0.917,0.199,0.469,0.000,0.783,0.298,0.329,0.446,0.000,0.000,0.637,0.903,0.000,0.000,0.000,0.012,0.021,0.000,0.000,0.089,0.000,0.554,0.002,0.000,0.000,0.095,0.020,0.001,0.001,0.011,0.000,0.200,0.000,0.060,0.053,0.082,0.036,0.013,0.000,0.062,0.169,0.137,0.029,0.001,0.000,0.178,0.079,0.000,0.999,1.000,0.988,0.979,0.975,1.000,0.744,0.984,0.435,0.998,0.914,1.000,0.405,0.475,0.900,0.947,0.965,0.993,0.000,1.000,0.725,0.203,0.000,0.765,0.518,1.000,0.154,0.533,0.534,0.525,0.999,1.000,0.185,0.018,1.000,0.001,0.000,0.000,0.000,0.025,0.000,0.167,0.016,0.012,0.000),ncol=3)
# }	
# make STRUCTURE-style plot
	make.structure.plot(admix.proportions = admix.props)

# make STRUCTURE-style plot, sorted by membership in layer 1
make.structure.plot(admix.proportions = admix.props,sort.by=1) 

Run the code above in your browser using DataLab