count_retained_clones.Rd
This function calculates the number of clones with at least a specified number of cells. Clones with fewer cells than the threshold are excluded from the count.
count_retained_clones(count_data, thresholds, count_column, grouping_col = NA)
A data.table where each row corresponds to a clone barcode.
A numeric vector listing the minimum cell counts required for a clone to be included in the count. The calculation will be applied for each value in the vector.
A character indicating the column storing the count of the clone barcodes.
A character string, default NA. If provided, the function repeats the calculation for each subsets of `count_data` defined by this column, effectively a group-by operation.
A data.table containing the counts of clones that meet or exceed the specified threshold.
library(data.table)
toy_clone_counts <- data.table(
sample_name = c(rep("test1", 2), rep("test2", 3)),
clone_barcode = c("A", "B", "C", "D", "E"),
read_count = c(1, 5, 10, 15, 20)
)
count_retained_clones(
count_data = toy_clone_counts,
thresholds = c(2, 10),
count_column = "read_count",
grouping_col = "sample_name"
)
#> sample_name at_least_2_cells at_least_10_cells
#> 1: test1 1 0
#> 2: test2 3 3