ggscatter.dapc: Make ggplot with DAPC scatterplot THIS FUNCTION IS LARGELY...

ggscatter.dapcR Documentation

Make ggplot with DAPC scatterplot THIS FUNCTION IS LARGELY BASED ON THE FUNCTION 'scatter.dapc' FROM ADEGENET This function produces plots very similar to those produced by the adegenet function 'scatter.dapc', except that the object returned is a ggplot. This is useful when making lists of plots. SOME FEATURES STILL IN PROGRESS:
  • ability to add screeplot of discriminant functions or PCAs.

Description

Make ggplot with DAPC scatterplot

THIS FUNCTION IS LARGELY BASED ON THE FUNCTION 'scatter.dapc' FROM ADEGENET This function produces plots very similar to those produced by the adegenet function 'scatter.dapc', except that the object returned is a ggplot. This is useful when making lists of plots. SOME FEATURES STILL IN PROGRESS:

  • ability to add screeplot of discriminant functions or PCAs.

Usage

ggscatter.dapc(
  x,
  xax = 1,
  yax = 2,
  vartype = "df",
  varname = NULL,
  axis.title.cex = 1,
  grp = x$grp,
  cpoint = 2,
  col = adegenet::seasun(length(levels(grp))),
  txt.leg = levels(grp),
  label = TRUE,
  pch = 20,
  solid = 0.9,
  hideperimeter = FALSE,
  show.title = TRUE,
  scree.da = TRUE,
  scree.pca = FALSE,
  posi.da = "bottomright",
  posi.pca = "bottomleft",
  bg = "white",
  bg.inset = "white",
  ratio.da = 0.25,
  ratio.pca = 0.25,
  inset.da = 0.02,
  inset.pca = 0.02,
  inset.solid = 0.5,
  onedim.filled = TRUE,
  mstree = FALSE,
  lwd = 0.25,
  lty = 1,
  segcol = "black",
  legend = FALSE,
  posi.leg = "topright",
  cleg = 1,
  cstar = 1,
  cellipse = 1.5,
  axesell = FALSE,
  clabel = 1,
  xlim = NULL,
  ylim = NULL,
  grid = FALSE,
  addaxes = TRUE,
  ltyaxes = 2,
  lwdaxes = 0.5,
  origin = c(0, 0),
  include.origin = TRUE,
  sub = "",
  csub = 1,
  possub = "bottomleft",
  cgrid = 1,
  pixmap = NULL,
  contour = NULL,
  area = NULL,
  label.inds = NULL,
  new.pred = NULL
)

Arguments

x

Object of class DAPC (adegenet package).

xax

Which descriminant function to plot on the x axis.

yax

Which descriminant function to plot on the y axis. Default 2. Ignored if only one discriminant function exists.

vartype

Character string indicating which variables to plot. Either "df" for discriminant functions or "pc" for principle components. Default "df".

varname

Character string with name to use for the type of variable. Determined from the value of vartype when NULL (the default), such that 'varname'='Discriminant function' when vartype="df", and 'varname'="Principle component" when vartype="pc".

axis.title.cex

Font cex size of x and y axis titles.

grp

Object of class 'factor' with length equal to the number of individuals, which indicates individual assignments to clusters. By default posterior assignments are extracted from 'x'.

cpoint

Number with cex size to use for points.

col

Vector with color to use for each cluster.

txt.leg

NOT YET IMPLEMENTED. Labels to use for clusters in the legend.

label

Logical indicating whether or not clusters should be labeled in discriminant function biplots. Default TRUE.

pch

Either one number indicating pch code of symbol to use for all points (see 'pch' in graphical parameters), or, a numeric vector with pch codes to each for clusters . Default 20.

solid

Number between 0 and 1 indicating the level of transparency to use for colors; 0 = fully transparent; 1 = fully opaque; default = 0.7.

hideperimeter

Logical indicating whether or not to hide the x and y axes and labels (the perimeter area of the plottting area). Default FALSE.

show.title

Logical indicating whether or not to include a plot title. Default TRUE. Overriden if hideperimeter=TRUE.

scree.da

NOT YET IMPLEMENTED. Logical indicated whether or not a screeplot of the discriminant functions should be included. Default TRUE.

scree.pca

NOT YET IMPLEMENTED. Logical indicated whether or not a screeplot of the PCs should be included. Default FALSE.

posi.da

NOT YET IMPLEMENTED. The position of the screeplot of discriminant functions. Can match any combination of "top/bottom" and "left/right", or a set of x/y coordinates stored as a list (locator can be used). Default = "bottomright".

posi.pca

NOT YET IMPLEMENTED. The position of the screeplot of discriminant functions. Can match any combination of "top/bottom" and "left/right", or a set of x/y coordinates stored as a list (locator can be used). Default = "bottomleft".

bg

Color to use for the background of the plot. Default "white".

bg.inset

NOT YET IMPLEMENTED. Default "white".

ratio.da

NOT YET IMPLEMENTED. Default 0.25

ratio.pca

NOT YET IMPLEMENTED. Default 0.25

inset.da

NOT YET IMPLEMENTED. Default 0.02

inset.pca

NOT YET IMPLEMENTED. Default 0.02

inset.solid

NOT YET IMPLEMENTED. Default 0.5

onedim.filled

Logical indicating, when only one discriminant function is to be plotted, whether or not density plots should be filled or unfilled with the colors indicated by 'col'. Default TRUE.

mstree

A logical indicating whether a minimum spanning tree linking the groups and based on the squared distances between the groups inside the entire space should added to the plot (TRUE), or not (FALSE). Default FALSE.

lwd

Line weight to use for edges of the minimum spanning tree linking the groups. Default 0.25.

lty

Line type to use for edges of the minimum spanning tree linking the groups. Default 1 (solid).

segcol

Color to use for edges of the minimum spanning tree linking the groups Default "black".

legend

A logical indicating whether a legend for group colours should added to the plot. Default FALSE.

posi.leg

NOT YET IMPLEMENTED. The position of the legend holding group colors. Can match any combination of "top/bottom" and "left/right", or a set of x/y coordinates stored as a list (locator can be used). Default = "topright".

cleg

NOT YET IMPLEMENTED. Size factor for the legend. Default 1.

cstar

A number greater than 0 defining the length of the star size (i.e., the lines radiating from the center of clusters towards individuals). Default 1. Setting to zero removes the star lines; setting =1 connects points to cluster mean; setting > 1 extends lines through their points.

cellipse

A positive coefficient for the inertia ellipse size. Default 1.5. Setting to zero removes ellipses. Ignored if axesell is TRUE.

axesell

NOT YET IMPLEMENTED. A logical value indicating whether the ellipse axes should be drawn. Default FALSE.

clabel

A number indicating the size of labels. Default 1.

xlim

NOT YET IMPLEMENTED. Default NULL.

ylim

NOT YET IMPLEMENTED. Default NULL.

grid

NOT YET IMPLEMENTED. Whether or not to include a grid in the background. Default FALSE.

addaxes

Logical indicating if reference axes should be drawn at x=a and y=b, with a and b supplied by the 'origin' argument. Default TRUE.

ltyaxes

Line weight to use for edges of the minimum spanning tree linking the groups. Default 0.5.

lwdaxes

Line type to use for edges of the minimum spanning tree linking the groups. Default 2 (dashed).

origin

NOT YET IMPLEMENTED. Location of the origin.

include.origin

NOT YET IMPLEMENTED. A logical value indicating whether the point "origin" should be belonged to the graph space. Default TRUE.

sub

NOT YET IMPLEMENTED. A string of characters to be inserted as legend. Default "".

csub

NOT YET IMPLEMENTED. Number specifying text size for 'sub'.

possub

NOT YET IMPLEMENTED. The position of the subtitle ("topleft", "topright", "bottomleft", "bottomright"). Default "bottomleft".

cgrid

NOT YET IMPLEMENTED. A number used with par("cex")* cgrid to specify the mesh of the grid.

pixmap

NOT YET IMPLEMENTED. An object 'pixmap' displayed in the map background. Default NULL.

contour

NOT YET IMPLEMENTED. A data frame with 4 columns to plot the contour of the map : each row gives a segment (x1,y1,x2,y2). Default NULL.

area

NOT YET IMPLEMENTED. A data frame of class 'area' to plot a set of surface units in contour. Default NULL.

label.inds

NOT YET IMPLEMENTED. Default NULL. Named list of arguments passed to the orditorp function. This will label individual points witout overlapping. Arguments x and display are hardcoded and should not be specified by user.

new.pred

NOT YET IMPLEMENTED. An optional list, as returned by the predict method for dapc objects; if provided, the individuals with unknown groups are added at the bottom of the plot. To visualize these individuals only, specify only.grp="unknown".

only.grp

NOT YET IMPLEMENTED. Character vector indicating which groups should be displayed. Values should match values of x$grp. If NULL, all results are displayed.

Value

A ggplot object


JeffWeinell/misc.wrappers documentation built on Sept. 20, 2023, 12:42 p.m.