# sim2dis: Converts a Similarity Matrix into a Dissimilarity Matrix In optiSel: Optimum Contribution Selection and Population Genetics

 sim2dis R Documentation

## Converts a Similarity Matrix into a Dissimilarity Matrix

### Description

Converts a similarity matrix (e.g. a kinship matrix) into a dissimilarity matrix.

### Usage

``````sim2dis(f, a=4.0, baseF=0.03, method=1)
``````

### Arguments

 `f` Similarity matrix. `a` Exponent `baseF` Old inbreeding not measured by `f` `method` Either `1` or `2`

### Details

This function converts a similarity matrix `f` with values between 0 and 1 (e.g. a kinship matrix) into a dissimilarity matrix. At first, the similarity is adjusted as

`f <- baseF + (1-baseF)*f`.

Then, for Method 1, the dissimilarity between individuals `i` and `j` is computed as

`Dij = (-log(fij))^a`,

whereas for Method 2, the dissimilarity is computed as

`Dij = sqrt((fii+fjj)/2-fij)^a`.

Although Method 2 may provide lower stress values in some cases, Method 1 has the advantage that the area reflects the diversity of a population more reasonable.

### Value

Dissimilarity matrix D.

Robin Wellmann

### Examples

``````data(map)
dir   <- system.file("extdata", package = "optiSel")
files <- file.path(dir, paste("Chr", unique(map\$Chr), ".phased", sep=""))
f     <- segIBD(files, map, minSNP=15, minL=1.0)
D     <- sim2dis(f, 4)

## Multidimensional scaling of animals:
## Not run:
data(Cattle)
library("smacof")
color <- c(Angler="red", Rotbunt="green", Fleckvieh="blue", Holstein="black")
col   <- color[as.character(Cattle\$Breed)]
Res   <- smacofSym(D, itmax = 5000, eps = 1e-08)
plot(Res\$conf, pch=18, col=col, main="Multidimensional Scaling", cex=0.5)
mtext(paste("segIBD Stress1 = ", round(Res\$stress,3)))

## End(Not run)

``````

optiSel documentation built on May 31, 2023, 6:50 p.m.