Learn R Programming

Bios2cor (version 1.2)

centered_pca: Principal component analysis of a correlation/covariation matrix

Description

Given a correlation matrix, performs a principal component analysis of a correlation/covariation matrix.

Usage

centered_pca(mat, m = NULL, pc= 3, dec_val= 3, eigenvalues_csv= NULL)

Arguments

mat

A matrix created by a correlation function (omes, mip, elsc, mcbasc, rotamer_circular, rotamer_omes, rotamer_mip)

m

A weighting filter calculated by a weighting function (gauss_weighting, sigmoid_weighting or delta_weighting). DEFAULT is NULL (no filter is applied and each element has the same weight equal to the inverse of the number of elements).

pc

A numeric value indicating the number of principal components to be saved.

dec_val

A numeric value corresponding to the precision when the round function is used.

eigenvalues_csv

A full path name for the csv file where eigen values are stored. Default is NULL (csv file is not created). If not NULL, a png file will also be created with the .csv extension replaced by .png

Value

returns an object of class 'pca' which is a named list of four elements:

eigen

a numeric vector of the eigenvalues

eigen.perc

a numeric vector of the relative eigenvalues (eigenvalues divided by the sum of the absolute eigenvalues)

coord

a numeric matrix representing the coordinates of each element of the correlation matrix in the PCA space

source

a named list with 2 elements, the correlation matrix (cor) and the vector of mass m which is used to give a different weight to each element.

Details

This function performs a principal component analysis of a correlation/covariation matrix after double centering. It is based on the matrix centering of the mmds.R function from the Bios2mds package.The elements may have the same weight or different weights. In this case, a weighting filter, corresponding to the relative weight of each matrix element, is passed as a parameter The weighting filter is calculated by a weighting function based on the element entropy.

Examples

Run this code
# NOT RUN {
   msf <- system.file("msa/toy_align.msf", package = "Bios2cor")
  align <- import.msf(msf)

  #Creating OMES object
  omes <- omes(align,fileHelix= NULL , diag= 0, fileCSV= NULL, gap_val= 0.8, z_score= TRUE)

  #Creating ENTROPY object
  entropy <- entropy(align)

  #Creating weighting filter
  filter <- gauss_weighting(entropy, L= 0.1)
  
  # Creating PCA structures for OMES method and storing in txt file
  omes <-omes$normalized
  pca <- centered_pca(omes, m= filter, pc= NULL, dec_val= 5,eigenvalues_csv= NULL)
  #create_pcafile(pca, "pca_results.txt",10,"pc1.txt","pc2.txt")
# }

Run the code above in your browser using DataLab