# --- Generate data sets
n<-20 # sample size
p<-5 # number of genes
genes.name<-paste("G",seq(1,p),sep="") # genes name
data<-matrix(rnorm(p*n),n,p) # generate expression matrix
data[,1]<-data[,2] # var 1 and 2 interact
W<-abs(matrix(rnorm(p*p),p,p)) # generate score for regulatory relationships
# --- Standardize variables to mean 0 and variance 1
data <- (apply(data, 2, function(x) { (x - mean(x)) / sd(x) } ))
# --- Run iRafNet and obtain importance score of regulatory relationships
out<-iRafNet(data,W,mtry=round(sqrt(p-1)),ntree=1000,genes.name)
# --- Matrix of true regulations
truth<-out[,seq(1,2)]
truth<-cbind(as.character(truth[,1]),as.character(truth[,2])
,as.data.frame(rep(0,,dim(out)[1])));
truth[(truth[,1]=="G2" & truth[,2]=="G1") | (truth[,1]=="G1" & truth[,2]=="G2"),3]<-1
# --- Plot ROC curve and compute AUC
auc<-roc_curve(out,truth)
Run the code above in your browser using DataLab