bpp-seq3  3.0.0
bpp::GranthamAAChemicalDistance Class Reference

Grantham (1974) Amino-Acid chemical distance. More...

#include <Bpp/Seq/AlphabetIndex/GranthamAAChemicalDistance.h>

+ Inheritance diagram for bpp::GranthamAAChemicalDistance:
+ Collaboration diagram for bpp::GranthamAAChemicalDistance:

Public Member Functions

 GranthamAAChemicalDistance ()
 
 GranthamAAChemicalDistance (const GranthamAAChemicalDistance &gd)
 
GranthamAAChemicalDistanceoperator= (const GranthamAAChemicalDistance &gd)
 
GranthamAAChemicalDistanceclone () const override
 
virtual ~GranthamAAChemicalDistance ()
 
void setSymmetric (bool yn)
 
bool isSymmetric () const override
 
void setPC1Sign (bool yn)
 The sign of the distance is computed using the coordinate on the first axis of a principal component analysis with the 3 elementary properties (Volume, Polarity, Composition). Otherwise, use the default arbitrary sign. Using this option will lead isSymmetric to return false. More...
 
std::shared_ptr< const AlphabetgetAlphabet () const override
 Get the alphabet associated to this index. More...
 
const Alphabetalphabet () const override
 Get the alphabet associated to this index. More...
 
Methods from the AlphabetIndex2 interface.
double getIndex (int state1, int state2) const override
 Get the index associated to a pair of states. More...
 
double getIndex (const std::string &state1, const std::string &state2) const override
 Get the index associated to a pair of states. More...
 
const Matrix< double > & getIndexMatrix () const override
 

Static Public Attributes

static short int SIGN_ARBITRARY = 1
 
static short int SIGN_PC1 = 2
 
static short int SIGN_NONE = 0
 

Protected Member Functions

void computeIndexMatrix_ ()
 

Private Attributes

LinearMatrix< double > distanceMatrix_
 
LinearMatrix< double > signMatrix_
 
LinearMatrix< double > indexMatrix_
 
short int sign_
 
std::shared_ptr< const ProteicAlphabetalpha_
 

Detailed Description

Grantham (1974) Amino-Acid chemical distance.

Two kinds of matrix can be built:

  • a symmetric one, with $I_{i,j} = I_{i,j}$,
  • or a non-symmetric one, with $I_{i,j} = -I_{i,j}$. In the second case, which one of the two entries between $I_{i,j}$ and $I_{i,j}$ is positive is arbitrary by default. It is also possible to use the coordinate on a principal component analysis between the elementary properties of the distance instead (setPC1Sign(true)). The following R code was use in order to get those signs:
    library(seqinr)
    data(aaindex)
    data<-data.frame(composition=aaindex[["GRAR740101"]]$I,
    polarity=aaindex[["GRAR740102"]]$I,
    volume=aaindex[["GRAR740103"]]$I)
    library(ade4)
    pca<-dudi.pca(data)
    plot(pca$li[, 1:2], type="n")
    text(pca$li[, 1:2], rownames(data))
    s.corcircle(pca$co)
    layout(matrix(1:3,nrow=1))
    a1<-pca$li[,1]; names(a1)<-rownames(data); dotchart(sort(a1))
    a2<-pca$li[,2]; names(a2)<-rownames(data); dotchart(sort(a2))
    a3<-pca$li[,3]; names(a3)<-rownames(data); dotchart(sort(a3))
    x<-pca$li[,1] #Contains the coordinates on the first axis.
    m<-matrix(nrow=20, ncol=20)
    for(i in 1:length(x))
    for(j in 1:length(x))
    m[i,j]<-sign(x[j] - x[i])

Reference: Grantham, R. Amino acid difference formula to help explain protein evolution Science 185, 862-864 (1974)

Data from AAIndex2 database, Accession Number GRAR740104.

Definition at line 61 of file GranthamAAChemicalDistance.h.

Constructor & Destructor Documentation

◆ GranthamAAChemicalDistance() [1/2]

GranthamAAChemicalDistance::GranthamAAChemicalDistance ( )

Definition at line 19 of file GranthamAAChemicalDistance.cpp.

References computeIndexMatrix_().

Referenced by clone().

◆ GranthamAAChemicalDistance() [2/2]

bpp::GranthamAAChemicalDistance::GranthamAAChemicalDistance ( const GranthamAAChemicalDistance gd)
inline

Definition at line 73 of file GranthamAAChemicalDistance.h.

◆ ~GranthamAAChemicalDistance()

virtual bpp::GranthamAAChemicalDistance::~GranthamAAChemicalDistance ( )
inlinevirtual

Definition at line 94 of file GranthamAAChemicalDistance.h.

Member Function Documentation

◆ alphabet()

const Alphabet& bpp::ProteicAlphabetIndex2::alphabet ( ) const
inlineoverridevirtualinherited

Get the alphabet associated to this index.

Returns
Alphabet The alphabet associated to this index.

Implements bpp::AlphabetIndex2.

Definition at line 104 of file AlphabetIndex2.h.

References bpp::ProteicAlphabetIndex2::alpha_.

◆ clone()

GranthamAAChemicalDistance* bpp::GranthamAAChemicalDistance::clone ( ) const
inlineoverridevirtual

Implements bpp::ProteicAlphabetIndex2.

Definition at line 92 of file GranthamAAChemicalDistance.h.

References GranthamAAChemicalDistance().

◆ computeIndexMatrix_()

void GranthamAAChemicalDistance::computeIndexMatrix_ ( )
protected

◆ getAlphabet()

std::shared_ptr<const Alphabet> bpp::ProteicAlphabetIndex2::getAlphabet ( ) const
inlineoverridevirtualinherited

Get the alphabet associated to this index.

Returns
Alphabet The alphabet associated to this index.

Implements bpp::AlphabetIndex2.

Definition at line 102 of file AlphabetIndex2.h.

References bpp::ProteicAlphabetIndex2::alpha_.

Referenced by bpp::AAIndex2Entry::getIndex(), bpp::BLOSUM50::getIndex(), getIndex(), and bpp::MiyataAAChemicalDistance::getIndex().

◆ getIndex() [1/2]

double GranthamAAChemicalDistance::getIndex ( const std::string &  state1,
const std::string &  state2 
) const
overridevirtual

Get the index associated to a pair of states.

Parameters
state1First state to consider, as a string value.
state2Second state to consider, as a string value.
Returns
The index associated to the pair of states.

Implements bpp::AlphabetIndex2.

Definition at line 42 of file GranthamAAChemicalDistance.cpp.

References bpp::ProteicAlphabetIndex2::getAlphabet(), and getIndex().

◆ getIndex() [2/2]

double GranthamAAChemicalDistance::getIndex ( int  state1,
int  state2 
) const
overridevirtual

Get the index associated to a pair of states.

Parameters
state1First state to consider, as a int value in the Alphabet
state2Second state to consider, as a int value in the Alphabet
Returns
The index associated to the pair of states.

Implements bpp::AlphabetIndex2.

Definition at line 31 of file GranthamAAChemicalDistance.cpp.

References distanceMatrix_, bpp::ProteicAlphabetIndex2::getAlphabet(), sign_, SIGN_NONE, SIGN_PC1, and signMatrix_.

Referenced by getIndex().

◆ getIndexMatrix()

const Matrix<double>& bpp::GranthamAAChemicalDistance::getIndexMatrix ( ) const
inlineoverridevirtual
Returns
A matrix object with all indices.

Implements bpp::AlphabetIndex2.

Definition at line 104 of file GranthamAAChemicalDistance.h.

References indexMatrix_.

◆ isSymmetric()

bool bpp::GranthamAAChemicalDistance::isSymmetric ( ) const
inlineoverridevirtual
Returns
True if the index is symetric (that is, index(i,j) == index(j, i)).

Implements bpp::AlphabetIndex2.

Definition at line 116 of file GranthamAAChemicalDistance.h.

References sign_, and SIGN_NONE.

◆ operator=()

GranthamAAChemicalDistance& bpp::GranthamAAChemicalDistance::operator= ( const GranthamAAChemicalDistance gd)
inline

◆ setPC1Sign()

void bpp::GranthamAAChemicalDistance::setPC1Sign ( bool  yn)
inline

The sign of the distance is computed using the coordinate on the first axis of a principal component analysis with the 3 elementary properties (Volume, Polarity, Composition). Otherwise, use the default arbitrary sign. Using this option will lead isSymmetric to return false.

Parameters
ynTell is the PC1-based sign should be used instead of the arbitrary one.

Definition at line 124 of file GranthamAAChemicalDistance.h.

References computeIndexMatrix_(), sign_, SIGN_ARBITRARY, and SIGN_PC1.

◆ setSymmetric()

void bpp::GranthamAAChemicalDistance::setSymmetric ( bool  yn)
inline

Definition at line 111 of file GranthamAAChemicalDistance.h.

References computeIndexMatrix_(), sign_, SIGN_ARBITRARY, and SIGN_NONE.

Member Data Documentation

◆ alpha_

std::shared_ptr<const ProteicAlphabet> bpp::ProteicAlphabetIndex2::alpha_
privateinherited

◆ distanceMatrix_

LinearMatrix<double> bpp::GranthamAAChemicalDistance::distanceMatrix_
private

Definition at line 65 of file GranthamAAChemicalDistance.h.

Referenced by computeIndexMatrix_(), getIndex(), and operator=().

◆ indexMatrix_

LinearMatrix<double> bpp::GranthamAAChemicalDistance::indexMatrix_
private

Definition at line 67 of file GranthamAAChemicalDistance.h.

Referenced by computeIndexMatrix_(), getIndexMatrix(), and operator=().

◆ sign_

short int bpp::GranthamAAChemicalDistance::sign_
private

◆ SIGN_ARBITRARY

short int GranthamAAChemicalDistance::SIGN_ARBITRARY = 1
static

Definition at line 130 of file GranthamAAChemicalDistance.h.

Referenced by setPC1Sign(), and setSymmetric().

◆ SIGN_NONE

short int GranthamAAChemicalDistance::SIGN_NONE = 0
static

◆ SIGN_PC1

short int GranthamAAChemicalDistance::SIGN_PC1 = 2
static

Definition at line 131 of file GranthamAAChemicalDistance.h.

Referenced by computeIndexMatrix_(), getIndex(), and setPC1Sign().

◆ signMatrix_

LinearMatrix<double> bpp::GranthamAAChemicalDistance::signMatrix_
private

Definition at line 66 of file GranthamAAChemicalDistance.h.

Referenced by computeIndexMatrix_(), getIndex(), and operator=().


The documentation for this class was generated from the following files: