#' @import ggplot2
#' @title Plot the reference and pair distributions.
#'
#' @param reference A reference distribution generated by one of the reference functions.
#' @param results A results table generated by one of the relatedness functions.
#' @export
plotScoresDensity <- function(reference, results){
names(reference) <- rep("Reference", length(reference))
pair_scores <- results$pair_scores
names(pair_scores) <- rep("Pairs", length(pair_scores))
toplot <- as.data.table(c(pair_scores, reference), keep.rownames = TRUE)
names(toplot) <- c("Distribution", "Score")
plot <- ggplot(toplot, aes(x = Score, colour = Distribution)) + geom_density(size = 1) + scale_colour_brewer(palette = "Set1") +
geom_hline(yintercept = 0, size = 1) + geom_vline(xintercept = 0, size = 1) + geom_vline(xintercept = quantile(reference, probs = 0.95), size = 0.5, linetype = 2) + ylab("Density")
return(plot)
}
#' @title Plot the reference and pair histograms.
#'
#' @param reference A reference distribution generated by one of the reference functions.
#' @param results A results table generated by one of the relatedness functions.
#' @export
plotScoresHistogram <- function(reference, results){
names(reference) <- rep("Reference", length(reference))
pair_scores <- results$pair_scores
names(pair_scores) <- rep("Pairs", length(pair_scores))
toplot <- as.data.table(c(pair_scores, reference), keep.rownames = TRUE)
names(toplot) <- c("Distribution", "Score")
plot <- ggplot(toplot, aes(x = Score, fill = Distribution, y = ..density..)) + geom_histogram(position = "dodge", binwidth = 0.05) + scale_color_brewer(palette = "Set1") +
geom_hline(yintercept = 0, size = 1) + geom_vline(xintercept = 0, size = 1) + scale_x_continuous(limits = c(-0.1,1.1), breaks = seq(0,1,0.1), expand = expand_scale()) + ylab("Density")
return(plot)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.