| Title: | Analysis of Single-Cell CRISPR Screen Data |
|---|---|
| Description: | Analysis of single-cell CRISPR screen data. `sceptre` is an R package for statistically rigorous, massively scalable, and user-friendly single-cell CRISPR screen data analysis. The `sceptre` pipeline consists of several distinct steps: (1) import data from 10X CellRanger, Parse CRISPR Detect, or a set of R objects; (2) set the analysis parameters, which are the parameters that govern how the statistical analysis is to be conducted; (3) assign gRNAs to cells using one of three methods; (4) run quality control; (5) run the calibration check, which is an analysis that verifies that `sceptre` controls the rate of false positives on the dataset under analysis; (6) run the power check, which is an analysis that verifies that `sceptre` is capable of discovering true associations on the dataset under analysis; (7) run the discovery analysis to identify high-confidence perturbation-gene links among the set of perturbations and genes whose association status we do not know but seek to learn; (8) write outputs to a specified directory, including results, plots, and a textual summary of the analysis. `sceptre` leverages several novel statistical and computational algorithms to achieve high statistical accuracy and computational speed. |
| Authors: | Timothy Barry [aut, cre] (ORCID: <https://orcid.org/0000-0002-4356-627X>), Louis Deutsch [aut], Eugene Katsevich [aut] (ORCID: <https://orcid.org/0000-0003-0598-2050>), Wharton Analytics [fnd], National Science Foundation [fnd] (Grants DMS-2113072 and DMS-2310654) |
| Maintainer: | Timothy Barry <[email protected]> |
| License: | GPL-3 |
| Version: | 0.99.0 |
| Built: | 2026-09-30 12:47:21 UTC |
| Source: | https://github.com/BiocStaging/sceptre |
sceptre is an R package for single-cell CRISPR screen data analysis,
emphasizing statistical rigor, massive scalability, and ease of use.
Maintainer: Timothy Barry [email protected] (ORCID)
Authors:
Louis Deutsch
Eugene Katsevich [email protected] (ORCID)
Other contributors:
Wharton Analytics [funder]
National Science Foundation (Grants DMS-2113072 and DMS-2310654) [funder]
Useful links:
Report bugs at https://github.com/Katsevich-Lab/sceptre/issues
########################## # Low-MOI CRISPRko example ########################## # 1. create the sceptre object data("lowmoi_example_data") 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" ) print(sceptre_object) # 2. set the analysis parameters positive_control_pairs <- construct_positive_control_pairs(sceptre_object) discovery_pairs <- construct_trans_pairs( sceptre_object = sceptre_object, positive_control_pairs = positive_control_pairs, pairs_to_exclude = "pc_pairs" ) sceptre_object <- set_analysis_parameters( sceptre_object = sceptre_object, discovery_pairs = discovery_pairs, positive_control_pairs = positive_control_pairs ) print(sceptre_object) # 3. assign grnas plot_grna_count_distributions(sceptre_object) sceptre_object <- sceptre_object |> assign_grnas() plot(sceptre_object) print(sceptre_object) # 4. run qc plot_covariates(sceptre_object, p_mito_threshold = 0.075) sceptre_object <- sceptre_object |> run_qc(p_mito_threshold = 0.075) plot(sceptre_object) print(sceptre_object) # 5. run the calibration check sceptre_object <- run_calibration_check(sceptre_object) plot(sceptre_object) print(sceptre_object) # 6. run power check sceptre_object <- run_power_check(sceptre_object) plot(sceptre_object) print(sceptre_object) # 7. run discovery analysis sceptre_object <- run_discovery_analysis(sceptre_object) plot(sceptre_object) print(sceptre_object) # 8. write results to a directory. tempdir() is used so this example is # self-contained; for a real analysis choose a directory you can find again. output_dir <- file.path(tempdir(), "sceptre_outputs_lowmoi") write_outputs_to_directory( sceptre_object = sceptre_object, directory = output_dir ) message( "sceptre outputs written to a temporary directory; ", 'open with `browseURL("', output_dir, '")`' ) ########################## # High-MOI CRISPRi example ########################## # 1. create the sceptre object from cellranger output directories <- paste0( system.file("extdata", package = "sceptre"), "/highmoi_example/gem_group_", c(1, 2) ) data(grna_target_data_frame_highmoi) sceptre_object <- import_data_from_cellranger( directories = directories, moi = "high", grna_target_data_frame = grna_target_data_frame_highmoi ) print(sceptre_object) # 2. set the analysis parameters positive_control_pairs <- construct_positive_control_pairs(sceptre_object) discovery_pairs <- construct_cis_pairs(sceptre_object, positive_control_pairs = positive_control_pairs, distance_threshold = 5e6 ) sceptre_object <- set_analysis_parameters( sceptre_object = sceptre_object, discovery_pairs = discovery_pairs, positive_control_pairs = positive_control_pairs, side = "left" ) print(sceptre_object) # 3. assign grnas plot_grna_count_distributions(sceptre_object) sceptre_object <- sceptre_object |> assign_grnas() plot(sceptre_object) print(sceptre_object) # 4. run qc plot_covariates(sceptre_object, p_mito_threshold = 0.075) sceptre_object <- sceptre_object |> run_qc(p_mito_threshold = 0.075) plot(sceptre_object) print(sceptre_object) # 5. run the calibration check sceptre_object <- run_calibration_check(sceptre_object) plot(sceptre_object) print(sceptre_object) # 6. run the power check sceptre_object <- run_power_check(sceptre_object) plot(sceptre_object) print(sceptre_object) # 7. run discovery analysis sceptre_object <- run_discovery_analysis(sceptre_object) plot(sceptre_object) print(sceptre_object) # 8. write results to a directory. tempdir() is used so this example is # self-contained; for a real analysis choose a directory you can find again. output_dir <- file.path(tempdir(), "sceptre_outputs_highmoi") write_outputs_to_directory( sceptre_object = sceptre_object, directory = output_dir ) message( "sceptre outputs written to a temporary directory; ", 'open by running `browseURL("', output_dir, '")` in the console.' )########################## # Low-MOI CRISPRko example ########################## # 1. create the sceptre object data("lowmoi_example_data") 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" ) print(sceptre_object) # 2. set the analysis parameters positive_control_pairs <- construct_positive_control_pairs(sceptre_object) discovery_pairs <- construct_trans_pairs( sceptre_object = sceptre_object, positive_control_pairs = positive_control_pairs, pairs_to_exclude = "pc_pairs" ) sceptre_object <- set_analysis_parameters( sceptre_object = sceptre_object, discovery_pairs = discovery_pairs, positive_control_pairs = positive_control_pairs ) print(sceptre_object) # 3. assign grnas plot_grna_count_distributions(sceptre_object) sceptre_object <- sceptre_object |> assign_grnas() plot(sceptre_object) print(sceptre_object) # 4. run qc plot_covariates(sceptre_object, p_mito_threshold = 0.075) sceptre_object <- sceptre_object |> run_qc(p_mito_threshold = 0.075) plot(sceptre_object) print(sceptre_object) # 5. run the calibration check sceptre_object <- run_calibration_check(sceptre_object) plot(sceptre_object) print(sceptre_object) # 6. run power check sceptre_object <- run_power_check(sceptre_object) plot(sceptre_object) print(sceptre_object) # 7. run discovery analysis sceptre_object <- run_discovery_analysis(sceptre_object) plot(sceptre_object) print(sceptre_object) # 8. write results to a directory. tempdir() is used so this example is # self-contained; for a real analysis choose a directory you can find again. output_dir <- file.path(tempdir(), "sceptre_outputs_lowmoi") write_outputs_to_directory( sceptre_object = sceptre_object, directory = output_dir ) message( "sceptre outputs written to a temporary directory; ", 'open with `browseURL("', output_dir, '")`' ) ########################## # High-MOI CRISPRi example ########################## # 1. create the sceptre object from cellranger output directories <- paste0( system.file("extdata", package = "sceptre"), "/highmoi_example/gem_group_", c(1, 2) ) data(grna_target_data_frame_highmoi) sceptre_object <- import_data_from_cellranger( directories = directories, moi = "high", grna_target_data_frame = grna_target_data_frame_highmoi ) print(sceptre_object) # 2. set the analysis parameters positive_control_pairs <- construct_positive_control_pairs(sceptre_object) discovery_pairs <- construct_cis_pairs(sceptre_object, positive_control_pairs = positive_control_pairs, distance_threshold = 5e6 ) sceptre_object <- set_analysis_parameters( sceptre_object = sceptre_object, discovery_pairs = discovery_pairs, positive_control_pairs = positive_control_pairs, side = "left" ) print(sceptre_object) # 3. assign grnas plot_grna_count_distributions(sceptre_object) sceptre_object <- sceptre_object |> assign_grnas() plot(sceptre_object) print(sceptre_object) # 4. run qc plot_covariates(sceptre_object, p_mito_threshold = 0.075) sceptre_object <- sceptre_object |> run_qc(p_mito_threshold = 0.075) plot(sceptre_object) print(sceptre_object) # 5. run the calibration check sceptre_object <- run_calibration_check(sceptre_object) plot(sceptre_object) print(sceptre_object) # 6. run the power check sceptre_object <- run_power_check(sceptre_object) plot(sceptre_object) print(sceptre_object) # 7. run discovery analysis sceptre_object <- run_discovery_analysis(sceptre_object) plot(sceptre_object) print(sceptre_object) # 8. write results to a directory. tempdir() is used so this example is # self-contained; for a real analysis choose a directory you can find again. output_dir <- file.path(tempdir(), "sceptre_outputs_highmoi") write_outputs_to_directory( sceptre_object = sceptre_object, directory = output_dir ) message( "sceptre outputs written to a temporary directory; ", 'open by running `browseURL("', output_dir, '")` in the console.' )
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 assigns gRNAs
by thresholding fitted posterior membership probabilities. 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().
assign_grnas( sceptre_object, method = "default", print_progress = TRUE, parallel = FALSE, n_processors = "auto", log_dir = tempdir(), ... )assign_grnas( sceptre_object, method = "default", print_progress = TRUE, parallel = FALSE, n_processors = "auto", log_dir = tempdir(), ... )
sceptre_object |
a |
method |
(optional) a string indicating the method to use to assign the
gRNAs to cells, one of |
print_progress |
(optional; default |
parallel |
(optional; default |
n_processors |
(optional; default |
log_dir |
(optional; default |
... |
optional method-specific additional arguments |
an updated sceptre_object in which the gRNA assignments have been
carried out
The "mixture" method retains the historical fitting algorithm used
in sceptre version 0.9.0 and later. Owing to an implementation
inconsistency, the perturbation parameter is estimated under a multiplicative
parameterization but applied additively in the subsequent E-step. The
resulting parameter estimates therefore do not maximize the likelihood of
the mixture model used to compute the fitted probabilities. The historical
implementation is retained because it has performed well in benchmarks. This
limitation affects only "mixture";
"maximum" and "thresholding" are unaffected. We plan to replace the
historical mixture implementation after a
statistically coherent and empirically validated alternative is available.
Any change to the public API or high-MOI default will follow that validation.
Progress is tracked in
GitHub issue #220.
See the manual for information about the method-specific additional
arguments.
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")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")
construct_cis_pairs() is a helper function to facilitate construction the
cis pairs. construct_cis_pairs() returns the set of target-response pairs
for which the target and response are located on the same chromosome and in
close physical proximity to one another. construct_cis_pairs() is a useful
pair constructor function for screens that aim to map noncoding regulatory
elements (e.g., enhancers or noncoding GWAS variants) to target genes in
cis. construct_cis_pairs() assumes that the columns chr, start, and
stop are present in the grna_target_data_frame, giving the chromosome,
start position, and end position, respectively, of the region that each gRNA
targets. construct_cis_pairs() takes several arguments: sceptre_object
(required), distance_threshold (optional), positive_control_pairs
(optional), and response_position_data_frame (optional). By default,
construct_cis_pairs() pairs each gRNA target to the set of responses on the
same chromosome as that target and within distance_threshold bases of that
target. (The default value of distance_threshold is 500,000 bases, or half
a megabase.) The positive_control_pairs data frame optionally can be passed
to construct_cis_pairs(), in which case the positive control targets (i.e.,
the entries within the grna_target column of positive_control_pairs) are
excluded from the cis pairs. One may want to exclude these from the
discovery analysis if these targets are intended for positive control
purposes only. See
Section 2.2.2 of the manual
for more detailed information about this function.
construct_cis_pairs( sceptre_object, positive_control_pairs = data.frame(), distance_threshold = 500000L, response_position_data_frame = NULL )construct_cis_pairs( sceptre_object, positive_control_pairs = data.frame(), distance_threshold = 500000L, response_position_data_frame = NULL )
sceptre_object |
a |
positive_control_pairs |
(optional) a data frame with columns
|
distance_threshold |
(optional) target-response pairs located within
|
response_position_data_frame |
(optional) a data frame with columns
|
a data frame with columns grna_target and response_id containing
the cis pairs
data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) positive_control_pairs <- construct_positive_control_pairs(sceptre_object) discovery_pairs <- construct_cis_pairs(sceptre_object, positive_control_pairs = positive_control_pairs, distance_threshold = 5e6 )data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) positive_control_pairs <- construct_positive_control_pairs(sceptre_object) discovery_pairs <- construct_cis_pairs(sceptre_object, positive_control_pairs = positive_control_pairs, distance_threshold = 5e6 )
construct_positive_control_pairs() is a helper function to facilitate
construction of the positive control pairs. Positive control pairs are
target-response pairs for which we know (or have strong reason to believe)
that there is a regulatory relationship between the target and the response.
We can use positive control pairs to verify that sceptre is sensitive
(i.e., capable of detecting true associations) on the dataset under analysis.
construct_positive_control_pairs() takes as an argument a sceptre_object
and returns a data frame with columns grna_target and response_id, where
gRNA targets and response IDs with matching names are paired. Typically, the
positive control set consists of transcription start sites paired to the gene
regulated by those transcription start sites. See
Section 2.2 in the manual
for more detailed information about this function.
construct_positive_control_pairs(sceptre_object)construct_positive_control_pairs(sceptre_object)
sceptre_object |
a |
a data frame with columns grna_target and response_id containing
the positive control pairs
data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) positive_control_pairs <- construct_positive_control_pairs(sceptre_object)data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) positive_control_pairs <- construct_positive_control_pairs(sceptre_object)
construct_trans_pairs() is a helper function to facilitate construction the
set of trans pairs. construct_trans_pairs() returns the entire set of
possible target-response pairs. construct_trans_pairs() is a useful pair
constructor function for analyses in which we seek to conduct a trans
analysis, testing each target against each response.
construct_trans_pairs() takes as arguments sceptre_object (required),
positive_control_pairs (optional), and pairs_to_exclude (optional). By
default construct_trans_pairs() returns a data frame with columns
grna_target and response_id, where each gRNA target is mapped to each
response ID.
construct_trans_pairs( sceptre_object, positive_control_pairs = data.frame(), pairs_to_exclude = "none" )construct_trans_pairs( sceptre_object, positive_control_pairs = data.frame(), pairs_to_exclude = "none" )
sceptre_object |
a |
positive_control_pairs |
(optional) the set of positive control pairs |
pairs_to_exclude |
(optional; default |
The optional argument pairs_to_exclude enables the user to remove specific
pairs from the trans set and takes values "none", "pc_pairs", or
"pairs_containing_pc_targets". If pairs_to_exclude is set to "none"
(the default), then no pairs are removed from the trans set. Next, if
pairs_to_exclude is set to "pc_pairs" (and the positive_control_pairs
data frame is passed), then then the positive control target-response pairs
are excluded from the trans set. Finally, if pairs_to_exclude is set to
"pairs_containing_pc_targets" (and positive_control_pairs is passed),
then all pairs containing a positive control gRNA target are excluded from
the trans pairs. (In this sense setting pairs_to_exclude to
"pairs_containing_pc_targets" is stronger than setting pairs_to_exclude
to "pc_pairs".) Typically, in gene-targeting (resp.,
noncoding-regulatory-element-targeting) screens, we set pairs_to_exclude to
"pc_pairs" (resp., "pairs_containing_pc_targets"). See
Section 2.2.2 of the manual
for more detailed information about this function.
a data frame with columns grna_target and response_id containing
the trans discovery set
# 1. low-moi, gene-targeting screen data("lowmoi_example_data") 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" ) positive_control_pairs <- construct_positive_control_pairs(sceptre_object) discovery_pairs <- construct_trans_pairs( sceptre_object = sceptre_object, positive_control_pairs = positive_control_pairs, pairs_to_exclude = "pc_pairs" ) # 2. high-moi, enhancer-targeting screen data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) positive_control_pairs <- construct_positive_control_pairs(sceptre_object) discovery_pairs <- construct_trans_pairs( sceptre_object = sceptre_object, positive_control_pairs = positive_control_pairs, pairs_to_exclude = "pairs_containing_pc_targets" )# 1. low-moi, gene-targeting screen data("lowmoi_example_data") 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" ) positive_control_pairs <- construct_positive_control_pairs(sceptre_object) discovery_pairs <- construct_trans_pairs( sceptre_object = sceptre_object, positive_control_pairs = positive_control_pairs, pairs_to_exclude = "pc_pairs" ) # 2. high-moi, enhancer-targeting screen data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) positive_control_pairs <- construct_positive_control_pairs(sceptre_object) discovery_pairs <- construct_trans_pairs( sceptre_object = sceptre_object, positive_control_pairs = positive_control_pairs, pairs_to_exclude = "pairs_containing_pc_targets" )
gene_position_data_frame_grch38 and gene_position_data_frame_grch37
contain the coordinate and transcription start site position of each gene
relative to reference genome GRCh38 and GRCh37, respectively. Both
gene_position_data_frame_grch38 and gene_position_data_frame_grch37 were
constructed from reference genomes available on the 10x Genomics website. The
GRCh38 reference genome has been used by 10x Cell Ranger since 2020.
data(gene_position_data_frame_grch38) data(gene_position_data_frame_grch37)data(gene_position_data_frame_grch38) data(gene_position_data_frame_grch37)
An object of class data.table (inherits from data.frame) with 36572 rows and 4 columns.
An object of class data.table (inherits from data.frame) with 57773 rows and 4 columns.
data(gene_position_data_frame_grch38) data(gene_position_data_frame_grch37) head(gene_position_data_frame_grch38) head(gene_position_data_frame_grch37)data(gene_position_data_frame_grch38) data(gene_position_data_frame_grch37) head(gene_position_data_frame_grch38) head(gene_position_data_frame_grch37)
get_grna_assignments() returns the gRNA-to-cell assignments contained
within a sceptre_object. The output is a sparse logical matrix, with gRNAs
in the rows and cells in the columns. A given entry of the matrix is set to
TRUE if the given gRNA is assigned to the given cell (and FALSE
otherwise).
get_grna_assignments(sceptre_object, apply_cellwise_qc = FALSE)get_grna_assignments(sceptre_object, apply_cellwise_qc = FALSE)
sceptre_object |
a |
apply_cellwise_qc |
a logical value (i.e., |
When using the "maximum" assignment strategy, exactly one gRNA is assigned to a given cell. In other words, each column of the gRNA-to-cell assignment matrix contains exactly one TRUE entry.
a sparse logical matrix containing the gRNA-to-cell assignments
data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) discovery_pairs <- construct_cis_pairs(sceptre_object) sceptre_object <- sceptre_object |> set_analysis_parameters( discovery_pairs = discovery_pairs, side = "left" ) |> assign_grnas(method = "mixture") |> run_qc() grna_assignment_matrix <- get_grna_assignments( sceptre_object = sceptre_object ) grna_assignment_matrix_with_qc <- get_grna_assignments( sceptre_object = sceptre_object, apply_cellwise_qc = TRUE )data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) discovery_pairs <- construct_cis_pairs(sceptre_object) sceptre_object <- sceptre_object |> set_analysis_parameters( discovery_pairs = discovery_pairs, side = "left" ) |> assign_grnas(method = "mixture") |> run_qc() grna_assignment_matrix <- get_grna_assignments( sceptre_object = sceptre_object ) grna_assignment_matrix_with_qc <- get_grna_assignments( sceptre_object = sceptre_object, apply_cellwise_qc = TRUE )
The data getter functions (i.e., get_response_matrix(),
get_grna_matrix(), get_cell_covariates()) return of a specified data
field from a sceptre_object.
get_response_matrix(sceptre_object) get_grna_matrix(sceptre_object) get_cell_covariates(sceptre_object)get_response_matrix(sceptre_object) get_grna_matrix(sceptre_object) get_cell_covariates(sceptre_object)
sceptre_object |
a |
get_response_matrix() returns the response matrix contained within a
sceptre_object.
get_grna_matrix() returns the gRNA matrix contained within a
sceptre_object.
get_cell_covariates() returns the cell covariate data frame contained
within a sceptre_object.
# 1. create a sceptre_object data(highmoi_example_data) data(grna_target_data_frame_highmoi) sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) # 2. extract data fields from the sceptre_object response_matrix <- get_response_matrix(sceptre_object) grna_matrix <- get_grna_matrix(sceptre_object) cell_covariates <- get_cell_covariates(sceptre_object)# 1. create a sceptre_object data(highmoi_example_data) data(grna_target_data_frame_highmoi) sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) # 2. extract data fields from the sceptre_object response_matrix <- get_response_matrix(sceptre_object) grna_matrix <- get_grna_matrix(sceptre_object) cell_covariates <- get_cell_covariates(sceptre_object)
get_result() returns a data frame containing the result of a calibration
check, power check, or discovery analysis. We pass as arguments
sceptre_object and analysis, where the latter is a string indicating the
function whose results we are querying. The output is a data frame, the rows
of which correspond to target-response pairs, and the columns of which are as
follows: response_id, grna_target, n_nonzero_trt, n_nonzero_cntrl,
pass_qc (a TRUE/FALSE value indicating whether the pair passes pairwise
QC), p_value, fold_change, se_fold_change (standard error for the fold
change estimate), log_2_fold_change, and significant (a TRUE/FALSE
value indicating whether the pair is called as significant). The p-value
contained within the p_value column is a raw (i.e.,
non-multiplicity-adjusted) p-value. See
Section 8 of the introductory chapter in the manual
for more information about this function.
get_result(sceptre_object, analysis)get_result(sceptre_object, analysis)
sceptre_object |
a |
analysis |
a string indicating the name of the analysis whose results we
are querying, one of |
a data frame containing the results of the analysis
If output_amount is set to 2 or 3 in run_calibration_check(),
run_power_check(), or run_discovery_analysis(), then the result data
frame contains additional columns; see
Chapter 6 in the manual
for more information.
data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) positive_control_pairs <- construct_positive_control_pairs(sceptre_object) pc_result <- sceptre_object |> set_analysis_parameters( side = "left", resampling_mechanism = "permutations", positive_control_pairs = positive_control_pairs ) |> assign_grnas(method = "thresholding") |> run_qc() |> run_power_check() |> get_result("run_power_check")data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) positive_control_pairs <- construct_positive_control_pairs(sceptre_object) pc_result <- sceptre_object |> set_analysis_parameters( side = "left", resampling_mechanism = "permutations", positive_control_pairs = positive_control_pairs ) |> assign_grnas(method = "thresholding") |> run_qc() |> run_power_check() |> get_result("run_power_check")
The gRNA target data frame corresponding to the example high MOI data. The
data frame contains the columns grna_id (ID of an individual gRNA),
grna_target (genomic target of the gRNA), chr (target chromosome),
start (start coordinate of target location), and end (end coordinate of
target location).
data(grna_target_data_frame_highmoi)data(grna_target_data_frame_highmoi)
An object of class data.frame with 60 rows and 5 columns.
The example high-MOI CRISPRi data are a small simulated dataset modeled on that of "A genome-wide framework for mapping gene regulation via cellular genetic screens" by Gasperini et al., 2019. These data contain perturbations both of gene transcription start sites (TSSs) and enhancers, as well as non- targeting perturbations.
data(highmoi_example_data)data(highmoi_example_data)
An object of class list of length 4.
The example data are stored in a list containing the following components:
response_matrix: the gene-by-cell expression matrix
grna_matrix: the gRNA-by-cell expression matrix
extra_covariates: a data frame containing a single column, batch,
specifying the batch in which each cell was sequenced (batch_1 or
batch_2); the row names give the cell IDs and match the matrix column names
gene_names: the human-readable name of each gene
import_data() imports data from a collection of R objects to create a
sceptre_object. Users can create either a standard sceptre object or an
ondisc-backed sceptre object; the latter is more appropriate for
large-scale data. See
Chapter 1 of the manual
for more detailed information about this function.
import_data( response_matrix, grna_matrix, grna_target_data_frame, moi, extra_covariates = data.frame(), response_names = NA_character_, use_ondisc = FALSE, directory_to_write = NULL )import_data( response_matrix, grna_matrix, grna_target_data_frame, moi, extra_covariates = data.frame(), response_names = NA_character_, use_ondisc = FALSE, directory_to_write = NULL )
response_matrix |
a matrix of response UMI counts, with responses in
rows and cells in columns. The matrix should be of type |
grna_matrix |
a matrix of gRNA UMI counts, with gRNAs in rows and cells
in columns. The matrix should be of type |
grna_target_data_frame |
a data frame containing columns |
moi |
a string indicating the MOI of the dataset, either "low" or "high". |
extra_covariates |
(optional) a data frame containing extra covariates
(e.g., batch, biological replicate) beyond those that |
response_names |
(optional) a vector of human-readable response names;
names with the prefix "MT-" are taken as mitochondrial genes and are used to
compute the covariate |
use_ondisc |
(default |
directory_to_write |
(optional) a file path to a directory in which to
write the backing |
an initialized sceptre_object
data("lowmoi_example_data") # 1. initialize a standard sceptre_object from R objects sceptre_object <- import_data( response_matrix = lowmoi_example_data$response_matrix, grna_matrix = lowmoi_example_data$grna_matrix, grna_target_data_frame = lowmoi_example_data$grna_target_data_frame, extra_covariates = lowmoi_example_data$extra_covariates, moi = "low" ) # 2. initialize an ondisc-backed sceptre_object from R objects sceptre_object <- import_data( response_matrix = lowmoi_example_data$response_matrix, grna_matrix = lowmoi_example_data$grna_matrix, grna_target_data_frame = lowmoi_example_data$grna_target_data_frame, extra_covariates = lowmoi_example_data$extra_covariates, moi = "low", use_ondisc = TRUE, directory_to_write = tempdir() )data("lowmoi_example_data") # 1. initialize a standard sceptre_object from R objects sceptre_object <- import_data( response_matrix = lowmoi_example_data$response_matrix, grna_matrix = lowmoi_example_data$grna_matrix, grna_target_data_frame = lowmoi_example_data$grna_target_data_frame, extra_covariates = lowmoi_example_data$extra_covariates, moi = "low" ) # 2. initialize an ondisc-backed sceptre_object from R objects sceptre_object <- import_data( response_matrix = lowmoi_example_data$response_matrix, grna_matrix = lowmoi_example_data$grna_matrix, grna_target_data_frame = lowmoi_example_data$grna_target_data_frame, extra_covariates = lowmoi_example_data$extra_covariates, moi = "low", use_ondisc = TRUE, directory_to_write = tempdir() )
import_data_from_cellranger() imports data from the output of one or more
calls to Cell Ranger count. Each directory supplied as an input to this
function should be in feature-barcode format, containing the files
features.tsv.gz and matrix.mtx.gz (and optionally barcodes.tsv.gz).
For standard in-memory objects, when every supplied directory contains a
barcode file, the cell barcodes are retained as the column names of the
response and gRNA matrices and the row names of the cell covariate data frame.
When multiple directories are supplied, the retained cell barcodes are
prefixed with their batch identifiers (for example, b1_ and b2_) to keep
the cell IDs unique and stable across imports.
Supplying barcode files for only some directories is an error.
Users can create either a standard sceptre object or an ondisc-backed
sceptre object; the latter is more appropriate for large-scale data. See
the introductory chapter
or
Chapter 1
of the manual for more information about this function.
import_data_from_cellranger( directories, moi, grna_target_data_frame, extra_covariates = data.frame(), use_ondisc = FALSE, directory_to_write = NULL )import_data_from_cellranger( directories, moi, grna_target_data_frame, extra_covariates = data.frame(), use_ondisc = FALSE, directory_to_write = NULL )
directories |
a character vector of file paths to directories containing
the output of one or more calls to Cell Ranger count. Each directory should
contain the files |
moi |
a string indicating the MOI of the dataset, either "low" or "high". |
grna_target_data_frame |
a data frame containing columns |
extra_covariates |
(optional) a data frame containing extra covariates
(e.g., batch, biological replicate) beyond those that |
use_ondisc |
(optional; default |
directory_to_write |
(optional) a string indicating the directory in
which to write the backing |
an initialized sceptre_object
data(grna_target_data_frame_highmoi) directories <- paste0( system.file("extdata", package = "sceptre"), "/highmoi_example/gem_group_", c(1, 2) ) # 1. create a standard sceptre_object from Cell Ranger output sceptre_object <- import_data_from_cellranger( directories = directories, moi = "high", grna_target_data_frame = grna_target_data_frame_highmoi, ) # 2. create an ondisc-backed sceptre_object from Cell Ranger output sceptre_object <- import_data_from_cellranger( directories = directories, moi = "high", grna_target_data_frame = grna_target_data_frame_highmoi, use_ondisc = TRUE, directory_to_write = tempdir() )data(grna_target_data_frame_highmoi) directories <- paste0( system.file("extdata", package = "sceptre"), "/highmoi_example/gem_group_", c(1, 2) ) # 1. create a standard sceptre_object from Cell Ranger output sceptre_object <- import_data_from_cellranger( directories = directories, moi = "high", grna_target_data_frame = grna_target_data_frame_highmoi, ) # 2. create an ondisc-backed sceptre_object from Cell Ranger output sceptre_object <- import_data_from_cellranger( directories = directories, moi = "high", grna_target_data_frame = grna_target_data_frame_highmoi, use_ondisc = TRUE, directory_to_write = tempdir() )
import_data_from_parse() imports data from the output of the Parse count
matrix generation program. See
Chapter 1 of the manual
for more information about this function.
import_data_from_parse( gene_mat_fp, grna_mat_fp, all_genes_fp, all_grnas_fp, moi, grna_target_data_frame, extra_covariates = data.frame() )import_data_from_parse( gene_mat_fp, grna_mat_fp, all_genes_fp, all_grnas_fp, moi, grna_target_data_frame, extra_covariates = data.frame() )
gene_mat_fp |
file path to the gene |
grna_mat_fp |
file path to the gRNA |
all_genes_fp |
file path to the |
all_grnas_fp |
file path to the |
moi |
a string indicating the MOI of the dataset, either "low" or "high". |
grna_target_data_frame |
a data frame containing columns |
extra_covariates |
(optional) a data frame containing extra covariates
(e.g., batch, biological replicate) beyond those that |
import_data_from_parse() is experimental, and the API of this function is
subject to change. We expect the API to solidify as we learn more about the
Parse platform and the structure of the Parse count matrix generation program
output.
The example data shipped with the package (used in the examples below) are a small subset of Parse Biosciences' "Technical Performance of CRISPR Detect in Cell Lines" demo dataset, used under the Creative Commons Attribution 4.0 International (CC BY 4.0) license, with attribution to Parse Biosciences. See https://www.parsebiosciences.com/datasets/technical-performance-of-crispr-detect-in-cell-lines/.
an initialized sceptre_object
directory <- paste0( system.file("extdata", package = "sceptre"), "/parse_example/" ) gene_mat_fp <- paste0(directory, "gene_mat.mtx") grna_mat_fp <- paste0(directory, "grna_mat.mtx") all_genes_fp <- paste0(directory, "all_genes.csv") all_grnas_fp <- paste0(directory, "all_grnas.csv") grna_target_data_frame <- data.frame( grna_id = c("guide_A", "guide_B", "guide_C"), grna_target = c("target-A", "target-B", "non-targeting") ) sceptre_object <- import_data_from_parse( gene_mat_fp = gene_mat_fp, grna_mat_fp = grna_mat_fp, all_genes_fp = all_genes_fp, all_grnas_fp = all_grnas_fp, moi = "low", grna_target_data_frame = grna_target_data_frame )directory <- paste0( system.file("extdata", package = "sceptre"), "/parse_example/" ) gene_mat_fp <- paste0(directory, "gene_mat.mtx") grna_mat_fp <- paste0(directory, "grna_mat.mtx") all_genes_fp <- paste0(directory, "all_genes.csv") all_grnas_fp <- paste0(directory, "all_grnas.csv") grna_target_data_frame <- data.frame( grna_id = c("guide_A", "guide_B", "guide_C"), grna_target = c("target-A", "target-B", "non-targeting") ) sceptre_object <- import_data_from_parse( gene_mat_fp = gene_mat_fp, grna_mat_fp = grna_mat_fp, all_genes_fp = all_genes_fp, all_grnas_fp = all_grnas_fp, moi = "low", grna_target_data_frame = grna_target_data_frame )
The example low-MOI data are a small simulated dataset modeled on that in the paper "Characterizing the molecular regulation of inhibitory immune checkpoints with multimodal single-cell screens" by Papalexi et al., 2021. This dataset includes gene-targeting CRISPRko perturbations as well as non- targeting perturbations.
data(lowmoi_example_data)data(lowmoi_example_data)
An object of class list of length 4.
The example data are stored in a list containing four components:
response_matrix: the gene-by-cell expression matrix
grna_matrix: the gRNA-by-cell expression matrix
grna_target_data_frame: a data frame containing the columns grna_id (ID
of an individual gRNA) and grna_target (genomic target of the gRNA)
extra_covariates: a data frame with a single column, batch, specifying
the batch in which each cell was sequenced (batch_1 or batch_2); the row
names give the cell IDs and match the matrix column names
plot_assign_grnas() plots the outcome of the gRNA-to-cell assignment step.
The top panel plots the gRNA-to-cell assignments of n_grnas_to_plot
(default 3) randomly selected gRNAs. In each plot the points represent cells;
the vertical axis indicates the UMI count of the gRNA in a given cell, and
the horizontal axis indicates whether the cell has been classified as
“perturbed” (i.e., it contains the gRNA) or unperturbed (i.e., it does not
contain the gRNA). Perturbed (resp., unperturbed) cells are shown in the left
(resp., right) column. The bottom left panel is a barplot of the number of
cells to which each gRNA has been mapped. Finally, the bottom right panel is
a histogram of the number of gRNAs contained in each cell. The mean number of
gRNAs per cell — i.e., the MOI — is displayed in purple text.
plot_assign_grnas( sceptre_object, n_grnas_to_plot = 3L, grnas_to_plot = NULL, point_size = 0.9, transparency = 0.8, return_indiv_plots = FALSE )plot_assign_grnas( sceptre_object, n_grnas_to_plot = 3L, grnas_to_plot = NULL, point_size = 0.9, transparency = 0.8, return_indiv_plots = FALSE )
sceptre_object |
a |
n_grnas_to_plot |
(optional; default |
grnas_to_plot |
(optional; default |
point_size |
(optional; default |
transparency |
(optional; default |
return_indiv_plots |
(optional; default |
a single cowplot object containing the combined panels (if
return_indiv_plots is set to TRUE) or a list of the individual
panels (if return_indiv_plots is set to FALSE)
data(highmoi_example_data) data(grna_target_data_frame_highmoi) import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) |> set_analysis_parameters() |> assign_grnas(method = "thresholding") |> plot_assign_grnas()data(highmoi_example_data) data(grna_target_data_frame_highmoi) import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) |> set_analysis_parameters() |> assign_grnas(method = "thresholding") |> plot_assign_grnas()
plot_covariates() creates a histogram of the covariates
response_n_nonzero, response_n_umis, and (if applicable)
response_p_mito. Cellwise QC removes cells that lie in the extreme right
tail of the response_p_mito distribution or that lie in the extreme left
or right tail of the response_n_nonzero or response_n_umis
distribution. To help guide the selection of QC thresholds,
plot_covariates() plots candidate QC thresholds as vertical lines on the
histograms. The optional arguments response_n_nonzero_range,
response_n_umis_range, and p_mito_threshold control the location of these
candidate QC thresholds. response_n_nonzero_range (resp.,
response_n_umis_range) is a length-two vector of quantiles (default:
c(0.01, 0.99)) indicating the location at which to draw candidate QC
thresholds on the response_n_nonzero (resp., response_n_umis) histogram.
Next, p_mito_threshold is a single numeric value in the interval [0,1]
specifying the location at which to draw a candidate QC threshold on the
response_p_mito plot.
plot_covariates( sceptre_object, response_n_umis_range = c(0.01, 0.99), response_n_nonzero_range = c(0.01, 0.99), p_mito_threshold = 0.2, return_indiv_plots = FALSE )plot_covariates( sceptre_object, response_n_umis_range = c(0.01, 0.99), response_n_nonzero_range = c(0.01, 0.99), p_mito_threshold = 0.2, return_indiv_plots = FALSE )
sceptre_object |
a |
response_n_umis_range |
(optional; default |
response_n_nonzero_range |
(optional; default |
p_mito_threshold |
(optional; default |
return_indiv_plots |
(optional; default |
a single cowplot object containing the combined panels (if
return_indiv_plots is set to TRUE) or a list of the individual
panels (if return_indiv_plots is set to FALSE)
If run_qc() has already been called on the sceptre_object, then the
parameters response_n_umis_range, response_n_nonzero_range, and
p_mito_threshold are set to the corresponding parameters within the
sceptre_object.
data(highmoi_example_data) data(grna_target_data_frame_highmoi) import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) |> plot_covariates(p_mito_threshold = 0.07)data(highmoi_example_data) data(grna_target_data_frame_highmoi) import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) |> plot_covariates(p_mito_threshold = 0.07)
plot_grna_count_distributions() plots the empirical UMI count distribution
of one or more gRNAs. plot_grna_count_distributions() can be called on a
sceptre_object at any point in the pipeline after import_data().
plot_grna_count_distributions( sceptre_object, n_grnas_to_plot = 4L, grnas_to_plot = NULL, threshold = NULL, return_indiv_plots = FALSE )plot_grna_count_distributions( sceptre_object, n_grnas_to_plot = 4L, grnas_to_plot = NULL, threshold = NULL, return_indiv_plots = FALSE )
sceptre_object |
a |
n_grnas_to_plot |
(optional; default |
grnas_to_plot |
(optional; default |
threshold |
(optional; default |
return_indiv_plots |
(optional; default |
The x-axis is a piecewise linear-log scale, with bins of size 1 going from
gRNA counts of 0 up to max(10, threshold), and then the bin widths
grow exponentially in size. The number under each bar indicates the first
value that is counted for that bar, and that bar includes all integers from
that label up until the integer immediately preceding the label of the next
bar on the right. For example, if one bar has a label of "23" and the next
bar on the right has a label of "26" then the bar with the label of "23"
counts values of 23, 24, and 25 in the data.
a single cowplot object containing the combined panels (if
return_indiv_plots is FALSE, the default) or a list of the
per-gRNA ggplot2 panels (if return_indiv_plots is TRUE)
data(highmoi_example_data) data(grna_target_data_frame_highmoi) import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) |> plot_grna_count_distributions()data(highmoi_example_data) data(grna_target_data_frame_highmoi) import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) |> plot_grna_count_distributions()
plot_response_grna_target_pair() creates a violin plot of the expression
level of a given response as a function of the "treatment status" (i.e.,
treatment or control) of a given gRNA target. The left (resp., right) violin
plot shows the expression level of the response in treatment (resp., control)
cells. The expression level is normalized by dividing by n_response_umis,
adding a pseudo-count of 1 and then taking the log transform. If the given
response-gRNA-target pair has been analyzed, the p-value for the test of
association also is displayed.
plot_response_grna_target_pair(sceptre_object, response_id, grna_target)plot_response_grna_target_pair(sceptre_object, response_id, grna_target)
sceptre_object |
a |
response_id |
a string containing a response ID |
grna_target |
a string containing a gRNA target (or, if
|
If grna_integration_strategy is set to "singleton", then grna_target
should be set to a gRNA ID.
a violin plot
data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) discovery_pairs <- construct_cis_pairs(sceptre_object) sceptre_object |> set_analysis_parameters( side = "left", discovery_pairs = discovery_pairs, resampling_mechanism = "permutations", ) |> assign_grnas(method = "thresholding") |> run_qc() |> run_discovery_analysis() |> plot_response_grna_target_pair( response_id = "ENSG00000211641", grna_target = "candidate_enh_15" )data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) discovery_pairs <- construct_cis_pairs(sceptre_object) sceptre_object |> set_analysis_parameters( side = "left", discovery_pairs = discovery_pairs, resampling_mechanism = "permutations", ) |> assign_grnas(method = "thresholding") |> run_qc() |> run_discovery_analysis() |> plot_response_grna_target_pair( response_id = "ENSG00000211641", grna_target = "candidate_enh_15" )
plot_run_calibration_check() creates a visualization of the outcome of
the calibration check. The visualization consists of four panels, which we
describe below.
The upper left panel is a QQ plot of the p-values plotted on an untransformed scale. The p-values ideally should lie along the diagonal line, indicating uniformity of the p-values in the bulk of the distribution.
The upper right panel is a QQ plot of the p-values plotted on a negative log-10 transformed scale. The p-values ideally should lie along the diagonal line (with the majority of the p-values falling within the gray confidence band), indicating uniformity of the p-values in the tail of the distribution.
The lower left panel is a histogram of the estimated log-2 fold changes. The histogram ideally should be roughly symmetric and centered around zero.
Finally, the bottom right panel is a text box displaying (i) the number of
false discoveries that sceptre has made on the negative control data and
(ii) the mean estimated log-fold change.
plot_run_calibration_check( sceptre_object, point_size = 0.55, transparency = 0.8, return_indiv_plots = FALSE )plot_run_calibration_check( sceptre_object, point_size = 0.55, transparency = 0.8, return_indiv_plots = FALSE )
sceptre_object |
a |
point_size |
(optional; default |
transparency |
(optional; default |
return_indiv_plots |
(optional; default |
a single cowplot object containing the combined panels (if
return_indiv_plots is set to TRUE) or a list of the individual
panels (if return_indiv_plots is set to FALSE)
data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) sceptre_object |> set_analysis_parameters( side = "left", resampling_mechanism = "permutations" ) |> assign_grnas(method = "thresholding") |> run_qc() |> run_calibration_check( n_calibration_pairs = 500, calibration_group_size = 2 ) |> plot_run_calibration_check()data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) sceptre_object |> set_analysis_parameters( side = "left", resampling_mechanism = "permutations" ) |> assign_grnas(method = "thresholding") |> run_qc() |> run_calibration_check( n_calibration_pairs = 500, calibration_group_size = 2 ) |> plot_run_calibration_check()
plot_run_discovery_analysis() creates a visualization of the outcome of the
discovery analysis. The visualization consists of four plots:
The upper left plot superimposes the discovery p-values (blue) on top of the negative control p-values (red) on an untransformed scale.
The upper right plot is the same as the upper left plot, but the scale is negative log-10 transformed. The discovery p-values ideally should trend above the diagonal line, indicating the presence of signal in the discovery set. The horizontal dashed line indicates the multiple testing threshold; discovery pairs whose p-value falls above this line are called as significant.
The bottom left panel is a volcano plot of the p-values and log fold changes of the discovery pairs. Each point corresponds to a pair; the estimated log-2 fold change of the pair is plotted on the horizontal axis, and the (negative log-10 transformed) p-value is plotted on the vertical axis. The horizontal dashed line again indicates the multiple testing threshold. Points above the dashed line (colored in purple) are called as discoveries, while points below (colored in blue) are called as insignificant.
The bottom right panel is a text box displaying the number of discovery pairs called as significant.
plot_run_discovery_analysis( sceptre_object, x_limits = c(-1.5, 1.5), point_size = 0.55, transparency = 0.8, return_indiv_plots = FALSE )plot_run_discovery_analysis( sceptre_object, x_limits = c(-1.5, 1.5), point_size = 0.55, transparency = 0.8, return_indiv_plots = FALSE )
sceptre_object |
a |
x_limits |
(optional; default |
point_size |
(optional; default |
transparency |
(optional; default |
return_indiv_plots |
(optional; default |
a single cowplot object containing the combined panels (if
return_indiv_plots is set to TRUE) or a list of the individual
panels (if return_indiv_plots is set to FALSE)
data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) positive_control_pairs <- construct_positive_control_pairs(sceptre_object) discovery_pairs <- construct_cis_pairs(sceptre_object, positive_control_pairs = positive_control_pairs, distance_threshold = 5e6 ) sceptre_object |> set_analysis_parameters( side = "left", discovery_pairs = discovery_pairs, resampling_mechanism = "permutations", ) |> assign_grnas(method = "thresholding") |> run_qc() |> run_calibration_check() |> run_discovery_analysis() |> plot_run_discovery_analysis()data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) positive_control_pairs <- construct_positive_control_pairs(sceptre_object) discovery_pairs <- construct_cis_pairs(sceptre_object, positive_control_pairs = positive_control_pairs, distance_threshold = 5e6 ) sceptre_object |> set_analysis_parameters( side = "left", discovery_pairs = discovery_pairs, resampling_mechanism = "permutations", ) |> assign_grnas(method = "thresholding") |> run_qc() |> run_calibration_check() |> run_discovery_analysis() |> plot_run_discovery_analysis()
plot_run_power_check() creates a visualization of the outcome of the
power check analysis. Each point in the plot corresponds to a target-response
pair, with positive control pairs in the left column and negative control
pairs in the right column. The vertical axis indicates the p-value of a given
pair; smaller (i.e., more significant) p-values are positioned higher along
this axis (p-values truncated at clip_to for visualization). The positive
control p-values should be small, and in particular, smaller than the
negative control p-values.
plot_run_power_check( sceptre_object, point_size = 1, transparency = 0.8, clip_to = 1e-20 )plot_run_power_check( sceptre_object, point_size = 1, transparency = 0.8, clip_to = 1e-20 )
sceptre_object |
a |
point_size |
(optional; default |
transparency |
(optional; default |
clip_to |
(optional; default |
a single ggplot2 plot
data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) positive_control_pairs <- construct_positive_control_pairs(sceptre_object) sceptre_object |> set_analysis_parameters( side = "left", positive_control_pairs = positive_control_pairs, resampling_mechanism = "permutations", ) |> assign_grnas(method = "thresholding") |> run_qc() |> run_calibration_check( n_calibration_pairs = 500, calibration_group_size = 2 ) |> run_power_check() |> plot_run_power_check()data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) positive_control_pairs <- construct_positive_control_pairs(sceptre_object) sceptre_object |> set_analysis_parameters( side = "left", positive_control_pairs = positive_control_pairs, resampling_mechanism = "permutations", ) |> assign_grnas(method = "thresholding") |> run_qc() |> run_calibration_check( n_calibration_pairs = 500, calibration_group_size = 2 ) |> run_power_check() |> plot_run_power_check()
plot_run_qc() creates a visualization of the outcome of the QC step. The
top panel depicts the outcome of the cellwise QC. The various cellwise QC
filters (e.g., "N nonzero responses," "N response UMIs," "Percent mito",
etc.) are shown on the horizontal axis, and the percentage of cells removed
due application of a given QC filter is shown on the vertical axis. Note that
a cell can be flagged by multiple QC filters; for example, a cell might have
an extremely high response_n_umi value and an extremely high
response_n_nonzero value. Thus, the height of the "any filter" bar (which
indicates the percentage of cells removed due to application of any filter)
need not be equal to the sum of the heights of the other bars. The bottom
panel depicts the outcome of the pairwise QC. Each point corresponds to a
target-response pair; the vertical axis (resp., horizontal axis) indicates
the n_nonzero_trt (resp., n_nonzero_cntrl) value of that pair. Pairs for
which n_nonzero_trt or n_nonzero_cntrl fall below the threshold are
removed (red), while the remaining pairs are retained (green).
plot_run_qc( sceptre_object, downsample_pairs = 10000L, point_size = 0.55, transparency = 0.8, return_indiv_plots = FALSE )plot_run_qc( sceptre_object, downsample_pairs = 10000L, point_size = 0.55, transparency = 0.8, return_indiv_plots = FALSE )
sceptre_object |
a |
downsample_pairs |
(optional; default |
point_size |
(optional; default |
transparency |
(optional; default |
return_indiv_plots |
(optional; default |
a single cowplot object containing the combined panels (if
return_indiv_plots is set to TRUE) or a list of the individual
panels (if return_indiv_plots is set to FALSE)
data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) discovery_pairs <- construct_cis_pairs(sceptre_object) sceptre_object |> set_analysis_parameters( discovery_pairs = discovery_pairs, side = "left" ) |> assign_grnas(method = "thresholding") |> run_qc() |> plot_run_qc()data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) discovery_pairs <- construct_cis_pairs(sceptre_object) sceptre_object |> set_analysis_parameters( discovery_pairs = discovery_pairs, side = "left" ) |> assign_grnas(method = "thresholding") |> run_qc() |> plot_run_qc()
plot() creates a plot depicting the current state of a sceptre_object.
## S4 method for signature 'sceptre_object' plot(x, y, ...)## S4 method for signature 'sceptre_object' plot(x, y, ...)
x |
a |
y |
ignored argument |
... |
arguments passed to the plotting function dispatched by |
plot() is "generic" in the sense that it dispatches a specific plotting
function based on the pipeline function that was most recently called on the
sceptre_object. For example, if run_assign_grnas() is the most recently
called pipeline function, then plot() dispatches plot_run_assign_grnas().
Similarly, if run_power_check() is the most recently called pipeline
function, then plot() dispatches plot_run_power_check(), and so on. Users
can pass arguments to the function dispatched by plot() as named arguments
to plot().
a single cowplot object containing the combined panels (if
return_indiv_plots is set to TRUE) or a list of the individual
panels (if return_indiv_plots is set to FALSE)
data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) # set analysis parameters, assign grnas sceptre_object <- sceptre_object |> set_analysis_parameters() |> assign_grnas(method = "thresholding") |> plot()data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) # set analysis parameters, assign grnas sceptre_object <- sceptre_object |> set_analysis_parameters() |> assign_grnas(method = "thresholding") |> plot()
print() prints information about the dataset and the status of the analysis
to the console. The output contains several fields: Attributes of the data
(summarizing key features of the data), Analysis status (indicating the
analysis functions that have been called), Analysis parameters (summarizing
the analysis parameters set in set_analysis_parameters()), gRNA-to-cell
assignment information (summarizing the outcome of the gRNA-to-cell
assignment step), and Summary of results (summarizing the key analysis
results). A subset of these fields may be printed, depending on the status of
the analysis.
## S4 method for signature 'sceptre_object' print(x)## S4 method for signature 'sceptre_object' print(x)
x |
a |
the value NULL
data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) print(sceptre_object)data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) print(sceptre_object)
ondisc-backed sceptre_object
write_ondisc_backed_sceptre_object() and
read_ondisc_backed_sceptre_object() enable the writing and reading of
ondisc-backed sceptre_objects, respectively. First,
write_ondisc_backed_sceptre_object() writes an ondisc-backed
sceptre_object to disk, creating a file sceptre_object.rds in the
specified directory. Next, read_ondisc_backed_sceptre_object() reads and
initializes a sceptre_object from a sceptre_object.rds file,
response.odm file, and grna.odm file stored on disk.
read_ondisc_backed_sceptre_object( sceptre_object_fp, response_odm_file_fp, grna_odm_file_fp ) write_ondisc_backed_sceptre_object(sceptre_object, directory_to_write)read_ondisc_backed_sceptre_object( sceptre_object_fp, response_odm_file_fp, grna_odm_file_fp ) write_ondisc_backed_sceptre_object(sceptre_object, directory_to_write)
sceptre_object_fp |
file path to a |
response_odm_file_fp |
file path to the backing |
grna_odm_file_fp |
file path to the backing |
sceptre_object |
a |
directory_to_write |
the directory in which to write the
|
write_ondisc_backed_sceptre_object() returns NULL, and
read_ondisc_backed_sceptre_object() returns an ondisc-backed
sceptre_object
data(lowmoi_example_data) # 1. create ondisc-backed sceptre_object sceptre_object <- import_data( response_matrix = lowmoi_example_data$response_matrix, grna_matrix = lowmoi_example_data$grna_matrix, grna_target_data_frame = lowmoi_example_data$grna_target_data_frame, extra_covariates = lowmoi_example_data$extra_covariates, moi = "low", use_ondisc = TRUE, directory_to_write = tempdir() ) # 2. write write_ondisc_backed_sceptre_object( sceptre_object = sceptre_object, directory_to_write = tempdir() ) # 3. read rm(sceptre_object) sceptre_object <- read_ondisc_backed_sceptre_object( sceptre_object_fp = paste0(tempdir(), "/sceptre_object.rds"), response_odm_file_fp = paste0(tempdir(), "/response.odm"), grna_odm_file_fp = paste0(tempdir(), "/grna.odm") )data(lowmoi_example_data) # 1. create ondisc-backed sceptre_object sceptre_object <- import_data( response_matrix = lowmoi_example_data$response_matrix, grna_matrix = lowmoi_example_data$grna_matrix, grna_target_data_frame = lowmoi_example_data$grna_target_data_frame, extra_covariates = lowmoi_example_data$extra_covariates, moi = "low", use_ondisc = TRUE, directory_to_write = tempdir() ) # 2. write write_ondisc_backed_sceptre_object( sceptre_object = sceptre_object, directory_to_write = tempdir() ) # 3. read rm(sceptre_object) sceptre_object <- read_ondisc_backed_sceptre_object( sceptre_object_fp = paste0(tempdir(), "/sceptre_object.rds"), response_odm_file_fp = paste0(tempdir(), "/response.odm"), grna_odm_file_fp = paste0(tempdir(), "/grna.odm") )
run_calibration_check() runs the calibration check. The calibration check
involves applying sceptre to analyze negative control target-response pairs
— pairs for which we know there is no association between the target and
response — to ensure control of the false discovery rate. The calibration
check enables us to verify that the discovery set that sceptre ultimately
produces is not contaminated by excess false positives. See
Chapter 5 of the manual
for more detailed information about this function.
run_calibration_check( sceptre_object, n_calibration_pairs = NULL, calibration_group_size = NULL, print_progress = TRUE, parallel = FALSE, n_processors = "auto", log_dir = tempdir(), output_amount = 1 )run_calibration_check( sceptre_object, n_calibration_pairs = NULL, calibration_group_size = NULL, print_progress = TRUE, parallel = FALSE, n_processors = "auto", log_dir = tempdir(), output_amount = 1 )
sceptre_object |
a |
n_calibration_pairs |
(optional) the number of negative control pairs to construct and test for association |
calibration_group_size |
(optional) the number of negative control gRNAs to randomly assemble to form each negative control target |
print_progress |
(optional; default |
parallel |
(optional; default |
n_processors |
(optional; default |
log_dir |
(optional; default |
output_amount |
(optional; default |
an updated sceptre_object in which the calibration check has been
carried out
data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) # set analysis parameters, assign grnas, run qc, run calibration check sceptre_object <- sceptre_object |> set_analysis_parameters( side = "left", resampling_mechanism = "permutations" ) |> assign_grnas(method = "thresholding") |> run_qc() |> run_calibration_check( n_calibration_pairs = 500, calibration_group_size = 2 )data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) # set analysis parameters, assign grnas, run qc, run calibration check sceptre_object <- sceptre_object |> set_analysis_parameters( side = "left", resampling_mechanism = "permutations" ) |> assign_grnas(method = "thresholding") |> run_qc() |> run_calibration_check( n_calibration_pairs = 500, calibration_group_size = 2 )
run_discovery_analysis() runs the discovery analysis. The discovery
analysis involves applying sceptre to analyze discovery pairs, or
target-response pairs whose association status we do not know but seek to
learn. Identifying associations among the discovery pairs is the primary
objective of the single-cell CRISPR screen analysis. See
Chapter 6 of the manual
for more detailed information about this function.
run_discovery_analysis( sceptre_object, output_amount = 1, print_progress = TRUE, parallel = FALSE, n_processors = "auto", log_dir = tempdir() )run_discovery_analysis( sceptre_object, output_amount = 1, print_progress = TRUE, parallel = FALSE, n_processors = "auto", log_dir = tempdir() )
sceptre_object |
a |
output_amount |
(optional; default |
print_progress |
(optional; default |
parallel |
(optional; default |
n_processors |
(optional; default |
log_dir |
(optional; default |
an updated sceptre_object in which the discovery analysis has been
carried out
data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) # set analysis parameters, assign grnas, run qc discovery_pairs <- construct_cis_pairs(sceptre_object) sceptre_object <- sceptre_object |> set_analysis_parameters( side = "left", resampling_mechanism = "permutations", discovery_pairs = discovery_pairs ) |> assign_grnas(method = "thresholding") |> run_qc() |> run_discovery_analysis()data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) # set analysis parameters, assign grnas, run qc discovery_pairs <- construct_cis_pairs(sceptre_object) sceptre_object <- sceptre_object |> set_analysis_parameters( side = "left", resampling_mechanism = "permutations", discovery_pairs = discovery_pairs ) |> assign_grnas(method = "thresholding") |> run_qc() |> run_discovery_analysis()
run_power_check() runs the power check. The power check entails applying
sceptre to analyze positive control pairs — pairs for which we know there
is an association between the target and the response — to ensure that
sceptre is capable of detecting true associations. See
Chapter 6 of the manual
for more detailed information about this function.
run_power_check( sceptre_object, output_amount = 1, print_progress = TRUE, parallel = FALSE, n_processors = "auto", log_dir = tempdir() )run_power_check( sceptre_object, output_amount = 1, print_progress = TRUE, parallel = FALSE, n_processors = "auto", log_dir = tempdir() )
sceptre_object |
a |
output_amount |
(optional; default |
print_progress |
(optional; default |
parallel |
(optional; default |
n_processors |
(optional; default |
log_dir |
(optional; default |
an updated sceptre_object in which the power check has been carried
out
data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) # set analysis parameters, assign grnas, run qc positive_control_pairs <- construct_positive_control_pairs(sceptre_object) sceptre_object <- sceptre_object |> set_analysis_parameters( side = "left", resampling_mechanism = "permutations", positive_control_pairs = positive_control_pairs ) |> assign_grnas(method = "thresholding") |> run_qc() |> run_power_check()data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) # set analysis parameters, assign grnas, run qc positive_control_pairs <- construct_positive_control_pairs(sceptre_object) sceptre_object <- sceptre_object |> set_analysis_parameters( side = "left", resampling_mechanism = "permutations", positive_control_pairs = positive_control_pairs ) |> assign_grnas(method = "thresholding") |> run_qc() |> run_power_check()
run_qc() runs cellwise and pairwise QC on the data. Cellwise QC involves
filtering cells on the covariates response_n_nonzero, response_n_umis,
and response_p_mito. In low-MOI we additionally remove cells that contain
zero or multiple gRNAs. Next, pairwise QC involves filtering out
target-response pairs whose data are too sparse to be analyzed reliably. In
this context we define the “number of nonzero treatment cells” (resp., the
“number of nonzero control cells”) as the number of cells in the treatment
group (resp., control group) that contain nonzero expression of the response.
(We sometimes use the shorthand n_nonzero_trt and n_nonzero_cntrl to
refer to the number of nonzero treatment cells and control cells,
respectively.) Pairwise QC involves filtering target-response pairs on
n_nonzero_trt and n_nonzero_cntrl. See
Chapter 4 of the manual
for more detailed information about this function.
run_qc( sceptre_object, n_nonzero_trt_thresh = 7L, n_nonzero_cntrl_thresh = 7L, response_n_umis_range = c(0.01, 0.99), response_n_nonzero_range = c(0.01, 0.99), p_mito_threshold = 0.2, additional_cells_to_remove = integer() )run_qc( sceptre_object, n_nonzero_trt_thresh = 7L, n_nonzero_cntrl_thresh = 7L, response_n_umis_range = c(0.01, 0.99), response_n_nonzero_range = c(0.01, 0.99), p_mito_threshold = 0.2, additional_cells_to_remove = integer() )
sceptre_object |
a |
n_nonzero_trt_thresh |
(optional; default |
n_nonzero_cntrl_thresh |
(optional; default |
response_n_umis_range |
(optional; default |
response_n_nonzero_range |
(optional; default |
p_mito_threshold |
(optional; default |
additional_cells_to_remove |
(optional) a vector of integer indices specifying additional cells to remove |
an updated sceptre_object in which cellwise and pairwise QC have
been applied
data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) # set analysis parameters, assign grnas, run qc positive_control_pairs <- construct_positive_control_pairs(sceptre_object) discovery_pairs <- construct_cis_pairs(sceptre_object, positive_control_pairs = positive_control_pairs, distance_threshold = 5e6 ) sceptre_object <- sceptre_object |> set_analysis_parameters( discovery_pairs = discovery_pairs, positive_control_pairs = positive_control_pairs, side = "left" ) |> assign_grnas(method = "thresholding") |> run_qc()data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) # set analysis parameters, assign grnas, run qc positive_control_pairs <- construct_positive_control_pairs(sceptre_object) discovery_pairs <- construct_cis_pairs(sceptre_object, positive_control_pairs = positive_control_pairs, distance_threshold = 5e6 ) sceptre_object <- sceptre_object |> set_analysis_parameters( discovery_pairs = discovery_pairs, positive_control_pairs = positive_control_pairs, side = "left" ) |> assign_grnas(method = "thresholding") |> run_qc()
set_analysis_parameters() sets the analysis parameters that control how the
statistical analysis is to be conducted. See
Chapter 2 of the manual
for more detailed information about this function.
set_analysis_parameters( sceptre_object, discovery_pairs = data.frame(grna_target = character(0), response_id = character(0)), positive_control_pairs = data.frame(grna_target = character(0), response_id = character(0)), side = "both", grna_integration_strategy = "union", formula_object = "default", resampling_approximation = "skew_normal", control_group = "default", resampling_mechanism = "default", multiple_testing_method = "BH", multiple_testing_alpha = 0.1 )set_analysis_parameters( sceptre_object, discovery_pairs = data.frame(grna_target = character(0), response_id = character(0)), positive_control_pairs = data.frame(grna_target = character(0), response_id = character(0)), side = "both", grna_integration_strategy = "union", formula_object = "default", resampling_approximation = "skew_normal", control_group = "default", resampling_mechanism = "default", multiple_testing_method = "BH", multiple_testing_alpha = 0.1 )
sceptre_object |
a |
discovery_pairs |
(optional) a data frame with columns |
positive_control_pairs |
(optional) a data frame with columns
|
side |
(optional; default |
grna_integration_strategy |
(optional; default |
formula_object |
(optional) a formula object specifying how to adjust for the covariates in the model |
resampling_approximation |
(optional; default |
control_group |
(optional) a string specifying the control group to use
in the differential expression analysis, either |
resampling_mechanism |
(optional) a string specifying the resampling
mechanism to use, either |
multiple_testing_method |
(optional; default |
multiple_testing_alpha |
(optional; default |
an updated sceptre_object in which the analysis parameters have
been set
Every argument to this function is optional, but typically, users want
to specify discovery_pairs at minimum.
data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) # set analysis parameters positive_control_pairs <- construct_positive_control_pairs(sceptre_object) discovery_pairs <- construct_cis_pairs(sceptre_object, positive_control_pairs = positive_control_pairs, distance_threshold = 5e6 ) sceptre_object <- sceptre_object |> set_analysis_parameters( discovery_pairs = discovery_pairs, positive_control_pairs = positive_control_pairs, side = "left" )data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) # set analysis parameters positive_control_pairs <- construct_positive_control_pairs(sceptre_object) discovery_pairs <- construct_cis_pairs(sceptre_object, positive_control_pairs = positive_control_pairs, distance_threshold = 5e6 ) sceptre_object <- sceptre_object |> set_analysis_parameters( discovery_pairs = discovery_pairs, positive_control_pairs = positive_control_pairs, side = "left" )
write_outputs_to_directory() writes the outputs of a sceptre analysis to
a directory on disk. write_outputs_to_directory() writes several files to
the specified directory: a text-based summary of the analysis
(analysis_summary.txt), the various plots (*.png), the calibration check,
power check, discovery analysis results (results_run_calibration_check.rds,
results_run_power_check.rds, and results_run_discovery_analysis.rds,
respectively), and the binary gRNA-to-cell assignment matrix
(grna_assignment_matrix.rds). See
Section 8 of the introductory chapter in the manual
for more information about this function.
write_outputs_to_directory(sceptre_object, directory)write_outputs_to_directory(sceptre_object, directory)
sceptre_object |
a |
directory |
a string giving the file path to a directory on disk in which to write the results |
No return value; called for its side effect of writing files to directory.
data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) positive_control_pairs <- construct_positive_control_pairs(sceptre_object) discovery_pairs <- construct_cis_pairs(sceptre_object, positive_control_pairs = positive_control_pairs, distance_threshold = 5e6 ) sceptre_object |> set_analysis_parameters( side = "left", resampling_mechanism = "permutations", discovery_pairs = discovery_pairs, positive_control_pairs = positive_control_pairs ) |> assign_grnas(method = "thresholding") |> run_qc() |> run_calibration_check() |> run_power_check() |> run_discovery_analysis() |> write_outputs_to_directory(paste0(tempdir(), "/sceptre_outputs")) # files written to "sceptre_outputs" in tempdir()data(highmoi_example_data) data(grna_target_data_frame_highmoi) # import data sceptre_object <- import_data( response_matrix = highmoi_example_data$response_matrix, grna_matrix = highmoi_example_data$grna_matrix, grna_target_data_frame = grna_target_data_frame_highmoi, moi = "high", extra_covariates = highmoi_example_data$extra_covariates, response_names = highmoi_example_data$gene_names ) positive_control_pairs <- construct_positive_control_pairs(sceptre_object) discovery_pairs <- construct_cis_pairs(sceptre_object, positive_control_pairs = positive_control_pairs, distance_threshold = 5e6 ) sceptre_object |> set_analysis_parameters( side = "left", resampling_mechanism = "permutations", discovery_pairs = discovery_pairs, positive_control_pairs = positive_control_pairs ) |> assign_grnas(method = "thresholding") |> run_qc() |> run_calibration_check() |> run_power_check() |> run_discovery_analysis() |> write_outputs_to_directory(paste0(tempdir(), "/sceptre_outputs")) # files written to "sceptre_outputs" in tempdir()