Combines perturbations by collapsing gRNAs within the same group into a single "combined" gRNA.

combine_perturbations(perturbation_matrix, gRNA_groups_table)

Arguments

perturbation_matrix

a perturbation matrix (i.e., a binary matrix of gRNA-to-cell assignments) stored as a sparse matrix (as implemented by the Matrix package) or a dense matrix (as implemented by base R); the row names should be the gRNA IDs.

gRNA_groups_table

a data frame with columns gRNA_id and gRNA_group, mapping each gRNA to its gRNA group

Value

a "combined" perturbation matrix, where gRNAs within the same gRNA group have been collapsed into a single row

Details

The function combines binary (i.e., 0/1) perturbation vectors via a "max" operation. In other words, if x1, x2, ..., xp are binary perturbation vectors, then the "combined" perturbation vector v is v = pmax(x1, x2, ..., xp), where pmax is the element-wise maximum function.

Examples

library(Matrix)
data("gRNA_matrix")
data("gRNA_groups_table")
perturbation_matrix <- threshold_gRNA_matrix(gRNA_matrix)
combined_perturbation_matrix <- combine_perturbations(perturbation_matrix, gRNA_groups_table)