haplotype_distance_between_within_populations_and_groups
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
haplotype_distance_between_within_populations_and_groups [2008/01/22 11:39] – heidi | haplotype_distance_between_within_populations_and_groups [2008/07/22 13:31] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 6: | Line 6: | ||
**code:** | **code:** | ||
< | < | ||
- | #----read data----------------------------------------------------------- | + | #----read data------------------------------------------------------------------ |
#----read haplotype list---- | #----read haplotype list---- | ||
- | Data <- read.table(" | + | Data <- read.table(" |
- | ListHaplotype_betweenPop.txt", | + | |
Row <- nrow(Data) | Row <- nrow(Data) | ||
Line 19: | Line 18: | ||
n <- 1 | n <- 1 | ||
- | DistanceMatrix <- as.matrix(scan(" | + | DistanceMatrix <- as.matrix(scan(" |
- | HaplotypeDistance/ | + | |
DistanceMatrix <- cbind(DistanceMatrix, | DistanceMatrix <- cbind(DistanceMatrix, | ||
DistanceMatrix <- DistanceMatrix[, | DistanceMatrix <- DistanceMatrix[, | ||
Line 28: | Line 27: | ||
while(n< | while(n< | ||
- | nextrow <- as.matrix(scan(" | + | nextrow <- as.matrix(scan(" |
- | | + | HapDistanceMatrix_betweenPop.txt", |
- | | + | |
nextrow <- cbind(t(nextrow), | nextrow <- cbind(t(nextrow), | ||
nextrow <- nextrow[, | nextrow <- nextrow[, | ||
Line 41: | Line 39: | ||
- | #----select the data of DistanceMatrix----------------------------------- | + | #----select the data of DistanceMatrix------------------------------------------ |
dimnames(DistanceMatrix) <- list(Data[, | dimnames(DistanceMatrix) <- list(Data[, | ||
# | # | ||
- | Pop1 <- read.table(" | + | Pop1 <- read.table(" |
- | HapDistanceMatrix_withinPop1.txt", | + | |
Pop1 <- as.character(Pop1[, | Pop1 <- as.character(Pop1[, | ||
DistanceMatrixPop1 <- DistanceMatrix[Pop1, | DistanceMatrixPop1 <- DistanceMatrix[Pop1, | ||
- | |||
# | # | ||
- | Pop2 <- read.table(" | + | Pop2 <- read.table(" |
- | HapDistanceMatrix_withinPop2.txt", | + | |
Pop2 <- as.character(Pop2[, | Pop2 <- as.character(Pop2[, | ||
DistanceMatrixPop2 <- DistanceMatrix[Pop2, | DistanceMatrixPop2 <- DistanceMatrix[Pop2, | ||
- | |||
#--between population1/ | #--between population1/ | ||
Line 65: | Line 59: | ||
twholeDistanceMatrix <- t(wholeDistanceMatrix) | twholeDistanceMatrix <- t(wholeDistanceMatrix) | ||
- | wholeDistanceMatrix[x, | + | wholeDistanceMatrix[x, |
- | twholeDistanceMatrix[x, | + | |
x <- x + 1 | x <- x + 1 | ||
Line 74: | Line 67: | ||
# | # | ||
- | DistanceMatrixUp <- cbind(DistanceMatrixPop1, | + | DistanceMatrixUp <- cbind(DistanceMatrixPop1, |
- | ncol(DistanceMatrixPop1), | + | |
DistanceMatrixLo <- cbind(wholeDistanceMatrixBetween, | DistanceMatrixLo <- cbind(wholeDistanceMatrixBetween, | ||
DistanceMatrixTogether <- rbind(DistanceMatrixUp, | DistanceMatrixTogether <- rbind(DistanceMatrixUp, | ||
Line 83: | Line 75: | ||
Pop_together <- c(Pop1, Pop2) | Pop_together <- c(Pop1, Pop2) | ||
- | wholeDistanceMatrixTogether <- wholeDistanceMatrix[Pop_together, | + | wholeDistanceMatrixTogether <- wholeDistanceMatrix[Pop_together, |
- | | + | |
Line 103: | Line 94: | ||
- | #----draw matrix--------------------------------------------------------- | + | #----draw matrix---------------------------------------------------------------- |
- | windows() | + | windows() |
library(fields) | library(fields) | ||
| | ||
Line 115: | Line 106: | ||
x <- c(1:a) | x <- c(1:a) | ||
y <- c(1:b) | y <- c(1:b) | ||
- | + | ||
- | png(" | + | png(" |
- | and Groups.png", | + | |
op <- par(mfrow=c(2, | op <- par(mfrow=c(2, | ||
#----matrix one---- | #----matrix one---- | ||
op1 <- par(mfg=c(1, | op1 <- par(mfg=c(1, | ||
- | image(x, | + | image(x, |
- | font.lab=2, axes = FALSE) | + | |
| | ||
- | | + | |
- | cex.axis=0.6, | + | |
| | ||
| | ||
Line 132: | Line 120: | ||
| | ||
| | ||
- | | + | |
- | cex=0.7) | + | |
- | | + | |
- | cex=0.7) | + | |
par(op1) | par(op1) | ||
Line 144: | Line 130: | ||
| | ||
| | ||
- | | + | |
- | cex.axis=0.6, | + | |
box() | box() | ||
| | ||
- | | + | |
- | +0.5), lwd=2) | + | |
- | | + | |
- | +0.5), lwd=2) | + | |
| | ||
- | | + | |
- | cex=0.7) | + | |
- | | + | |
- | cex=0.7) | + | |
- | | + | |
- | cex=0.7) | + | |
- | | + | |
- | cex=0.7) | + | |
par(op2) | par(op2) | ||
#----matrix three---- | #----matrix three---- | ||
op3 <- par(mfg=c(2, | op3 <- par(mfg=c(2, | ||
- | image(x, | + | image(x, |
- | font.lab=2, axes = FALSE) | + | |
| | ||
| | ||
Line 174: | Line 152: | ||
| | ||
| | ||
- | | + | |
- | cex=0.7) | + | |
- | | + | |
- | cex=0.7) | + | |
par(op3) | par(op3) | ||
# | # | ||
- | maximum <- max(DistanceMatrixTogether, | + | maximum <- max(DistanceMatrixTogether, |
- | | + | |
Legend <- seq(from=0, to=maximum, length=100) | Legend <- seq(from=0, to=maximum, length=100) | ||
Line 192: | Line 167: | ||
box() | box() | ||
- | title(" | + | title(" |
- | | + | |
par(op4) | par(op4) | ||
haplotype_distance_between_within_populations_and_groups.1200998368.txt.gz · Last modified: 2008/07/22 13:30 (external edit)