R/stretch_and_shift.R

Defines functions apply_registration

#' Apply registration
#'
#' @param data Input data frame, either containing all replicates of gene expression or not.
#' @param stretches Candidate registration stretch factors to apply to query data.
#' @param shifts Candidate registration shift values to apply to query data.
#'
#' @noRd
apply_registration <- function(data, stretch, shift) {
  # Suppress "no visible binding for global variable" note
  accession <- NULL
  timepoint <- NULL

  data <- data.table::copy(data)

  # Apply registration
  data[, timepoint := as.numeric(timepoint)]
  data[, timepoint := if (accession == "query") timepoint * stretch + shift else timepoint, by = .(accession)]

  return(data)
}

Try the greatR package in your browser

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

greatR documentation built on May 29, 2024, 12:18 p.m.