




###############################################################fisher's exact test for gene expression


 setwd ("final")


 k <- 1
 
 load ("expr.main.RData")
 load ( paste("Main.expr.perm", k, ".RData", sep="") ) 
 s0 <- quantile(expr.perm[[2]], 0.5); rm(expr.perm); gc()
 main <- expr.main[[k]][,1] / ( expr.main[[k]][,2]+ s0)
 names(main) <- rownames(expr.main[[k]])



 ##1249 676
 #418	224

 glist <- names( sort(main) ) [1:676]
 glist <- c(glist, names(sort(main, decreasing=T) )[1:1249])
 #glist <- names( sort(main) ) [1:224]
 #glist <- c(glist, names(sort(main, decreasing=T) )[1:418])
 total.gene <- names(main)


 go <- c("proc", "func", "comp")
 j <- 3
 load ( paste("../ftp/go.", go[j], ".RData", sep="") )


 gene.list <- intersect(total.gene, rownames(go.mat) )  
 go.mat <- go.mat[ which(rownames(go.mat) %in% gene.list), ]
 go.mat <- go.mat[, colSums(go.mat) >= 10] 
 go.mat <- go.mat[rowSums(go.mat) >0,]

 gene.list <- intersect(gene.list, rownames(go.mat) )
 go.mat <- go.mat[ match(gene.list, rownames(go.mat) ), ]

 sig.list <- intersect( glist, rownames(go.mat) ) 
 sig.mat <- go.mat[ match(sig.list, rownames(go.mat)), ]


 tab <- matrix(NA, nc=2, nr=ncol(go.mat) )
 rownames(tab) <- colnames(go.mat)
 tab[,1] <- colSums(sig.mat)
 tab[,2] <- colSums(go.mat)

 fisher.pval <- rep(NA, nrow(tab) )
 names(fisher.pval) <- rownames(tab)

 for( i in 1:nrow(tab) )
 {
  mat <- matrix(c(tab[i,1], length(sig.list)-tab[i,1], tab[i,2]-tab[i,1],  length(gene.list)-length(sig.list)-(tab[i,2]-tab[i,1]) ), nc=2, dimnames=list( c("within.cat", "out.cat"), c("significant", "non.significant") )  ) 
  fisher.pval [i] <- fisher.test(mat, alternative="greater")$p.value
 }



 library(multtest)
 adj.pval <- mt.rawp2adjp (fisher.pval, proc="Bonferroni") #could be "Bonferroni" or other process ("Holm", "Hochberg", "SidakSS", "SidakSD", "BH", "BY")
 result <- adj.pval$adjp
 rownames(result) <- names(fisher.pval)[adj.pval$index]


  load ("find.RData")
 hit <- result[1:10,]

 anno <- find[ match( rownames(hit), names(find)) ]
 print( data.frame( rawp=hit[,1], bonferronip=hit[,2], anno) )



                   rawp  bonferronip                           anno
GO:0009535 4.556030e-08 4.100427e-06 chloroplast thylakoid membrane
GO:0016020 1.865101e-06 1.678591e-04                       membrane
GO:0005886 7.767913e-05 6.991122e-03                plasma membrane
GO:0009507 5.584464e-04 5.026018e-02                    chloroplast
GO:0005829 2.256450e-03 2.030805e-01                        cytosol
GO:0009536 3.880283e-03 3.492255e-01                        plastid
GO:0009706 3.911509e-03 3.520359e-01     chloroplast inner membrane






 ind  <- which (colnames(sig.mat)=="GO:0009535")
 hit.gene <- rownames(sig.mat)[ sig.mat[, ind] == 1]
  write(hit.gene, "write.gene.membrane.txt")


 ind  <- which (colnames(sig.mat)=="GO:0009543")
 hit.gene <- rownames(sig.mat)[ sig.mat[, ind] == 1]
  write(hit.gene, "write.gene.lumen.txt")




write( cbind(hit.gene,  as.character(gene.info$annotation)[ match(hit.gene,  toupper(as.character(gene.info$gene)) )]), "write.gene.membrane.txt")





#######################################################################exon fisher's


 setwd ("final")


 load ("tmean.main.v2.RData")
 load ("Main.tmean.perm.v2.1.RData") 
 s0 <- quantile(texpr.perm[[2]], 0.5); rm(texpr.perm); gc()
 main <- texpr.main[[1]][,1] / ( texpr.main[[1]][,2]+ s0)
 names(main) <- rownames(texpr.main[[1]])


 

 #287	190
 #127	109




 tlist <- names( sort(main) ) [1:190]
 tlist <- c(tlist, names(sort(main, decreasing=T) )[1:287])
 #tlist <- names( sort(main) ) [1:109]
 #tlist <- c(tlist, names(sort(main, decreasing=T) )[1:127])
 
 sig.gene <- matrix( unlist(strsplit(tlist, " ") ), byrow=T, nc=2)[,1]
 sig.gene <- names(table(sig.gene))
 total.gene <- matrix( unlist(strsplit(names(main), " ") ), byrow=T, nc=2)[,1]
 total.gene <- names(table(total.gene) )


 go <- c("proc", "func", "comp")
 j <- 3
 load ( paste("../ftp/go.", go[j], ".RData", sep="") )

 gene.list <- intersect(total.gene, rownames(go.mat) )  
 go.mat <- go.mat[ which(rownames(go.mat) %in% gene.list), ]
 go.mat <- go.mat[, colSums(go.mat) >= 10] 
 go.mat <- go.mat[rowSums(go.mat) >0,]

 gene.list <- intersect(gene.list, rownames(go.mat) )
 go.mat <- go.mat[ match(gene.list, rownames(go.mat) ), ]
 
 sig.list <- intersect( sig.gene, rownames(go.mat) ) 
 sig.mat <- go.mat[ match(sig.list, rownames(go.mat)), ]


 tab <- matrix(NA, nc=2, nr=ncol(go.mat) )
 rownames(tab) <- colnames(go.mat)
 tab[,1] <- colSums(sig.mat)
 tab[,2] <- colSums(go.mat)

 fisher.pval <- rep(NA, nrow(tab) )
 names(fisher.pval) <- rownames(tab)

 for( i in 1:nrow(tab) )
 {
  mat <- matrix(c(tab[i,1], length(sig.list)-tab[i,1], tab[i,2]-tab[i,1],  length(gene.list)-length(sig.list)-(tab[i,2]-tab[i,1]) ), nc=2, dimnames=list( c("within.cat", "out.cat"), c("significant", "non.significant") )  ) 
  fisher.pval [i] <- fisher.test(mat, alternative="greater")$p.value
 }



 library(multtest)
 adj.pval <- mt.rawp2adjp (fisher.pval, proc="Bonferroni") #could be "Bonferroni" or other process ("Holm", "Hochberg", "SidakSS", "SidakSD", "BH", "BY")
 result <- adj.pval$adjp
 rownames(result) <- names(fisher.pval)[adj.pval$index]


 load ("find.RData")
 hit <- result[1:10,]
 anno <- find[ match( rownames(hit), names(find)) ]
 print( data.frame( rawp=hit[,1], bonferronip=hit[,2], anno) )



 load ("../liping/atV5.geneinfo.RData")
 ind  <- which (colnames(sig.mat)=="GO:0009535")
 hit.exon <- rownames(sig.mat)[ sig.mat[, ind] == 1]
 cbind( hit.exon, as.character(gene.info$annotation)[ match(hit.exon, toupper( as.character(gene.info$gene) ) )] )



 ind  <- which (colnames(sig.mat)=="GO:0009543")
 hit.exon <- rownames(sig.mat)[ sig.mat[, ind] == 1]
cbind( hit.exon, as.character(gene.info$annotation)[ match(hit.exon, toupper( as.character(gene.info$gene) ) )] )







##################################################intron fisher's


setwd ("final")


load ("iexpr.main.v2.RData")
load ("Main.iexpr.perm.v2.1.RData") 
s0 <- quantile(iexpr.perm[[2]], 0.5); rm(iexpr.perm); gc()
main <- iexpr.main[[1]][,1] / ( iexpr.main[[1]][,2]+ s0)
names(main) <- rownames(iexpr.main[[1]])


#239	220
#202	155




ilist <- names( sort(main) ) [1:220]
ilist <- c(ilist, names(sort(main, decreasing=T) )[1:239])
#ilist <- names( sort(main) ) [1:155]
#ilist <- c(ilist, names(sort(main, decreasing=T) )[1:202])



sig.gene <- matrix( unlist(strsplit(ilist, " ") ), byrow=T, nc=2)[,1]
sig.gene <- names(table(sig.gene))
total.gene <- matrix( unlist(strsplit(names(main), " ") ), byrow=T, nc=2)[,1]
total.gene <- names(table(total.gene) )


go <- c("proc", "func", "comp")
j <- 1
load ( paste("../ftp/go.", go[j], ".RData", sep="") )


gene.list <- intersect(total.gene, rownames(go.mat) )  
go.mat <- go.mat[ which(rownames(go.mat) %in% gene.list), ]
go.mat <- go.mat[, colSums(go.mat) >= 10] 
go.mat <- go.mat[rowSums(go.mat) >0,]

gene.list <- intersect(gene.list, rownames(go.mat) )
go.mat <- go.mat[ match(gene.list, rownames(go.mat) ), ]

sig.list <- intersect( sig.gene, rownames(go.mat) ) 
sig.mat <- go.mat[ match(sig.list, rownames(go.mat)), ]


tab <- matrix(NA, nc=2, nr=ncol(go.mat) )
rownames(tab) <- colnames(go.mat)
tab[,1] <- colSums(sig.mat)
tab[,2] <- colSums(go.mat)

fisher.pval <- rep(NA, nrow(tab) )
names(fisher.pval) <- rownames(tab)

for( i in 1:nrow(tab) )
{
mat <- matrix(c(tab[i,1], length(sig.list)-tab[i,1], tab[i,2]-tab[i,1],  length(gene.list)-length(sig.list)-(tab[i,2]-tab[i,1]) ), nc=2, dimnames=list( c("within.cat", "out.cat"), c("significant", "non.significant") )  ) 
fisher.pval [i] <- fisher.test(mat, alternative="greater")$p.value
}



library(multtest)
adj.pval <- mt.rawp2adjp (fisher.pval, proc="Bonferroni") #could be "Bonferroni" or other process ("Holm", "Hochberg", "SidakSS", "SidakSD", "BH", "BY")
result <- adj.pval$adjp
rownames(result) <- names(fisher.pval)[adj.pval$index]


load ("find.RData")
hit <- result[1:10,]
 
 anno <- find[ match( rownames(hit), names(find)) ]
 print( data.frame( rawp=hit[,1], bonferronip=hit[,2], anno) )




#spling bioprocess at 3% FDR intron
 ind  <- which (colnames(sig.mat)=="GO:0008380")
 hit.intron <- rownames(sig.mat)[ sig.mat[, ind] == 1]
 load ("../liping/atV5.geneinfo.RData")
 cbind( hit.intron, as.character(gene.info$annotation)[ match(hit.intron, toupper( as.character(gene.info$gene) ) )] )



#chlorophyl thylokoid membrane
 ind  <- which (colnames(sig.mat)=="GO:0009535")
 hit.intron <- rownames(sig.mat)[ sig.mat[, ind] == 1]
 cbind( hit.intron, as.character(gene.info$annotation)[ match(hit.intron, toupper( as.character(gene.info$gene) ) )] )


#chlorophyl thylokoid lumen
 ind  <- which (colnames(sig.mat)=="GO:0009543")
 hit.intron <- rownames(sig.mat)[ sig.mat[, ind] == 1]
cbind( hit.intron, as.character(gene.info$annotation)[ match(hit.intron, toupper( as.character(gene.info$gene) ) )] )








#########################################################page for gene expression

 setwd ("final")

 k <- 1

 load ("expr.main.RData")
 load ( paste("Main.expr.perm", k, ".RData", sep="") ) 
 s0 <- quantile(expr.perm[[2]], 0.5); rm(expr.perm); gc()
 main <- expr.main[[k]][,1] / ( expr.main[[k]][,2]+ s0)
 names(main) <- rownames(expr.main[[k]])

 
 go <- c("proc", "func", "comp")
 j <- 3
 load ( paste("../ftp/go.", go[j], ".RData", sep="") )

 gene.list <- intersect( names(main), rownames(go.mat) )
 go.mat <- go.mat[ which(rownames(go.mat) %in% gene.list), ]
 go.mat <- go.mat[, colSums(go.mat) >= 15]
 go.mat <- go.mat[rowSums(go.mat) >0,]

 gene.list <- intersect(names(main), rownames(go.mat) )
 main <- main[ match(gene.list, names(main) ) ]
 go.mat <- go.mat[ match(gene.list, rownames(go.mat) ), ]

 vec <- rep(NA, ncol(go.mat) )
 names(vec)  <- colnames(go.mat)
 z <- p <- vec


 mu <- mean(main )
 std <- sqrt( var(main) )

 for (i in 1:ncol(go.mat) )
 {
  hit <- rownames(go.mat)[ go.mat[,i]==1 ]

  d <- main [ which(names(main) %in% hit ) ]
  sm <- mean (d)
  n <- length(hit)

  z[i] <- (sm-mu)/ (std /sqrt(n) )
  ifelse( z[i] <=0, p[i] <- -pnorm(z[i] ), p[i] <- pnorm(z[i], lower.tail=F)  )
 }

 page <- cbind(z, p)
 page <- page[ order( abs(page[,2]) ),]



 hit <- page[ abs(page[,2])< 1e-3,]
 load ("find.RData")
 anno <- find[ match( rownames(hit), names(find)) ]
 print( data.frame( zscore=hit[,1], pval=hit[,2], anno) )




              zscore          pval                           anno
GO:0009535  4.423080  4.865191e-06 chloroplast thylakoid membrane
GO:0010287  4.006461  3.081766e-05                  plastoglobule
GO:0005634  3.810316  6.939464e-05                        nucleus
GO:0012505 -3.619631 -1.475115e-04            endomembrane system





#########################################################################################exon page




setwd ("final")


load ("tmean.main.v2.RData")
load ("Main.tmean.perm.v2.1.RData") 
s0 <- quantile(texpr.perm[[2]], 0.5); rm(texpr.perm); gc()
main <- texpr.main[[1]][,1] / ( texpr.main[[1]][,2]+ s0)
names(main) <- rownames(texpr.main[[1]])

total.gene <- matrix( unlist(strsplit(names(main), " ") ), byrow=T, nc=2)[,1]
main <- tapply(main, total.gene, max)
#main <- tapply(main, total.gene, min)

go <- c("proc", "func", "comp")
j <- 2
load ( paste("../ftp/go.", go[j], ".RData", sep="") )

gene.list <- intersect( names(main), rownames(go.mat) )
go.mat <- go.mat[ which(rownames(go.mat) %in% gene.list), ]
go.mat <- go.mat[, colSums(go.mat) >= 15]
go.mat <- go.mat[rowSums(go.mat) >0,]

gene.list <- intersect(names(main), rownames(go.mat) )
main <- main[ match(gene.list, names(main) ) ]
go.mat <- go.mat[ match(gene.list, rownames(go.mat) ), ]

vec <- rep(NA, ncol(go.mat) )
names(vec)  <- colnames(go.mat)
z <- p <- vec


mu <- mean(main )
std <- sqrt( var(main) )

for (i in 1:ncol(go.mat) )
{
hit <- rownames(go.mat)[ go.mat[,i]==1 ]

d <- main [ which(names(main) %in% hit ) ]
sm <- mean (d)
n <- length(hit)

z[i] <- (sm-mu)/ (std /sqrt(n) )
ifelse( z[i] <=0, p[i] <- -pnorm(z[i] ), p[i] <- pnorm(z[i], lower.tail=F)  )

}

page <- cbind(z, p)
page <- page[ order( abs(page[,2]) ),]




 hit <- page[ abs(page[,2])< 1e-3,]
 load ("find.RData")
 anno <- find[ match( rownames(hit), names(find)) ]
 print( data.frame( zscore=hit[,1], pval=hit[,2], anno) )





              zscore          pval                       anno
GO:0009507  7.361716  9.078057e-14                chloroplast
GO:0005739  5.674505  6.954517e-09                mitochondrion
GO:0009535 4.960863 3.509027e-07                  chloroplast thylakoid membrane
GO:0005875 4.447659 4.340569e-06                 microtubule associated complex
GO:0005886 4.259624 1.023854e-05                plasma membrane
GO:0009705 4.049259 2.568999e-05                  membrane of vacuole with cell cycle-independent morphology
GO:0005829 3.994765 3.237927e-05                     cytosol
GO:0005643 3.845632 6.012114e-05                nuclear pore
GO:0009543 3.702742 1.066408e-04                 chloroplast thylakoid lumen
GO:0005777 3.475793 2.546727e-04                  peroxisome
GO:0016459 3.210305 6.629699e-04              myosin complex





             zscore          pval                                      anno

GO:0005575  5.114991  1.568783e-07                cellular_component_unknown
GO:0005840  3.998926  3.181530e-05                ribosome
GO:0009505  3.299641  4.840429e-04                cellulose and pectin-containing cell wall
GO:0012505  3.155334  8.015734e-04                endomembrane system




#####################################################################################intron page


setwd ("final")


load ("iexpr.main.v2.RData")
load ("Main.iexpr.perm.v2.1.RData") 
s0 <- quantile(iexpr.perm[[2]], 0.5); rm(iexpr.perm); gc()
main <- iexpr.main[[1]][,1] / ( iexpr.main[[1]][,2]+ s0)
names(main) <- rownames(iexpr.main[[1]])

total.gene <- matrix( unlist(strsplit(names(main), " ") ), byrow=T, nc=2)[,1]
main <- tapply(main, total.gene, max)
#main <- tapply(main, total.gene, min)

go <- c("proc", "func", "comp")
j <- 1
load ( paste("../ftp/go.", go[j], ".RData", sep="") )

gene.list <- intersect( names(main), rownames(go.mat) )
go.mat <- go.mat[ which(rownames(go.mat) %in% gene.list), ]
go.mat <- go.mat[, colSums(go.mat) >= 15]
go.mat <- go.mat[rowSums(go.mat) >0,]

gene.list <- intersect(names(main), rownames(go.mat) )
main <- main[ match(gene.list, names(main) ) ]
go.mat <- go.mat[ match(gene.list, rownames(go.mat) ), ]

vec <- rep(NA, ncol(go.mat) )
names(vec)  <- colnames(go.mat)
z <- p <- vec


mu <- mean(main )
std <- sqrt( var(main) )

for (i in 1:ncol(go.mat) )
{
hit <- rownames(go.mat)[ go.mat[,i]==1 ]

d <- main [ which(names(main) %in% hit ) ]
sm <- mean (d)
n <- length(hit)

z[i] <- (sm-mu)/ (std /sqrt(n) )
ifelse( z[i] <=0, p[i] <- -pnorm(z[i] ), p[i] <- pnorm(z[i], lower.tail=F)  )

}

page <- cbind(z, p)
page <- page[ order( abs(page[,2]) ),]





 hit <- page[ abs(page[,2])< 1e-2,]
 load ("find.RData")
 anno <- find[ match( rownames(hit), names(find)) ]
 print( data.frame( zscore=hit[,1], pval=hit[,2], anno) )





              zscore          pval                           anno
GO:0005777  4.267285  9.893296e-06                     peroxisome
GO:0005875  4.195071  1.363930e-05 microtubule associated complex
GO:0009535  4.172226  1.508190e-05 chloroplast thylakoid membrane
GO:0005739  4.133764  1.784350e-05                  mitochondrion
GO:0016459  3.151691  8.116384e-04                 myosin complex






              zscore          pval                           anno

GO:0012505  5.370244  3.931512e-08            endomembrane system
GO:0031225  3.250106  5.768092e-04           anchored to membrane







#######################################################see overlap in chloroplast 


 setwd ("final")

 hit.gene <- scan("write.gene.membrane.txt", what="a")
 hit.exon <- scan("write.exon.membrane.txt", what="a")
 hit.intron <- scan("write.intron.membrane.txt", what="a")



 load ("../liping/atV5.geneinfo.RData")
 write( cbind(hit.intron,  as.character(gene.info$annotation)[ match(hit.intron,  toupper(as.character(gene.info$gene)) )]), "write.txt", append=T)
 write( cbind(hit.exon,  as.character(gene.info$annotation)[ match(hit.exon,  toupper(as.character(gene.info$gene)) )]), "write.txt", append=T)
  

hit.intron[- which(hit.intron %in% intersect( hit.gene, hit.intron)  ) ]
hit.exon[- which(hit.exon %in% intersect( hit.gene, hit.exon)  ) ]






  hit.gene <- scan("write.gene.lumen.txt", what="a")
  hit.exon <- scan("write.exon.lumen.txt", what="a") 
  hit.intron <- scan("write.intron.lumen.txt", what="a")

 write( cbind(hit.intron,  as.character(gene.info$annotation)[ match(hit.intron,  toupper(as.character(gene.info$gene)) )]), "write.txt", append=T)
 write( cbind(hit.exon,  as.character(gene.info$annotation)[ match(hit.exon,  toupper(as.character(gene.info$gene)) )]), "write.txt", append=T)



###



load ("tmean.main.v2.RData")
load ("Main.tmean.perm.v2.1.RData") 
s0 <- quantile(texpr.perm[[2]], 0.5); rm(texpr.perm); gc()
main <- texpr.main[[1]][,1] / ( texpr.main[[1]][,2]+ s0)
names(main) <- rownames(texpr.main[[1]])

 #cut.exon <- quantile( main, (length(main)-287+1)/length(main) )
 #> cut.exon
 #99.68654%
 # 2.034867

 tu.list <- names( sort(main) ) [1:190]
 tu.list <- c(tu.list, names(sort(main, decreasing=T) )[1:287])
 egene <- matrix( unlist(strsplit(tu.list, " ") ), byrow=T, nc=2)[,1]
 egene <- names(table(egene))

 total.gene <- matrix( unlist(strsplit(names(main), " ") ), byrow=T, nc=2)[,1]
 total.gene <- names(table(total.gene))

 #main <- tapply(main, total.gene, max)
 #main <- tapply(main, total.gene, min)

go <- c("proc", "func", "comp")
j <- 3
load ( paste("../ftp/go.", go[j], ".RData", sep="") )

gene.list <- intersect( total.gene, rownames(go.mat) )
go.mat <- go.mat[ which(rownames(go.mat) %in% gene.list), ]
go.mat <- go.mat[, colSums(go.mat) >= 15]
go.mat <- go.mat[rowSums(go.mat) >0,]

 
ind  <- which (colnames(go.mat)=="GO:0009535")
hit.exon <- rownames(go.mat)[ go.mat[, ind] == 1]

d.exon <- egene[ which(egene %in% hit.exon) ]


###


load ("iexpr.main.v2.RData")
load ("Main.iexpr.perm.v2.1.RData") 
s0 <- quantile(iexpr.perm[[2]], 0.5); rm(iexpr.perm); gc()
main <- iexpr.main[[1]][,1] / ( iexpr.main[[1]][,2]+ s0)
names(main) <- rownames(iexpr.main[[1]])


 #cut.intron <- quantile( main, (length(main)-202+1)/length(main) )
 #> cut.intron
 #99.68024%
 # 2.184137

 
 tu.list <- names( sort(main) ) [1:155]
 tu.list <- c(tu.list, names(sort(main, decreasing=T) )[1:202])
 igene <- matrix( unlist(strsplit(tu.list, " ") ), byrow=T, nc=2)[,1]
 igene <- names(table(igene))
 total.gene <- matrix( unlist(strsplit(names(main), " ") ), byrow=T, nc=2)[,1]
 total.gene <- names(table(total.gene) )
 


 #main <- tapply(main, total.gene, max)
 #main <- tapply(main, total.gene, min)

go <- c("proc", "func", "comp")
j <- 3
load ( paste("../ftp/go.", go[j], ".RData", sep="") )

gene.list <- intersect( total.gene, rownames(go.mat) )
go.mat <- go.mat[ which(rownames(go.mat) %in% gene.list), ]
go.mat <- go.mat[, colSums(go.mat) >= 15]
go.mat <- go.mat[rowSums(go.mat) >0,]

 
ind  <- which (colnames(go.mat)=="GO:0009535")
hit.intron <- rownames(go.mat)[ go.mat[, ind] == 1]

d.intron <- igene[ which(igene %in% hit.intron) ]








top.gene <- sort(d.gene, decreasing=T)
top.gene <- top.gene[ top.gene >= cut.gene]


top.exon <- sort(d.exon, decreasing=T)
top.exon <- top.exon[ top.exon >=cut.exon]



top.intron <- sort(d.intron, decreasing=T)
top.intron <- top.intron[ top.intron >=cut.intron]


#ge <- intersect( names(top.gene), names(top.exon) )
#gi <- intersect( names(top.gene), names(top.intron) )


load ("../liping/atV5.geneinfo.RData")


name=c(names(top.gene), names(top.exon), names(top.intron))

ganno <- as.character(gene.info$annotation)[ match( name, toupper(as.character(gene.info$gene)) ) ]



dat <- data.frame(name , dscore=c(top.gene, top.exon, top.intron), ganno)


write(dat, file="write.txt")






























