Skip to content

Instantly share code, notes, and snippets.

@stephenturner
Created January 19, 2016 21:26
Show Gist options
  • Save stephenturner/36216f32349d8003ce9f to your computer and use it in GitHub Desktop.
Save stephenturner/36216f32349d8003ce9f to your computer and use it in GitHub Desktop.
# Function to merge topTable output with original expression values
# Function to merge topTable output with original expression values
mergett <- function(tt, eset) {
if (class(tt)!="data.frame") stop("tt should be a data.frame")
if (class(eset)!="ExpressionSet") stop("eset should be an ExpressionSet")
exprset <- data.frame(exprs(eset))
exprset$ID <- rownames(exprset)
rownames(exprset) <- NULL
print(paste("nrow(tt):", nrow(tt)))
print(paste("nrow(exprset):", nrow(exprset)))
if (nrow(tt)==nrow(exprset)) {
newtt <- merge(tt, exprset) # merge with intensities
} else {
stop("nrow(tt) != nrow(exprset)")
}
print(paste("nrow(newtt):", nrow(newtt)))
newtt <- newtt[order(newtt$P.Val), ] #reorder by p-value
rownames(newtt) <- NULL
newtt
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment