load("my.data.selected.imputed.RData")
load("my.gini.perm.RData")
load("my.perm.perm.RData")

nlevelsSNPs<-sapply(my.data.selected.imputed[,-1],FUN=function(x) nlevels(factor(x)))


######################
# 2 categorical SNPs #
######################
my.snps2<-my.data.selected.imputed[,1+which(nlevelsSNPs==2)]
my.gini.perm2<-my.gini.perm[which(nlevelsSNPs==2),]
my.perm.perm2<-my.perm.perm[which(nlevelsSNPs==2),]

freq2<-function(x)
{
tab<-table(x)
return(min(tab)/sum(tab))
}

my.freq2<-sapply(my.snps2,FUN=freq2)

######################
# 3 categorical SNPs #
######################
my.snps3<-my.data.selected.imputed[,1+which(nlevelsSNPs==3)]
my.gini.perm3<-my.gini.perm[which(nlevelsSNPs==3),]
my.perm.perm3<-my.perm.perm[which(nlevelsSNPs==3),]

maf3<-function(x)
{
tab<-table(x)
return((tab[2]+2*min(tab[1],tab[3]))/(2*sum(tab)))
}

my.maf3<-sapply(my.snps3,FUN=maf3)

# Boxplot Gini
boxplot(as.numeric(my.gini.perm3[my.maf3<0.1,]),as.numeric(my.gini.perm3[my.maf3>=0.1&my.maf3<0.2,]),as.numeric(my.gini.perm3[my.maf3>=0.2&my.maf3<0.3,]),as.numeric(my.gini.perm3[my.maf3>=0.3& my.maf3<0.4,]),as.numeric(my.gini.perm3[my.maf3>=0.4,]),ylim=c(0,0.1))

# Boxplot perm
boxplot(as.numeric(my.perm.perm3[my.maf3<0.1,]),as.numeric(my.perm.perm3[my.maf3>=0.1&my.maf3<0.2,]),as.numeric(my.perm.perm3[my.maf3>=0.2&my.maf3<0.3,]),as.numeric(my.perm.perm3[my.maf3>=0.3& my.maf3<0.4,]),as.numeric(my.perm.perm3[my.maf3>=0.4,]),ylim=c(-5e-5,5e-5))




####################
### small forests ##
####################

load("my.gini.RData")
load("my.perm.RData")
load("my.freq2.RData")
load("my.maf3.RData")

my.gini<-as.numeric(my.gini)
my.perm<-as.numeric(my.perm)

my.freq2<-as.numeric(my.freq2)
my.maf3<-as.numeric(my.maf3)

boxplot(my.gini[my.maf3<0.1],my.gini[my.maf3>=0.1&my.maf3<0.2],my.gini[my.maf3>=0.2&my.maf3<0.3],my.gini[my.maf3>=0.3& my.maf3<0.4],my.gini[my.maf3>=0.4])
boxplot(my.perm[my.maf3<0.1],my.perm[my.maf3>=0.1&my.maf3<0.2],my.perm[my.maf3>=0.2&my.maf3<0.3],my.perm[my.maf3>=0.3& my.maf3<0.4],my.perm[my.maf3>=0.4])


