sim2dist {RFLPtools}R Documentation

Convert similarity matrix to dist object.

Description

Function to convert similarity matrix to object of S3 class "dist".

Usage

sim2dist(x, maxSim = 1)

Arguments

x

symmetric matrix: similarity matrix.

maxSim

maximum similarity possible.

Details

Similarity is converted to distance by maxSim - x. The resulting matrix is converted to an object of S3 class "dist" by as.dist

Value

Object of S3 class "dist" is returned; see dist.

Author(s)

Fabienne Flessa Fabienne.Flessa@uni-bayreuth.de,
Alexandra Kehl Alexandra.Kehl@uni-tuebingen.de,
Matthias Kohl Matthias.Kohl@stamats.de

References

Flessa, F., Kehl, A., Kohl, M. Analysing diversity and community structures using PCR-RFLP: a new software application. Molecular Ecology Resources 2013 Jul; 13(4):726-33.

See Also

BLASTdata, simMatrix

Examples

data(BLASTdata)

## without sequence range
## Not run: 
res <- simMatrix(BLASTdata)

## End(Not run)

## with sequence range
range(BLASTdata$alignment.length)
res1 <- simMatrix(BLASTdata, sequence.range = TRUE, Min = 100, Max = 450)
res2 <- simMatrix(BLASTdata, sequence.range = TRUE, Min = 500)

## visualize similarity matrix
library(MKomics)
simPlot(res2, minVal = 0, 
        labels = colnames(res2), title = "(Dis-)Similarity Plot")


## or
library(lattice)
myCol <- colorRampPalette(brewer.pal(8, "RdYlGn"))(128)
levelplot(res2, col.regions = myCol,
          at = do.breaks(c(0, max(res2)), 128),
          xlab = "", ylab = "",
          ## Rotate label of x axis
          scales = list(x = list(rot = 90)),
          main = "(Dis-)Similarity Plot")

## convert to distance
res.d <- sim2dist(res2)

## hierarchical clustering
plot(hclust(res.d))

[Package RFLPtools version 2.0 Index]