#' Remove ribosomal RNA features in all samples
#'
#' Remove ribosomal RNA features in all samples
#'
#' @param counts matrix of normalized counts
#' @param glength \code{data.frame} of 2 columns: features's id and length
#' @param versionName versionName of the project
#' @return The \code{matrix} of counts normalized by the feature lengths
#' @author Marie-Agnes Dillies and Hugo Varet
# created Nov 18th, 2013
# modified Jan 3rd, 2014 (col.names=NA and all.x=TRUE)
# modified Jan 7th, 2014 (counts[as.character(tmp$Id),])
# modified May 5th, 2014 (replaced nrow(counts) by nrow(tmp))
# modified Aug 5th, 2014 (removed tabDir argument)
# modified Nov 03rd, 2016 (now return the lnorm table)
normGeneLength <- function(counts, glength, versionName="."){
colnames(glength) <- c("Id", "length")
tmp <- merge(data.frame(Id=rownames(counts)), glength, by="Id", all.x=TRUE)
mat.glength <- matrix(tmp$length, nrow=nrow(tmp), ncol=ncol(counts), byrow=FALSE)
lnorm <- round(counts[as.character(tmp$Id),]*1000/mat.glength,digits=0)
write.table(lnorm, file=paste0("tables/",versionName, ".LengthNorm.xls"),
sep="\t", row.names=TRUE, col.names=NA, quote=FALSE)
return(invisible(lnorm))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.