Normalize a CRISPR count matrix so each sample column sums to one million by
default. Set margin = 1 to normalize rows instead.
Usage
counts_per_million(counts, pseudocount = 0, margin = 2)
Arguments
- counts
Numeric matrix or data frame with guides/features in rows and
samples in columns.
- pseudocount
Non-negative numeric scalar added to every entry before
normalization.
- margin
Integer margin to normalize. Use 2 for columns and 1 for
rows.
Value
A numeric matrix scaled so each selected margin sums to one million.
Examples
counts <- matrix(
c(100, 300, 50, 50),
nrow = 2,
dimnames = list(c("guide_1", "guide_2"), c("sample_a", "sample_b"))
)
counts_per_million(counts)
#> sample_a sample_b
#> guide_1 250000 5e+05
#> guide_2 750000 5e+05