Learn R Programming

GSNA (version 0.1.4.2)

distMat2UnitNormRank: distMat2UnitNormRank negDistMat2UnitNormRank

Description

Convert a symmetrical numerical matrix of distances to a matrix of scaled ranks (from 0 to 1). Note: Only the lower side of the matrix is used. Data on the upper right are assumed to be redundant. These functions are intended to convert a matrix of distance or similarity values into a proper form for applying hierarchical clustering with the gsnPareNetGenericHierarchic() function.

Usage

distMat2UnitNormRank(mat, lower_is_closer = TRUE)

negDistMat2UnitNormRank(mat)

Value

A symmetric matrix of ranks. The matrix has the attribute 'lower_is_closer' set to 'TRUE'.

Arguments

mat

A numerical matrix containing distances.

lower_is_closer

Logical indicating that lower is closer.

Functions

  • negDistMat2UnitNormRank(): Takes the same parameter distMat2UnitNormRank, but multiplies the distance by -1 first.

Details

The difference between distMat2UnitNormRank() and negDistMat2UnitNormRank() is that negDistMat2UnitNormRank() takes only the mat argument, and negates it prior to calling distMat2UnitNormRank().

See Also

distMat2Rank()

Examples

Run this code

# For log Fisher values, lower is closer and more significant.
mat.dist <- matrix( c( NA, -400, -600, NA, NA, -120, NA, NA, NA ), nrow = 3, ncol = 3 )
mat.scaledranks <- distMat2UnitNormRank(mat.dist)

# With metrics for which higher is closer/more similar, use
# negDistMat2UnitNormRank():
mat.jaccard <- matrix( c( NA, 0.2, 0.3, NA, NA, 0.1, NA, NA, NA ), nrow = 3, ncol = 3 )
mat.srjaccard <- negDistMat2UnitNormRank(mat.jaccard)

# This also works:
mat.srjaccard <- distMat2UnitNormRank(mat.jaccard, lower_is_closer=FALSE)

Run the code above in your browser using DataLab