knitr::opts_chunk$set(error = TRUE)

Input

Load the AutoPlate R library

# install.packages("devtools")
# devtools::install_github("PhilPalmer/AutoPlate", dependencies = TRUE)
library(autoplate)

Title

platelist_file <- "pmn_platelist.csv"
assay_df <- utils::read.csv(platelist_file, header = TRUE, stringsAsFactors = FALSE, check.names = FALSE)
# Fix column types
assay_df <- update_col_types(assay_df, example_data_column_descriptions)
init_title(assay_df, full_title = TRUE)

Let's take a look at the data

knitr::kable(head(assay_df, 3))

Dimensions before exclusion

paste0("Rows: ", dim(assay_df)[1], ", Columns: ", dim(assay_df)[2])

Dimensions after exclusion

data <- dplyr::filter(assay_df, exclude == FALSE)
paste0("Rows: ", dim(data)[1], ", Columns: ", dim(data)[2])

Number of wells excluded

dim(assay_df)[1] - dim(data)[1]

Quality Control

Average Virus + Cell Luminescence

av_lum_df <- init_av_lum_df(assay_df)
knitr::kable(av_lum_df)

Heatmaps for The 96 Well Plate(s)

features <- c("Types", "Sample ID", "Dilution", "Virus", "RLU", "Neutralisation", "Treatment", "Experiment ID", "Bleed", "Exclude")
plates <- sort(unique(assay_df$plate_number))

for (feature in features) {
  for (plate in plates) {
    plot_heatmap(plate, assay_df, gsub(" ", "_", tolower(feature), fixed = TRUE), feature)
  }
}

Types boxplot

# Preprocessing
boxplot_data <- data %>%
  dplyr::mutate(types = ifelse((types == "c"), "cell", types)) %>%
  dplyr::mutate(types = ifelse((types == "m"), "monoclonal antibody", types)) %>%
  dplyr::mutate(types = ifelse((types == "v"), "virus", types)) %>%
  dplyr::mutate(types = ifelse((types == "x"), "serum sample", types))
boxplot_data$plate_number <- as.factor(boxplot_data$plate_number)

# Generate plot
types_boxplot <- init_types_boxplot(boxplot_data)
plotly::ggplotly(types_boxplot) %>% plotly::layout(boxmode = "group")

Results

Data Exploration

# Preprocessing
data <- dplyr::filter(data, types %in% c("x", "m"))

# Generate plot
data_exploration_plot <- plot_data_exploration(data)
suppressWarnings(plotly::ggplotly(data_exploration_plot))

DRM model

drm_model <- params$drm_model
drm_model

Dose Response Curve(s)

# Produce a seperate plot for each virus
htmltools::tagList(lapply(unique(data$virus), function(virus_to_plot) {
  # Preprocessing
  data <- dplyr::filter(assay_df, types %in% c("x", "m"), exclude == FALSE, virus == virus_to_plot)
  model <- eval(parse(text = paste("drc::drm(", drm_model, ")")))
  # Generate plot
  drc_plot <- plot_drc(data, model)
  suppressWarnings(plotly::ggplotly(drc_plot))
}))

Individual Effective Dose (IED) Table(s)

# Generate ied tables and ic50 boxplots
ic50_boxplots <- htmltools::tagList()
for (virus_to_plot in unique(data$virus)) {
  # Preprocessing
  data <- dplyr::filter(assay_df, types %in% c("x", "m"), exclude == FALSE, virus == virus_to_plot)
  model <- eval(parse(text = paste("drc::drm(", drm_model, ")")))
  # Generate plot
  suppressWarnings(ic50 <- plot_ic50_boxplot(data, model))
  ic50_boxplots[[virus_to_plot]] <- plotly::ggplotly(ic50$ic50_boxplot)
  print(knitr::kable(ic50$ied))
}

IC50 Boxplot(s)

ic50_boxplots

Virus + Cell Boxplot

# Preprocessing
boxplot_data <- dplyr::filter(boxplot_data, types %in% c("cell", "virus"))

# Generate plot
cv_boxplot <- plot_cv_boxplot(boxplot_data)
suppressWarnings(plotly::ggplotly(cv_boxplot) %>% plotly::layout(boxmode = "group"))

Session Info for Reproducibility

sessionInfo()


PhilPalmer/AutoPlate documentation built on Dec. 18, 2021, 7:41 a.m.