#' plots count data
#'
#' plot count data for Lewy Body project
#'
#' @param m MSnSet object
#' @param valueName name of the value to be displayed
#'
#' @import RColorBrewer
#'
#' @export
#'
image.lewy.counts <- function(m, valueName='value'){
# scaling counts to [0,1]
x <- exprs(m)
x <- sweep(x, 1, apply(x, 1, min), '-')
x <- sweep(x, 1, apply(x, 1, max), '/')
exprs(m) <- x
# convertion to long format
mlong <- melt(exprs(m), varnames=c("Feature", "Sample.ID"),
value.name='value')
mlong$Peptide.ID <- as.character(mlong$Feature)
mlong$Sample.ID <- as.character(mlong$Sample.ID)
mlong <- merge(mlong, pData(m), by.x="Sample.ID", by.y="row.names")
x <- mlong
x$Feature <- ordered(x$Feature, levels=rev(sort(unique(x$Feature))))
gLabeller <- function(var, value){
value <- as.character(value)
if (var=="subject.type") {
value[value=="case"] <- "Cases with Lewy Bodies"
value[value=="control.1"] <- "Controls, Matched by Neuronal Loss"
value[value=="control.2"] <- "Controls, Not Matched by Neuronal Loss"
}
return(value)
}
p <- ggplot(x, aes(x=match.group, y=Peptide.ID, fill=value)) +
geom_raster() +
scale_fill_gradientn(
colours=colorRampPalette(brewer.pal(9,"Blues"))(100)) +
facet_grid( ~ subject.type, labeller=gLabeller) +
theme(
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.margin = unit(1.5, "lines"),
panel.border = element_rect(linetype = "dashed",
size=1, colour = "black", fill=NA),
legend.key.height = unit(2, "lines")
) +
xlab("matching group #") +
ylab("feature") +
labs(fill=valueName)
return(p)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.