createTable {BGcom}R Documentation

Function to create an output table

Description

This function creates an output table with the results from the Bayesian model in a csv format.

Usage

createTable(dir,output.ratio,output.bay,name)
        

Arguments

dir directory for storing the table
output.ratio The output object from the Frequentist model (ratio function)
output.bay The output object from the Bayesian model (baymod function)
name Name of the .csv file where the output is stored

Details

To select a list of interesting features from the Bayesian model we suggest two decision rules in the paper: 1. the maximum of Median(R(q)) only for the subset of credibility intervals which do not include 1 2. the largest threshold q for which the ratio R(q) il bigger than 2

The first one is pointing out the strongest deviation from independence, whilst the second is the largest threshold where the number of genes called in common at least doubles the number of genes in common under independence.

Value

An object of the class list with two recommended decision rules:

max the results of the Rmax statistic
rule2 the results using the rule R larger than 2 (see details)

Author(s)

Marta Blangiardo

References

1. M.Blangiardo and S.Richardson Statistical tools for synthesizing lists of differentially expressed features in related experiments , Genome Biology, 8, R54

Examples

data = simulation(n=500,GammaA=1,GammaB=1,r1=0.5,r2=0.8,DEfirst=300,DEsecond=200,DEcommon=100)
T<- ratio(data$Pval,interval=0.01,dir="D:/",name="CompData1Data2",pvalue=TRUE)
BayesianModel<- baymod(data$Pval,repl=100,output.ratio=T,dir="D:/")
output.table <- createTable(dir="D:/",output.ratio=T,output.bay=BayesianModel,name="OutputTable")
 
## The function is currently defined as
function(dir,output.ratio,output.bay,name){
if(output.ratio$pvalue==TRUE){
matrix.results =  cbind(output.ratio$q,round(output.bay,3),output.ratio$DECommon,output.ratio$DE)
lists = dim(output.ratio$DE)[2]
namesDE = paste("O",seq(1,lists),rep("+",lists))
names.matrix = c("q","LowCI","MedCI","HighCI","O11",namesDE)
dimnames(matrix.results)[[2]]<-names.matrix
}
if(output.ratio$pvalue==FALSE){
matrix.results =  cbind(1-output.ratio$q,round(output.bay,3),output.ratio$DECommon,output.ratio$DE)
lists = dim(output.ratio$DE)[2]
namesDE = paste("O",seq(1,lists),rep("+",lists))
names.matrix = c("q","LowCI","MedCI","HighCI","O11",namesDE)
dimnames(matrix.results)[[2]]<-names.matrix
}

#Decision rules:
#1) Maximum for CI not including 1
max.R = max(matrix.results[round(round(matrix.results[,2],2),1)>1,3])
maximum = matrix.results[matrix.results[,3]==max.R,]

if(length(matrix.results[matrix.results[round(matrix.results[,2],2)>1,3]>=2,1])>0){
#2) Rule 2
R2 = max(matrix.results[round(round(matrix.results[,3],2),3)>=2 & round(round(matrix.results[,2],2),1)>1 ,1])
rule2 = matrix.results[matrix.results[,1]==R2,]

setwd(dir)
write.csv(matrix.results,paste(name,".csv"),row.names=FALSE)
return(list(maximum=maximum,rule2=rule2))
        }

if(length(matrix.results[matrix.results[round(matrix.results[,2],2)>1,3]>=2,1])==0){
#2) Rule 2
setwd(dir)
write.csv(matrix.results,paste(name,".csv"),row.names=FALSE)
return(maximum=maximum)
        }

}


[Package BGcom version 1.0 Index]