#' @title Generate a scatter plot showing the balance between abundant and specific gene expression
#' @description This function takes the output from GlowwormGlobal and generates a
#' scatter plot
#' @param GlowwormOutput Output from GlowwormScale
#' @param TopLabels A numeric value indicating how many of the most specific and abundant genes to label.
#' This value is used on both specificity and abundance and these numbers may overlap. Default is 0.
#' @return
#' @export
GlowwormOutputScatter = function(GlowwormOutput, TopLabels = 0){
if("SumStatsGlobal" %in% names(GlowwormOutput)){
if(TopLabels == 0){
SumStats = GlowwormOutput[["SumStatsGlobal"]]
SumStats_Recombo = SumStats
SumStats_Recombo$Name = NA
}else{
SumStats = GlowwormOutput[["SumStatsGlobal"]]
SumStats_TopTotal = SumStats %>% top_n(TopLabels, Total)
SumStats_TopSD = SumStats %>% top_n(TopLabels, SD)
SumStats_Labelled = subset(SumStats, row.names(SumStats) %in% c(row.names(SumStats_TopSD), row.names(SumStats_TopTotal)))
SumStats_Labelled$Name = row.names(SumStats_Labelled)
SumStats_Unlabelled = subset(SumStats, ! (row.names(SumStats) %in% c(row.names(SumStats_TopSD), row.names(SumStats_TopTotal))))
SumStats_Unlabelled <- SumStats_Unlabelled %>% add_column(Name = NA)
SumStats_Recombo = rbind(SumStats_Labelled, SumStats_Unlabelled)
}
ScatterPlot = ggplot(SumStats_Recombo, aes(x = Total, y=SD, label = Name)) + geom_point() + theme_light() + ylab("Specificity (SD)") + xlab("Abundance (Total)")+geom_text(aes(label=Name),hjust=0, vjust=0)
}else{
stop("Need to run GlowwormGlobal")
}
return(ScatterPlot)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.