msc.pca: Prinicple Component Analysis based on MSC

Description Usage Arguments Value Examples

View source: R/msc.pca.R

Description

The msc.pca allows you to perform Principle Component Analysis to summarize MSCs variation in all samples or in a subset of samples.

Usage

1
msc.pca(clustmatrix, samples, groups, n = 20, labels = TRUE, title = NULL)

Arguments

clustmatrix

a cluster matrix

samples

a vector containing the names of the samples. This can include all samples or it can be a subset.

groups

a vector specifying to which group (e.g. species) the samples belong to.

n

number of clusters to select with highest contribution to PCA.

labels

a logical parameter indicating whether to use labels on the PCA plot or not. Default is set to true.

title

the title of the graph

Value

plot

a PCA plot.

eigenvalues

a barplot showing percentage of explained variances.

clustnames

list of cluster names with highest contribution to PCA.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
data(matrices)
data(exData)

### run function with all samples
res.pca <- lapply(matrices, function(x) msc.pca(x, samples = exData$samples, 
                  groups = exData$species, n=30, labels=FALSE, title=NULL))

res.pca$id93$eigenvalues
res.pca$id93$plot

### use clusters with highest contribution to visualize in a heatmap
msc.heatmap(matrices[["id93"]][res.pca$id93$clustnames,], samples = exData$samples,
            groups = exData$species)

### run function with a subset of samples
### you will be asked to confirm
table(exData$species)
hybrid <- which(exData$species=="hybrid")
# pca.subset <- msc.pca(clustmatrix = matrices[["id97"]], 
#                       samples = exData$samples[hybrid], 
#                       groups = exData$species[hybrid], labels = TRUE, 
#                       title = "PCA only with hybrids")

rKOMICS documentation built on July 21, 2021, 5:07 p.m.