linCombDist: Linear Combination of Distances

Description Usage Arguments Details Value Author(s) References Examples

View source: R/linCombDist.R

Description

This function computes linear combinations of distances.

Usage

1
linCombDist(x, distfun1, w1, distfun2, w2, diag = FALSE, upper = FALSE)

Arguments

x

object which is passed to distfun1 and distfun2.

distfun1

function used to compute an object of class "dist".

w1

weight for result of distfun1.

distfun2

function used to compute an object of class "dist".

w2

weight for result of distfun2.

diag

see dist

upper

see dist

Details

This function computes and returns the distance matrix computed by a linear combination of two distance matrices.

Value

linCombDist returns an object of class "dist"; cf. dist.

Author(s)

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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## assume a shift in the measured bands
M <- rbind(c(550, 500, 300, 250), c(510, 460, 260, 210),
           c(700, 650, 450, 400), c(550, 490, 310, 250))
dist(M)
diffDist(M)

## convex combination of dist and diffDist
linCombDist(M, distfun1 = dist, w1 = 0.5, distfun2 = diffDist, w2 = 0.5)

## linear combination
linCombDist(M, distfun1 = dist, w1 = 2, distfun2 = diffDist, w2 = 5)

## maximum distance
linCombDist(M, distfun1 = function(x) dist(x, method = "maximum"), w1 = 0.5, 
            distfun2 = function(x) diffDist(x, method = "maximum"), w2 = 0.5)
            
data(RFLPdata)
distfun <- function(x) linCombDist(x, distfun1 = dist, w1 = 0.1, distfun2 = diffDist, w2 = 0.9)
par(mfrow = c(2, 2))
plot(hclust(RFLPdist(RFLPdata, nrBands = 3, distfun = distfun)), cex = 0.7, cex.lab = 0.7)
RFLPplot(RFLPdata, nrBands = 3, distfun = distfun, mar.bottom = 6, cex.axis = 0.8)
plot(hclust(RFLPdist(RFLPdata, nrBands = 3)), cex = 0.7, cex.lab = 0.7)
RFLPplot(RFLPdata, nrBands = 3, mar.bottom = 6, cex.axis = 0.8)

Example output

Loading required package: RColorBrewer
          1         2         3
2  80.00000                    
3 300.00000 380.00000          
4  14.14214  81.24038 300.33315
        1       2       3
2  0.0000                
3  0.0000  0.0000        
4 24.4949 24.4949 24.4949
          1         2         3
2  40.00000                    
3 150.00000 190.00000          
4  19.31852  52.86764 162.41402
         1        2        3
2 160.0000                  
3 600.0000 760.0000         
4 150.7588 284.9553 723.1408
   1  2  3
2 20      
3 75 95   
4 15 35 90

RFLPtools documentation built on May 4, 2021, 1:06 a.m.