assign_grnas: Assign gRNAs to cells

View source: R/s4_analysis_functs_1.R

assign_grnasR Documentation

Assign gRNAs to cells

Description

assign_grnas() performs the gRNA-to-cell assignments. sceptre provides three gRNA-to-cell assignment strategies: the mixture method, the thresholding method, and the maximum method. The mixture method involves assigning gRNAs to cells using a principled mixture model. Next, the thresholding method assigns a gRNA to a cell if the UMI count of the gRNA in the cell is greater than or equal to some integer threshold. Finally, the maximum method assigns the gRNA that accounts for the greatest number of UMIs in a given cell to that cell. The maximum method is available only in low MOI. See Chapter 3 of the manual for more detailed information about assign_grnas().

Usage

assign_grnas(
  sceptre_object,
  method = "default",
  print_progress = TRUE,
  parallel = FALSE,
  n_processors = "auto",
  log_dir = tempdir(),
  ...
)

Arguments

sceptre_object

a sceptre_object

method

(optional) a string indicating the method to use to assign the gRNAs to cells, one of "mixture", "thresholding", or "maximum"

print_progress

(optional; default TRUE) a logical indicating whether to print progress updates

parallel

(optional; default FALSE) a logical indicating whether to run the function in parallel

n_processors

(optional; default "auto") an integer specifying the number of processors to use if parallel is set to TRUE. The default, "auto", automatically detects the number of processors available on the machine.

log_dir

(optional; default tempdir()) a string indicating the directory in which to write the log files (ignored if parallel = FALSE)

...

optional method-specific additional arguments

Value

an updated sceptre_object in which the gRNA assignments have been carried out

Note

See the manual for information about the method-specific additional arguments.

Examples

library(sceptredata)
data("lowmoi_example_data")
# 1. import data, set default analysis parameters
sceptre_object <- import_data(
  response_matrix = lowmoi_example_data$response_matrix,
  grna_matrix = lowmoi_example_data$grna_matrix,
  extra_covariates = lowmoi_example_data$extra_covariates,
  grna_target_data_frame = lowmoi_example_data$grna_target_data_frame,
  moi = "low"
) |> set_analysis_parameters()

# 2. assign gRNAs (three different methods)
sceptre_object <- sceptre_object |> assign_grnas(method = "thresholding")
sceptre_object <- sceptre_object |> assign_grnas(method = "maximum")
sceptre_object <- sceptre_object |> assign_grnas(
  method = "mixture", parallel = TRUE, n_processors = 2
)

timothy-barry/sceptre documentation built on Sept. 27, 2024, 6:49 a.m.