haplotype_distance
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| haplotype_distance [2007/12/21 12:13] – created heidi | haplotype_distance [2008/07/22 13:31] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 47: | Line 47: | ||
| image.plot(x, | image.plot(x, | ||
| distance matrix", | distance matrix", | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== rotated and more labels ===== | ||
| + | * file: matrix_HapDistanceMatrix.r | ||
| + | * document page: 8 | ||
| + | |||
| + | \\ | ||
| + | **code:** | ||
| + | < | ||
| + | Data <- read.table(" | ||
| + | |||
| + | Columns <- ncol(Data ) + 1 | ||
| + | Row <- nrow(Data) | ||
| + | |||
| + | x <- 3 | ||
| + | n <- 1 | ||
| + | |||
| + | DistanceMatrix <- as.matrix(scan(" | ||
| + | what=double(0), | ||
| + | DistanceMatrix <- cbind(DistanceMatrix, | ||
| + | DistanceMatrix <- DistanceMatrix[, | ||
| + | |||
| + | n <- n + 1 | ||
| + | x <- x + 1 | ||
| + | |||
| + | while(n< | ||
| + | nextrow <- as.matrix(scan(" | ||
| + | | ||
| + | nextrow <- cbind(t(nextrow), | ||
| + | nextrow <- nextrow[, | ||
| + | |||
| + | DistanceMatrix <- rbind(DistanceMatrix, | ||
| + | |||
| + | n <- n + 1 | ||
| + | x <- x + 1 | ||
| + | } | ||
| + | |||
| + | a <- ncol(DistanceMatrix) | ||
| + | b <- nrow(DistanceMatrix) | ||
| + | |||
| + | x <- c(1:a) | ||
| + | y <- c(1:b) | ||
| + | |||
| + | # Mirror matrix (left-right) | ||
| + | mirror.matrix <- function(x) { | ||
| + | xx <- as.data.frame(x); | ||
| + | xx <- rev(xx); | ||
| + | xx <- as.matrix(xx); | ||
| + | xx; | ||
| + | } | ||
| + | |||
| + | # Rotate matrix 270 clockworks | ||
| + | rotate270.matrix <- function(x) { | ||
| + | mirror.matrix(t(x)) | ||
| + | } | ||
| + | |||
| + | DistanceMatrix <- rotate270.matrix(DistanceMatrix) | ||
| + | |||
| + | |||
| + | library(fields) | ||
| + | | ||
| + | | ||
| + | | ||
| + | |||
| + | | ||
| + | xlab=" | ||
| + | contour(DistanceMatrix, | ||
| + | axis(1, at = c(1: | ||
| + | axis(2, at = c(1:b), labels=c(b: | ||
| + | box() | ||
| </ | </ | ||
haplotype_distance.1198235627.txt.gz · Last modified: 2008/07/22 13:30 (external edit)