draw_pca: draw PCA plots

View source: R/1_plots.R

draw_pcaR Documentation

draw PCA plots

Description

do PCA analysis and warning a PCA plot

Usage

draw_pca(
  exp,
  group_list,
  color = c("#2874C5", "#f87669", "#e6b707", "#868686", "#92C5DE", "#F4A582", "#66C2A5",
    "#FC8D62", "#8DA0CB", "#E78AC3", "#A6D854", "#FFD92F", "#E5C494", "#B3B3B3"),
  addEllipses = TRUE,
  style = "default",
  color.label = "Group",
  title = "",
  ...
)

Arguments

exp

A numeric matrix

group_list

A factor with duplicated character or factor

color

color vector

addEllipses

logical,add ellipses or not

style

plot style,"default","ggplot2"and "3D"

color.label

color legend label

title

plot title

...

other paramters from fviz_pca_ind

Value

a pca plot according to exp and grouped by group.

Author(s)

Xiaojie Sun

See Also

draw_heatmap;draw_volcano;draw_venn

Examples

if(requireNamespace("FactoMineR",quietly = TRUE)&
   requireNamespace("factoextra",quietly = TRUE)){
  draw_pca(t(iris[,1:4]),iris$Species)
  draw_pca(t(iris[,1:4]),iris$Species,style = "ggplot2")
  #change color
  draw_pca(t(iris[,1:4]),iris$Species,color = c("#E78AC3", "#A6D854", "#FFD92F"))
}else{
  if(!requireNamespace("FactoMineR",quietly = TRUE)){
    warning("Package 'FactoMineR' needed for this function to work.
         Please install it by install.packages('FactoMineR')")
  }
  if(!requireNamespace("factoextra",quietly = TRUE)){
    warning("Package 'factoextra' needed for this function to work.
         Please install it by install.packages('factoextra')")
  }
}

if(requireNamespace("scatterplot3d",quietly = TRUE)&
   requireNamespace("FactoMineR",quietly = TRUE)){
  draw_pca(t(iris[,1:4]),iris$Species,style = "3D")
}else{
  if(!requireNamespace("scatterplot3d",quietly = TRUE)){
    warning("Package 'scatterplot3d' needed for this function to work.
         Please install it by install.packages('scatterplot3d')")
  }
  if(!requireNamespace("FactoMineR",quietly = TRUE)){
    warning("Package 'FactoMineR' needed for this function to work.
         Please install it by install.packages('FactoMineR')")
  }
}

tinyarray documentation built on June 22, 2024, 9:58 a.m.