pca_plot {hipathia} | R Documentation

## Plots two components of a PCA

### Description

Plots two components of a PCA computed with `do_pca`

### Usage

    pca_plot(fit, group = NULL, sample_colors = NULL, cp1 = 1, cp2 = 2,
      legend = TRUE, legend_xy = "bottomleft", cex = 2, pch = 20,
      mgp = c(3, 1, 0), main = "PCA plot", save_png = NULL)

### Arguments

`fit` | princomp object as returned by `do_pca`
`group` | Vector with the group to which each sample belongs. The samples must be ordered as in `rownames(fit$scores)`. By default, all samples will be assigned to the same class.
`sample_colors` | Named character vector of colors. The names of the colors must be the classes in `group`. Each sample will be assigned the color corresponding to its class, taken from the `group` vector. By default a color will be assigned automatically to each class.
`cp1` | Integer, number of the component in the X-axis. Default is 1, the first component.
`cp2` | Integer, number of the component in the Y-axis. Default is 2, the second component.
`legend` | Boolean, whether to plot a legend in the plot. Default is TRUE.
`legend_xy` | Situation of the legend in the plot. Available options are: "bottomright", "bottom", "bottomleft", "left", "topleft", "top", "topright", "right" and "center".
`cex` | Graphical parameter from `par()` function.
`pch` | Graphical parameter from `par()` function.
`mgp` | Graphical parameter from `par()` function.
`main` | Title of the graphics
`save_png` | Path to the file where the image as PNG will be saved. By default, the image is not saved.

### Value

Plots two components of a PCA

### Examples

    data(path_vals)
    sample_group <- brca_design[colnames(path_vals),"group"]
    pca_model <- do_pca(path_vals[seq_len(ncol(path_vals)),])
    pca_plot(pca_model, sample_group)

[Package hipathia version 2.10.0 Index]