#' plot cell count by batch variables as a density plot
#'
#'@param well_scores tibble::tibble as output by read_well_scores
#'@param subtitle plot subtitle, typically the study identifier
#'@return ggplot2 object with the lattice plot with a panel for each batch variable
#'
#'@export
plot_score_by_batch_vars_density <- function(well_scores, subtitle=NULL){
data <- well_scores %>%
dplyr::filter(!is_control) %>%
dplyr::select(
week, plate, row, # batch variables
prob_positive)%>% # response values
tidyr::pivot_longer(
cols=c("week", "plate", "row"),
names_to="batch_variable",
values_to="batch_value")
p <- ggplot2::ggplot(data=data) +
ggplot2::theme_bw() +
ggplot2::geom_density(
mapping=ggplot2::aes(
x=prob_positive,
y=log10(..density..+1),
color=batch_value,
group=batch_value)) +
ggplot2::facet_wrap(
facets=ggplot2::vars(batch_variable),
scales="free_x") +
ggplot2::facet_wrap(
facets=ggplot2::vars(batch_variable)) +
ggplot2::scale_x_continuous(
"Score",
limits=c(0,1),
labels=scales::percent_format()) +
ggplot2::scale_y_continuous("log(Density+1)") +
ggplot2::scale_color_continuous("Batch Value") +
ggplot2::ggtitle(
label="Classifier Score by Batch Dimensions",
subtitle=subtitle) +
ggplot2::theme(
legend.position=c(.84,1.13),
legend.direction="horizontal",
legend.margin=ggplot2::margin(t=0,r=0,b=0,l=0),
legend.box.background=ggplot2::element_blank())
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.