R/getLorenz.R

Defines functions getLorenz

Documented in getLorenz

#' Calculate Lorenz curve
#'
#' Calculate a Lorenz curve derived from the frequency of the amino acid
#' sequences.
#'
#' @param sample_table A tibble for a single repertoire_id generated using the
#'  LymphoSeq function [readImmunoSeq()] or [productiveSeq()].
#'  The table should contain the "duplicate_frequency" column.
#' @return Returns a Lorenz curve tibble.
#' @export
getLorenz <- function(sample_table) {
  repertoire_id <- sample_table$repertoire_id[1]
  lc <- ineq::Lc(sample_table$duplicate_frequency)
  lctbl <- tibble::tibble(L = lc$L, p = lc$p) |>
    dplyr::mutate(repertoire_id = repertoire_id)
  return(lctbl)
}
shashidhar22/LymphoSeq2 documentation built on Jan. 16, 2024, 4:29 a.m.