haplotype_distance
This is an old revision of the document!
haplotype distance
- file: matrix_HapDistanceMatrix.r
- document page: 5
code:
Data <- read.table("D:/Heidi/Master/R_Daten/HaplotypeDistance/HapDistanceMatrix_mt.txt" , skip=1)
Columns <- ncol(Data ) + 1
Row <- nrow(Data)
x <- 3
n <- 1
DistanceMatrix <- as.matrix(scan("D:/Heidi/Master/R_Daten/HaplotypeDistance/HapDistanceMatrix_mt.txt",
what=double(0), skip=x, nlines=1, nmax=n), row.names=1)
DistanceMatrix <- cbind(DistanceMatrix, matrix(NA, ncol=(Columns-n), nrow=1))
DistanceMatrix <- DistanceMatrix[,2:Columns]
n <- n + 1
x <- x + 1
while(n<(Row+1)){
nextrow <- as.matrix(scan("D:/Heidi/Master/R_Daten/HaplotypeDistance/HapDistanceMatrix_mt.txt",
what=double(0), skip=x, nlines=1, nmax=n))
nextrow <- cbind(t(nextrow), matrix(NA, ncol=(Columns-n), nrow=1))
nextrow <- nextrow[,2:Columns]
DistanceMatrix <- rbind(DistanceMatrix, nextrow)
n <- n + 1
x <- x + 1
}
a <- ncol(DistanceMatrix)
b <- nrow(DistanceMatrix)
x <- c(1:a)
y <- c(1:b)
library(fields)
ColorRamp <- rgb( seq(1,0,length=256), # Red
seq(1,0,length=256), # Green
seq(1,1,length=256)) # Blue
image.plot(x,y,DistanceMatrix, col=ColorRamp, main="Inter-haplotypic
distance matrix", xlab="Haplotype", ylab="Haplotype" )
haplotype_distance.1198235627.txt.gz · Last modified: 2008/07/22 13:30 (external edit)