summary_fit: show summary of fit of a PCA model

View source: R/summary_fit.R

summary_fitR Documentation

show summary of fit of a PCA model

Description

Create a plot which shows a summary of the fit your PCA model.

Usage

summary_fit(data)

Arguments

data

data frame with all data. See details for more information.

Details

The data frame data should contain 3 variables. PC, R2cum and Q2cum.

Value

A ggplot2 plot is returned.

Author(s)

Rico Derks

Examples

library(pcaMethods)

# create some dummy data
my_data <- data.frame(samples = c(rep("a", 10), rep("b", 10)),
                      matrix(data = rnorm(400),
                             nrow = 20))

# as cross validation q2 needs to be selected
M1 <- pca(object = my_data,
          nPcs = 5,
          cv = "q2")
          
# create data frame with R2 and Q2            
sumfit_data <- data.frame(PC = paste("PC", 1:5, sep = ""), 
                          R2cum = M1@R2cum, 
                          Q2cum = M1@cvstat)

# create the summary plot
p <- summary_fit(sumfit_data)

ricoderks/Rcpm documentation built on May 18, 2022, 7:49 a.m.