R/tabIndepFiltering.R

Defines functions tabIndepFiltering

Documented in tabIndepFiltering

#' Table of features discarded by the independent filtering
#'
#' Table of features discarded by the independent filtering
#'
#' @param results list of results of \code{results(dds,...)} with chosen parameters
#' @param versionName versionName of the project
#' @return A matrix with the threshold and the number of features discarded 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 Aug 5th, 2014 (removed tabDir argument)
# modified Dec 18th, 2015 (way of getting the threshold changed in DESeq2 1.10.0s)

tabIndepFiltering <- function(results, versionName="."){
  out <- matrix(NA,ncol=3,nrow=length(names(results)),dimnames=list(names(results),c("Test vs Ref","Threshold","# discarded")))
  for (name in names(results)){
	  threshold <- metadata(results[[name]])$filterThreshold
	  out[name,2] <- round(threshold,2)
    use <- results[[name]]$baseMean > threshold
	  out[name,3] <- ifelse(is.na(table(use)["FALSE"]),0,table(use)["FALSE"])
  }
  out[,1] <- gsub("_"," ",rownames(out))
  rownames(out) <- NULL
  
  write.table(out,file=paste0("tables/",versionName,".tabIndepFiltering.xls"),
              row.names=FALSE,sep="\t")
  
  return(out)
}
biomics-pasteur-fr/RNADiff documentation built on Aug. 27, 2020, 12:44 a.m.