Combines gRNAs that target the same site into a single "combined" gRNA via addition of the expression levels.

combine_gRNAs(gRNA_matrix, site_table)

Arguments

gRNA_matrix

a gRNA-by-cell expression matrix; the row names should be gRNA IDs

site_table

a data frame with column names "site" and "gRNA_id". The "site" column should give the target site of each gRNA ID

Value

a "collapsed" gRNA-by-cell expression matrix, where gRNAs that target the same site have been collapsed into a single row (via addition of the constituent gRNAs)

Details

Combining gRNAs that target the same site helps to increase statistical power. This operation is especially appealing when gRNA expression levels are low or there are not a lot of (e.g., < 100,000) cells.

Examples

library(magrittr)
library(Matrix)
library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union

# 1. First example
data(gRNA_matrix)
data(site_table)
combined_gRNA_matrix <- combine_gRNAs(gRNA_matrix, site_table)

# 2. Second example
# Here we group only the gRNAs that target sites "chr10:17457016-17457416"
# and "chr18:48566684-48567084;" all others remain ungrouped
site_table_2 <- site_table %>%
filter(site %in% c("chr10:17457016-17457416", "chr18:48566684-48567084"))
combined_gRNA_matrix_2 <- combine_gRNAs(gRNA_matrix, site_table_2)