Learn R Programming

lineup (version 0.34-1)

combinedist: Combine distance matrices into a single such

Description

Combine multiple distance matrices into a single distance matrix providing an overall summary

Usage

combinedist(..., method=c("median", "mean"))

Arguments

...
Set of distance matrices, as calculated by distee or disteg.
method
Indicates whether to summarize using the median or the mean.

Value

  • A distance matrix, with class "lineupdist". The individual IDs are in the row and column names.

Details

The row and column names of the input distance matrices define the individual IDs.

If the input distance matrices all have an attribute "denom" (for denominator) and method="mean", we use a weighted mean, weighted by the denominators. This could be used to calculate an overall proportion.

See Also

distee, disteg, summary.lineupdist

Examples

Run this code
# simulate MVN, 100 individuals, 40 measurements (of which 20 are just noise)
V <- matrix(0.3, ncol=20, nrow=20) + diag(rep(0.5, 20)) 
D <- chol(V)
z <- matrix(rnorm(20*100), ncol=20)
# create three data matrices as z + noise
x <- cbind(z + rnorm(20*100, 0, 0.2), matrix(rnorm(20*100), ncol=20))
y <- cbind(z + rnorm(20*100, 0, 0.2), matrix(rnorm(20*100), ncol=20))
w <- cbind(z + rnorm(20*100, 0, 0.2), matrix(rnorm(20*100), ncol=20))

# permute some rows of x
x[51:53,] <- x[c(52,53,51),]

# add column and row names
dimnames(x) <- dimnames(y) <- dimnames(w) <- 
   list(paste("ind", 1:100, sep=""), paste("gene", 1:40, sep=""))

# calculate correlations between cols of x and of the other two matrices
corxy <- corbetw2mat(x, y)
corxw <- corbetw2mat(x, w)

# using columns with corr > 0.75, 
# calculate distance (using "correlation" as a measure...really similarity)
dxy <- distee(x[,corxy>0.75], y[,corxy>0.75], d.method="cor", labels=c("x", "y"))
dxw <- distee(x[,corxw>0.75], w[,corxw>0.75], d.method="cor", labels=c("x", "w"))

d <- combinedist(dxy, dxw)

summary(d)

Run the code above in your browser using DataLab