#' Plot EDY objects.
#'
#' @title Plot EDY objects
#' @param x An EDY object generated by the function \code{getEDY}.
#'
#' @import ggplot2
#' @export plot.EDY
#' @return A scatter plot in which \code{y axis} represents mean gene expression
#' in chromosome Y divided by mean gene expression in the rest of the genome
#' and each dot represents an individual. Individuals with extreme
#' downregulation of chromosome Y are coloured in light blue and labeled
#' with their identifiers. Normal individuals are coloured in red. The dashed
#' line indicates the threshold from which down EDY is considered.
plot.EDY <- function(x, ...){
edy <- data.frame(x$EDYcontinuous, 1:length(x$EDYcontinuous))
ggplot(edy, aes(x = edy[,2], y = edy[,1], color = x$EDY)) +
geom_point(size = 1.5) +
labs( y = "Gene expression ChrY / Autosomes", x = "Individuals") +
theme(plot.title = element_text(hjust = 0.5), axis.text.x = element_blank(),
axis.ticks.x = element_blank(), legend.title = element_blank()) +
scale_colour_discrete(labels=c("normal", "EDY")) +
scale_y_continuous(breaks = pretty(edy[,1], n = 5)) +
geom_text(aes(label = ifelse(edy[,1] < x$threshold, as.character(rownames(edy)), '')), hjust = 0,
vjust = 1, size = 3) +
geom_hline(yintercept = x$threshold, linetype = "dashed")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.