Mercurial > repos > yufei-luo > s_mart
diff SMART/DiffExpAnal/DESeqTools/exportDiff.R @ 18:94ab73e8a190
Uploaded
author | m-zytnicki |
---|---|
date | Mon, 29 Apr 2013 03:20:15 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SMART/DiffExpAnal/DESeqTools/exportDiff.R Mon Apr 29 03:20:15 2013 -0400 @@ -0,0 +1,42 @@ +# exportDiff +# export differentially expressed genes + +# input : complete, alpha, adjMethod, projectName +# output : diff genes, up and down in xls files + +# created Feb 14th, 2012 + + +exportDiff <- function( complete, alpha, adjMethod, OUT_upName, OUT_downName, out = T ){ + + diff <- complete[which(complete[,grep("adjp",colnames(complete))] < alpha),] + + gup <- up( diff ) + gdown <- down( diff ) + + if (out){ + gup[,(ncol(gup)-4):ncol(gup)] <- format( gup[,(ncol(gup)-4):ncol(gup)], digits=3, dec=",") + gdown[,(ncol(gdown)-4):ncol(gdown)] <- format( gdown[,(ncol(gdown)-4):ncol(gdown)], digits=3, dec=",") + write.table(gup, file=OUT_upName, row.names=F, sep="\t") + write.table(gdown, file=OUT_downName, row.names=F, sep="\t") + } + return( diff ) +} + + +up <- function( diff ){ + + up <- diff[diff$log2FC > 0,] + up <- up[order(up[,grep("adjp",colnames(up))]),] + + return( up ) +} + + +down <- function( diff ){ + + down <- diff[diff$log2FC < 0,] + down <- down[order(down[,grep("adjp",colnames(down))]),] + + return( down ) +}