# Example of R commands to call the ROMPrev functions within R # # MH Roy-Gagnon # 3/05 # # last modified: 10/3/06 source("E:/ROMP/ROMPrev_v0.1.r") # Defines the R functions sink("E:/ROMP/ROMPrev_example.out") # Sends output to the specified file # Specifies the input file. The example data files contains 150 trios with # phenotype data and SNP genotype data for 3 SNPs filename<-"E:/ROMP/ROMPrev_example.data" # Prepares data for analyses and saves them in list object data data<-ROMPrevPrep(filename) # This loop runs ROMPrev and ROMPrevRS for the 3 SNPs. for (i in 1:3) { res<-ROMPrev(data$y,data$xmp,data$z[,i]) print(paste("ROMPrev, SNP",i)) print(res) print(paste("ROMPrevRS, SNP",i)) print(ROMPrevRS(data$y,data$xmp,data$z[,i],res,1000)) } # This loop runs ROOPrev and ROOPrevRS for the 3 SNPs. for (i in 1:3) { res<-ROOPrev(data$y,data$xop,data$z[,i]) print(paste("ROOPrev, SNP",i)) print(res) print(paste("ROOPrevRS, SNP",i)) print(ROOPrevRS(data$y,data$xop,data$z[,i],res,1000)) } sink() # Stops sending output to file # The results can also be saved to a file directly from the list object created # by the functions. For example, the following would save the ROMPrev estimates, # standard errors, and p-values in a comma-delimited file: out<-matrix(NA,nrow=3,ncol=7) for (i in 1:3) { res<-ROMPrev(data$y,data$xmp,data$z[,i]) out[i,1]<-res$n out[i,2]<-res$h2 out[i,3]<-res$seh2 out[i,4]<-res$ph2 out[i,5]<-res$h2l out[i,6]<-res$seh2l out[i,7]<-res$ph2l } colnames(out)<-c("n","h2","seh2","ph2","h2l","seh2l","ph2l") row.names(out)<-c("SNP1","SNP2","SNP3") write.csv(out,file="E:/ROMP/ROMPrev_example_out.csv") # Names of elements in list object are given in the documentation for each function