expected_observed_haplotype
Table of Contents
expected/observed haplotype
barplot
- file: bar2_HaplotypeFreq.r
- document page: 6
code:
read.table("D:/Heidi/Master/R_Daten/HaplotypeFrequency/ObsHaplotypeFreq_mt.txt”, skip=5, row.names=1, fill=TRUE )-> Observed nrow(Observed) -> rObs ncol(Observed) -> cObs newObserved <- Observed[1:(rObs-1),1:(cObs-1)] read.table("D:/Heidi/Master/R_Daten/HaplotypeFrequency/ExpHaplotypeFreq_mt.txt", skip=6, row.names=1, fill=TRUE) -> Expected nrow(Expected) -> rExp ncol(Expected) -> cExp newExpected <- Expected[,1:(cExp-3)] HaplotypeFreq <- as.matrix(newExpected) HaplotypeFreq <- cbind(HaplotypeFreq, as.matrix(newObserved)) tHaplotypeFreq <- t(HaplotypeFreq) null <- matrix(0, ncol=1, nrow=rExp) ExpSd <- cbind((Expected[,2]), as.matrix(null)) sdpos <- tHaplotypeFreq + t(ExpSd) sdneg <- tHaplotypeFreq - t(ExpSd) library(gplots) mp <- barplot2(tHaplotypeFreq ,beside=TRUE, main="Haplotype Frequency", legend = c("Expected", "Observed"), xlab="Allel", ylab="relative Frequenci", ylim=c(0,(max(tHaplotypeFreq)+(max(HaplotypeFreq)/4))), plot.ci = TRUE, ci.l =sdneg, ci.u =sdpos, plot.grid = TRUE , col=c( gray(0.8), gray(0.2))) mtext(side = 1, at = colMeans(mp), line = 0.5, text = c(1:rExp), cex=0.7) box()
lines
- file: lines_HaplotypeFreq.r
- document page: 7
code:
read.table("D:/Heidi/Master/R_Daten/HaplotypeFrequency/ObsHaplotypeFreq_mt.txt", skip=5 ,row.names=1, fill=TRUE )-> Observed nrow(Observed) -> rObs ncol(Observed) -> cObs newObserved <- Observed[1:(rObs-1),1:(cObs-1)] read.table("D:/Heidi/Master/R_Daten/HaplotypeFrequency/ExpHaplotypeFreq_mt.txt", skip=6, row.names=1, fill=TRUE) -> Expected nrow(Expected) -> rExp ncol(Expected) -> cExp newExpected <- Expected[,1:(cExp-3)] sdExp <- Expected[,2] sdExpUp <- newExpected + sdExp sdExpLo <- newExpected - sdExp plot(newObserved, type="l", xlab="Allel", ylab="relative Frequency", main="Haplotype Frequency", xaxt="n") axis(1, 1:rExp, cex.axis=0.6) lines(newExpected, col="red") lines(sdExpUp, lty=2, col="red") lines(sdExpLo, lty=2, col="red") legend("topright", c("Observed", "Expected", "Expected +/- sd"), lty=c(1,1,2), bty="n", col=c("black", "red", "red"))
save graphic as a .png file
- file: lines_HaplotypeFreq.r
- document page: 15
code:
read.table("D:/Heidi/Master/R_Daten/HaplotypeFrequency/ObsHaplotypeFreq_mt.txt", skip=5 ,row.names=1, fill=TRUE )-> Observed nrow(Observed) -> rObs ncol(Observed) -> cObs newObserved <- Observed[1:(rObs-1),1:(cObs-1)] read.table("D:/Heidi/Master/R_Daten/HaplotypeFrequency/ExpHaplotypeFreq_mt.txt", skip=6, row.names=1, fill=TRUE) -> Expected nrow(Expected) -> rExp ncol(Expected) -> cExp newExpected <- Expected[,1:(cExp-3)] sdExp <- Expected[,2] sdExpUp <- newExpected + sdExp sdExpLo <- newExpected - sdExp png("D:/Heidi/Master/R_Graphiken/lines_HaplotypeFreq.png", width=550,height=550) plot(newObserved, type="l", xlab="Allel", ylab="relative Frequency", main="Haplotype Frequency", xaxt="n") axis(1, 1:rExp, cex.axis=0.6) lines(newExpected, col="red") lines(sdExpUp, lty=2, col="red") lines(sdExpLo, lty=2, col="red") legend("topright", c("Observed", "Expected", "Expected +/- sd"), lty=c(1,1,2), bty="n", col=c("black", "red", "red")) dev.off()
expected_observed_haplotype.txt · Last modified: 2008/07/22 13:31 by 127.0.0.1