R/pchit_map.R

Defines functions pchit_map

Documented in pchit_map

#' Plots a heatmap identifying hits from the first principal component
#'
#' Converts numerical values  and plate labels intoa plate heatmap
#' with z-scored principal components coloured dependent on a specified
#' threshold of standard deviations above or below the average.
#'
#' @param data Numerical values, either a dataframe or a matrix
#' @param well Vector of well identifers e.g "A01"
#' @param plate Number of wells in complete plate (96, 384 or 1536)
#' @param threshold Threshold of +/- standard deviations form the average
#'     to determine a hit
#' @param palette RColorBrewer palette
#' @param ... additional arguments to platetools::hit_map
#'
#' @return ggplot plot
#'
#' @import ggplot2
#'
#' @export
#'
#' @examples
#' v1 <- rnorm(1:96)
#' v2 <- rnorm(1:96)
#' v3 <- rnorm(1:96)
#' wells <- num_to_well(1:96)
#' df <- data.frame(wells, v1, v2, v3)
#'
#'
#' pchit_map(data = df[, 2:4],
#'           well = df$wells,
#'           threshold = 1.5)


pchit_map <- function(data, well, plate = 96, threshold = 2,
                      palette = "Spectral", ...){

    pca_data <- prcomp(data) # pca of data
    pc1 <- pca_data$x[,1] # take first principal component

    pc_hit_map <- hit_map(pc1, well, plate, threshold, palette, ...)

    return(pc_hit_map)

}

Try the platetools package in your browser

Any scripts or data that you put into this service are public.

platetools documentation built on June 3, 2021, 5:06 p.m.