#' Number of down, up and total per comparison
#'
#' Number of down, up and total per comparison
#'
#' @param complete list of \code{data.frame} containing features results
#' @param alpha threshold to apply to the FDR
#' @param versionName versionName of the project
#' @return A matrix with the number of up, down and total of features per comparison
#' @author Marie-Agnes Dillies and Hugo Varet
# created Nov 12th, 2013
# modified Feb 17th, 2014 (added versionName and tabDir to export the table)
# modified July 31th, 2014 (removed adjMethod argument)
# modified Aug 5th, 2014 (removed tabDir and log2FC argument)
# modified Feb 28th, 2017 (added quote=FALSE to write.table())
nDiffTotal <- function(complete, alpha=0.05, versionName="."){
nDiffTotal <- matrix(NA,ncol=4,nrow=length(complete),dimnames=list(names(complete),c("Test vs Ref", "# down","# up","# total")))
for (name in names(complete)){
complete.name <- complete[[name]]
if (!is.null(complete.name$betaConv)){
nDiffTotal[name,2:3]=c(nrow(complete.name[which(complete.name$padj <= alpha & complete.name$betaConv & complete.name$log2FoldChange<=0),]),
nrow(complete.name[which(complete.name$padj <= alpha & complete.name$betaConv & complete.name$log2FoldChange>=0),]))
} else{
nDiffTotal[name,2:3]=c(nrow(complete.name[which(complete.name$padj <= alpha & complete.name$log2FoldChange<=0),]),
nrow(complete.name[which(complete.name$padj <= alpha & complete.name$log2FoldChange>=0),]))
}
}
nDiffTotal[,4] <- nDiffTotal[,2] + nDiffTotal[,3]
nDiffTotal[,1] <- gsub("_"," ",rownames(nDiffTotal))
rownames(nDiffTotal) <- NULL
write.table(nDiffTotal,file=paste0("tables/",versionName,".nDiffTotal.xls"),row.names=FALSE,sep="\t",quote=FALSE)
return(nDiffTotal)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.