Last active
August 29, 2015 14:02
-
-
Save kmader/3bd0dcaf2a0bf2849177 to your computer and use it in GitHub Desktop.
A plot of a simple relationship between control variables and measurable outputs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(ggplot2) | |
| library(reshape2) | |
| parm.table<-expand.grid(Temperature=seq(20,80,length.out=20),Gene=c(1,2,3),pH=seq(3,6,length.out=10)) | |
| rf<-function(amplitude=0.1) runif(nrow(parm.table),min=1/(1+amplitude),max=1+amplitude) | |
| parm.table$Thickness<-with(parm.table,10^(pH+as.numeric(Gene))-10*Temperature)*rf(.1) | |
| parm.table$Count<-with(parm.table,10^(as.numeric(Gene))+100*Temperature)*rf(0.01) | |
| parm.table$Connections<-with(parm.table,2^(as.numeric(Gene))-5*as.numeric(Gene)+12)*rf(0.2) | |
| parm.table$GrowthRate<-with(parm.table,log(Thickness/Count)*Gene)*rf(0.2) | |
| parm.table$Strength<-with(parm.table,Count/Connections)*rf(0.1) | |
| parm.table$Viability<-with(parm.table,10^(10-Connections))*rf(0.2) | |
| parm.melt<-melt(parm.table,measure.vars = c("Temperature","Gene","pH"),variable.name="Controlled",value.name="CValue") | |
| strt.melt<-melt(parm.melt,measure.vars = c("Thickness","Count","Connections"),variable.name="Measured",value.name="MValue") | |
| all.melt<-melt(strt.melt,measure.vars = c("GrowthRate","Strength","Viability"),variable.name="Desired",value.name="DValue") | |
| ggplot(all.melt,aes(x=CValue,y=MValue))+ | |
| geom_jitter()+ | |
| facet_grid(Measured~Controlled,scales="free")+ | |
| labs(x="Controlled Value",y="Measured Value")+ | |
| theme_bw(25) | |
| ggplot(all.melt,aes(x=CValue,y=DValue))+ | |
| geom_jitter()+ | |
| facet_grid(Desired~Controlled,scales="free")+ | |
| labs(x="Controlled Value",y="Desired Value")+ | |
| theme_bw(25) | |
| ggplot(all.melt,aes(x=MValue,y=DValue))+ | |
| geom_jitter()+ | |
| facet_grid(Desired~Measured,scales="free")+ | |
| labs(y="Desired Value",x="Measured Value")+ | |
| theme_bw(25) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment