User Tools

Site Tools


fst_matrix

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
fst_matrix [2007/12/21 13:56] heidifst_matrix [2008/07/22 13:31] (current) – external edit 127.0.0.1
Line 114: Line 114:
         box()         box()
 </code> </code>
 +
  
 ===== read data from a XML file ===== ===== read data from a XML file =====
Line 206: Line 207:
         axis(1, at = c(1:a),cex.axis=0.7)         axis(1, at = c(1:a),cex.axis=0.7)
         axis(2, at = c(1:b), labels=c(b:1),cex.axis=0.7)         axis(2, at = c(1:b), labels=c(b:1),cex.axis=0.7)
 +        box()
 +</code>
 +
 +===== move legend =====
 +  * file: matrix_PairwiseFst.r
 +  * document page: 22
 +
 +\\
 +**code:**
 +<code>
 +#----read data--------------------------------------------------------------
 +read.table("D:/Heidi/Master/R_Daten/FstMatrix/PairwiseFst_mic.txt",
 +            header=TRUE, skip=5 ,row.names=1, fill=TRUE )-> Data
 +as.matrix.data.frame(Data) -> Matrix
 +
 +a <- ncol(Matrix)
 +b <- nrow(Matrix)
 +
 +x <- c(1:a)
 +y <- c(1:b)
 +
 +#----draw plot--------------------------------------------------------------
 +library(fields)
 +ColorRamp <- rgb( seq(1,0,length=256),  # Red
 +                  seq(1,0,length=256),  # Green
 +                  seq(1,1,length=256))  # Blue
 + 
 +#----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))
 +}
 +
 +Matrix <- rotate270.matrix(Matrix)
 +
 +#----draw matrix plot----
 +image.plot(x,y,Matrix, col=ColorRamp, main="Distance matrix: No. of different alleles (FST)",
 +            xlab="Population", ylab="Population", legend.args=list( text="Number of different Allels (FST)",
 +            cex=1.0, side=4, line=2), axes = FALSE)
 +        contour(Matrix, add = TRUE)
 +        axis(1, at = c(1:a))
 +        axis(2, at = c(1:b), labels=c(b:1))  
         box()         box()
 </code> </code>
fst_matrix.1198241781.txt.gz · Last modified: 2008/07/22 13:30 (external edit)