18
|
1 # exportDiff
|
|
2 # export differentially expressed genes
|
|
3
|
|
4 # input : complete, alpha, adjMethod, projectName
|
|
5 # output : diff genes, up and down in xls files
|
|
6
|
|
7 # created Feb 14th, 2012
|
|
8
|
|
9
|
|
10 exportDiff <- function( complete, alpha, adjMethod, OUT_upName, OUT_downName, out = T ){
|
|
11
|
|
12 diff <- complete[which(complete[,grep("adjp",colnames(complete))] < alpha),]
|
|
13
|
|
14 gup <- up( diff )
|
|
15 gdown <- down( diff )
|
|
16
|
|
17 if (out){
|
|
18 gup[,(ncol(gup)-4):ncol(gup)] <- format( gup[,(ncol(gup)-4):ncol(gup)], digits=3, dec=",")
|
|
19 gdown[,(ncol(gdown)-4):ncol(gdown)] <- format( gdown[,(ncol(gdown)-4):ncol(gdown)], digits=3, dec=",")
|
|
20 write.table(gup, file=OUT_upName, row.names=F, sep="\t")
|
|
21 write.table(gdown, file=OUT_downName, row.names=F, sep="\t")
|
|
22 }
|
|
23 return( diff )
|
|
24 }
|
|
25
|
|
26
|
|
27 up <- function( diff ){
|
|
28
|
|
29 up <- diff[diff$log2FC > 0,]
|
|
30 up <- up[order(up[,grep("adjp",colnames(up))]),]
|
|
31
|
|
32 return( up )
|
|
33 }
|
|
34
|
|
35
|
|
36 down <- function( diff ){
|
|
37
|
|
38 down <- diff[diff$log2FC < 0,]
|
|
39 down <- down[order(down[,grep("adjp",colnames(down))]),]
|
|
40
|
|
41 return( down )
|
|
42 }
|