Skip to contents

sceptre is an R package for single-cell CRISPR screen data analysis, emphasizing statistical rigor, massive scalability, and ease of use.

Author

Maintainer: Timothy Barry tbarry@hsph.harvard.edu (ORCID)

Authors:

Examples

##########################
# Low-MOI CRISPRko example
##########################
library(sceptredata)
# 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)
#> An object of class sceptre_object.
#> 
#> Attributes of the data:
#>20729 cells
#>299 responses
#>Low multiplicity-of-infection 
#>101 targeting gRNAs (distributed across 26 targets) 
#>9 non-targeting gRNAs 
#>6 covariates (bio_rep, grna_n_nonzero, grna_n_umis, response_n_nonzero, response_n_umis, response_p_mito)
#> 
#> Analysis status:
#> 	 import_data()
#> 	 set_analysis_parameters()
#> 	 assign_grnas()
#> 	 run_qc()
#> 	 run_calibration_check()
#> 	 run_power_check()
#> 	 run_discovery_analysis()
#> 
#> Analysis parameters: 
#> 	• Discovery pairs: not specified
#> 	• Positive control pairs: not specified
#> 	• Sidedness of test: not specified
#> 	• Control group: not specified
#> 	• Resampling mechanism: not specified
#> 	• gRNA integration strategy: not specified
#> 	• Resampling approximation: not specified
#> 	• Multiple testing adjustment: none
#> 	• N nonzero treatment cells threshold: not specified
#> 	• N nonzero control cells threshold: not specified
#> 	• Formula object: not specified

# 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)
#> An object of class sceptre_object.
#> 
#> Attributes of the data:
#>20729 cells
#>299 responses
#>Low multiplicity-of-infection 
#>101 targeting gRNAs (distributed across 26 targets) 
#>9 non-targeting gRNAs 
#>6 covariates (bio_rep, grna_n_nonzero, grna_n_umis, response_n_nonzero, response_n_umis, response_p_mito)
#> 
#> Analysis status:
#> 	 import_data()
#> 	 set_analysis_parameters()
#> 	 assign_grnas()
#> 	 run_qc()
#> 	 run_calibration_check()
#> 	 run_power_check()
#> 	 run_discovery_analysis()
#> 
#> Analysis parameters: 
#> 	• Discovery pairs: data frame with 7765 pairs
#> 	• Positive control pairs: data frame with 9 pairs
#> 	• Sidedness of test: both
#> 	• Control group: non-targeting cells
#> 	• Resampling mechanism: permutations
#> 	• gRNA integration strategy: union
#> 	• Resampling approximation: skew normal
#> 	• Multiple testing adjustment: BH at level 0.1
#> 	• N nonzero treatment cells threshold: not specified
#> 	• N nonzero control cells threshold: not specified
#> 	• Formula object: log(response_n_nonzero) + log(response_n_umis) + bio_rep

# 3. assign grnas
plot_grna_count_distributions(sceptre_object)

sceptre_object <- sceptre_object |> assign_grnas()
plot(sceptre_object)

print(sceptre_object)
#> An object of class sceptre_object.
#> 
#> Attributes of the data:
#>20729 cells
#>299 responses
#>Low multiplicity-of-infection 
#>101 targeting gRNAs (distributed across 26 targets) 
#>9 non-targeting gRNAs 
#>6 covariates (bio_rep, grna_n_nonzero, grna_n_umis, response_n_nonzero, response_n_umis, response_p_mito)
#> 
#> Analysis status:
#> 	 import_data()
#> 	 set_analysis_parameters()
#> 	 assign_grnas()
#> 	 run_qc()
#> 	 run_calibration_check()
#> 	 run_power_check()
#> 	 run_discovery_analysis()
#> 
#> Analysis parameters: 
#> 	• Discovery pairs: data frame with 7765 pairs
#> 	• Positive control pairs: data frame with 9 pairs
#> 	• Sidedness of test: both
#> 	• Control group: non-targeting cells
#> 	• Resampling mechanism: permutations
#> 	• gRNA integration strategy: union
#> 	• Resampling approximation: skew normal
#> 	• Multiple testing adjustment: BH at level 0.1
#> 	• N nonzero treatment cells threshold: not specified
#> 	• N nonzero control cells threshold: not specified
#> 	• Formula object: log(response_n_nonzero) + log(response_n_umis) + bio_rep
#> 
#> gRNA-to-cell assignment information:
#> 	• Assignment method: maximum
#> 	• Mean N cells per gRNA: 188.45
#> 	• Mean N gRNAs per cell (MOI): not computed when using "maximum" assignment method

# 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)
#> An object of class sceptre_object.
#> 
#> Attributes of the data:
#>20729 cells (15348 after cellwise QC)
#>299 responses
#>Low multiplicity-of-infection 
#>101 targeting gRNAs (distributed across 26 targets) 
#>9 non-targeting gRNAs 
#>6 covariates (bio_rep, grna_n_nonzero, grna_n_umis, response_n_nonzero, response_n_umis, response_p_mito)
#> 
#> Analysis status:
#> 	 import_data()
#> 	 set_analysis_parameters()
#> 	 assign_grnas()
#> 	 run_qc()
#> 	 run_calibration_check()
#> 	 run_power_check()
#> 	 run_discovery_analysis()
#> 
#> Analysis parameters: 
#> 	• Discovery pairs: data frame with 7765 pairs (6205 after pairwise QC)
#> 	• Positive control pairs: data frame with 9 pairs (9 after pairwise QC)
#> 	• Sidedness of test: both
#> 	• Control group: non-targeting cells
#> 	• Resampling mechanism: permutations
#> 	• gRNA integration strategy: union
#> 	• Resampling approximation: skew normal
#> 	• Multiple testing adjustment: BH at level 0.1
#> 	• N nonzero treatment cells threshold: 7
#> 	• N nonzero control cells threshold: 7
#> 	• Formula object: log(response_n_nonzero) + log(response_n_umis) + bio_rep
#> 
#> gRNA-to-cell assignment information:
#> 	• Assignment method: maximum
#> 	• Mean N cells per gRNA: 188.45
#> 	• Mean N gRNAs per cell (MOI): not computed when using "maximum" assignment method

# 5. run the calibration check
sceptre_object <- run_calibration_check(sceptre_object, parallel = TRUE, n_processors = 2)
#> Constructing negative control pairs.
#> Generating permutation resamples.
#> Running calibration_check in parallel. Change directories to /var/folders/7v/5sqjgh8j28lgf8qx3gbtq1h00000gp/T//RtmpHhxNRw/sceptre_logs/ and view the files calibration_check_*.out for progress updates.
#> 
#> 
plot(sceptre_object)

print(sceptre_object)
#> An object of class sceptre_object.
#> 
#> Attributes of the data:
#>20729 cells (15348 after cellwise QC)
#>299 responses
#>Low multiplicity-of-infection 
#>101 targeting gRNAs (distributed across 26 targets) 
#>9 non-targeting gRNAs 
#>6 covariates (bio_rep, grna_n_nonzero, grna_n_umis, response_n_nonzero, response_n_umis, response_p_mito)
#> 
#> Analysis status:
#> 	 import_data()
#> 	 set_analysis_parameters()
#> 	 assign_grnas()
#> 	 run_qc()
#> 	 run_calibration_check()
#> 	 run_power_check()
#> 	 run_discovery_analysis()
#> 
#> Analysis parameters: 
#> 	• Discovery pairs: data frame with 7765 pairs (6205 after pairwise QC)
#> 	• Positive control pairs: data frame with 9 pairs (9 after pairwise QC)
#> 	• Sidedness of test: both
#> 	• Control group: non-targeting cells
#> 	• Resampling mechanism: permutations
#> 	• gRNA integration strategy: union
#> 	• Resampling approximation: skew normal
#> 	• Multiple testing adjustment: BH at level 0.1
#> 	• N nonzero treatment cells threshold: 7
#> 	• N nonzero control cells threshold: 7
#> 	• Formula object: log(response_n_nonzero) + log(response_n_umis) + bio_rep
#> 
#> gRNA-to-cell assignment information:
#> 	• Assignment method: maximum
#> 	• Mean N cells per gRNA: 188.45
#> 	• Mean N gRNAs per cell (MOI): not computed when using "maximum" assignment method
#> 
#> Summary of results:
#> 	• N negative control pairs called as significant: 0/6205
#> 	• Mean log-2 FC for negative control pairs: -0.0027

# 6. run power check
sceptre_object <- run_power_check(sceptre_object, parallel = TRUE, n_processors = 2)
#> Generating permutation resamples.
#> Running power_check in parallel. Change directories to /var/folders/7v/5sqjgh8j28lgf8qx3gbtq1h00000gp/T//RtmpHhxNRw/sceptre_logs/ and view the files power_check_*.out for progress updates.
#> 
#> 
plot(sceptre_object)

print(sceptre_object)
#> An object of class sceptre_object.
#> 
#> Attributes of the data:
#>20729 cells (15348 after cellwise QC)
#>299 responses
#>Low multiplicity-of-infection 
#>101 targeting gRNAs (distributed across 26 targets) 
#>9 non-targeting gRNAs 
#>6 covariates (bio_rep, grna_n_nonzero, grna_n_umis, response_n_nonzero, response_n_umis, response_p_mito)
#> 
#> Analysis status:
#> 	 import_data()
#> 	 set_analysis_parameters()
#> 	 assign_grnas()
#> 	 run_qc()
#> 	 run_calibration_check()
#> 	 run_power_check()
#> 	 run_discovery_analysis()
#> 
#> Analysis parameters: 
#> 	• Discovery pairs: data frame with 7765 pairs (6205 after pairwise QC)
#> 	• Positive control pairs: data frame with 9 pairs (9 after pairwise QC)
#> 	• Sidedness of test: both
#> 	• Control group: non-targeting cells
#> 	• Resampling mechanism: permutations
#> 	• gRNA integration strategy: union
#> 	• Resampling approximation: skew normal
#> 	• Multiple testing adjustment: BH at level 0.1
#> 	• N nonzero treatment cells threshold: 7
#> 	• N nonzero control cells threshold: 7
#> 	• Formula object: log(response_n_nonzero) + log(response_n_umis) + bio_rep
#> 
#> gRNA-to-cell assignment information:
#> 	• Assignment method: maximum
#> 	• Mean N cells per gRNA: 188.45
#> 	• Mean N gRNAs per cell (MOI): not computed when using "maximum" assignment method
#> 
#> Summary of results:
#> 	• N negative control pairs called as significant: 0/6205
#> 	• Mean log-2 FC for negative control pairs: -0.0027
#> 	• Median positive control p-value: 1.3e-18

# 7. run discovery analysis
sceptre_object <- run_discovery_analysis(sceptre_object, parallel = TRUE, n_processors = 2)
#> Generating permutation resamples.
#> Running discovery_analysis in parallel. Change directories to /var/folders/7v/5sqjgh8j28lgf8qx3gbtq1h00000gp/T//RtmpHhxNRw/sceptre_logs/ and view the files discovery_analysis_*.out for progress updates.
#> 
#> 
plot(sceptre_object)

print(sceptre_object)
#> An object of class sceptre_object.
#> 
#> Attributes of the data:
#>20729 cells (15348 after cellwise QC)
#>299 responses
#>Low multiplicity-of-infection 
#>101 targeting gRNAs (distributed across 26 targets) 
#>9 non-targeting gRNAs 
#>6 covariates (bio_rep, grna_n_nonzero, grna_n_umis, response_n_nonzero, response_n_umis, response_p_mito)
#> 
#> Analysis status:
#> 	 import_data()
#> 	 set_analysis_parameters()
#> 	 assign_grnas()
#> 	 run_qc()
#> 	 run_calibration_check()
#> 	 run_power_check()
#> 	 run_discovery_analysis()
#> 
#> Analysis parameters: 
#> 	• Discovery pairs: data frame with 7765 pairs (6205 after pairwise QC)
#> 	• Positive control pairs: data frame with 9 pairs (9 after pairwise QC)
#> 	• Sidedness of test: both
#> 	• Control group: non-targeting cells
#> 	• Resampling mechanism: permutations
#> 	• gRNA integration strategy: union
#> 	• Resampling approximation: skew normal
#> 	• Multiple testing adjustment: BH at level 0.1
#> 	• N nonzero treatment cells threshold: 7
#> 	• N nonzero control cells threshold: 7
#> 	• Formula object: log(response_n_nonzero) + log(response_n_umis) + bio_rep
#> 
#> gRNA-to-cell assignment information:
#> 	• Assignment method: maximum
#> 	• Mean N cells per gRNA: 188.45
#> 	• Mean N gRNAs per cell (MOI): not computed when using "maximum" assignment method
#> 
#> Summary of results:
#> 	• N negative control pairs called as significant: 0/6205
#> 	• Mean log-2 FC for negative control pairs: -0.0027
#> 	• Median positive control p-value: 1.3e-18
#> 	• N discovery pairs called as significant: 453/6205

# 8. write results
write_outputs_to_directory(sceptre_object = sceptre_object, "~/sceptre_outputs_lowmoi/")
#> NULL

##########################
# High-MOI CRISPRi example
##########################
# 1. create the sceptre object from cellranger output
directories <- paste0(
  system.file("extdata", package = "sceptredata"),
  "/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
)
#> Processing directory 1.
#> Processing directory 2.
#> Combining matrices across directories.
#> Creating the sceptre object.
print(sceptre_object)
#> An object of class sceptre_object.
#> 
#> Attributes of the data:
#>45919 cells
#>526 responses
#>High multiplicity-of-infection 
#>70 targeting gRNAs (distributed across 35 targets) 
#>25 non-targeting gRNAs 
#>6 covariates (batch, grna_n_nonzero, grna_n_umis, response_n_nonzero, response_n_umis, response_p_mito)
#> 
#> Analysis status:
#> 	 import_data()
#> 	 set_analysis_parameters()
#> 	 assign_grnas()
#> 	 run_qc()
#> 	 run_calibration_check()
#> 	 run_power_check()
#> 	 run_discovery_analysis()
#> 
#> Analysis parameters: 
#> 	• Discovery pairs: not specified
#> 	• Positive control pairs: not specified
#> 	• Sidedness of test: not specified
#> 	• Resampling mechanism: not specified
#> 	• gRNA integration strategy: not specified
#> 	• Resampling approximation: not specified
#> 	• Multiple testing adjustment: none
#> 	• N nonzero treatment cells threshold: not specified
#> 	• N nonzero control cells threshold: not specified
#> 	• Formula object: not specified

# 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)
#> An object of class sceptre_object.
#> 
#> Attributes of the data:
#>45919 cells
#>526 responses
#>High multiplicity-of-infection 
#>70 targeting gRNAs (distributed across 35 targets) 
#>25 non-targeting gRNAs 
#>6 covariates (batch, grna_n_nonzero, grna_n_umis, response_n_nonzero, response_n_umis, response_p_mito)
#> 
#> Analysis status:
#> 	 import_data()
#> 	 set_analysis_parameters()
#> 	 assign_grnas()
#> 	 run_qc()
#> 	 run_calibration_check()
#> 	 run_power_check()
#> 	 run_discovery_analysis()
#> 
#> Analysis parameters: 
#> 	• Discovery pairs: data frame with 610 pairs
#> 	• Positive control pairs: data frame with 10 pairs
#> 	• Sidedness of test: left
#> 	• Resampling mechanism: conditional resampling
#> 	• gRNA integration strategy: union
#> 	• Resampling approximation: skew normal
#> 	• Multiple testing adjustment: BH at level 0.1
#> 	• N nonzero treatment cells threshold: not specified
#> 	• N nonzero control cells threshold: not specified
#> 	• Formula object: log(response_n_nonzero) + log(response_n_umis) + log(grna_n_nonzero) + log(grna_n_umis) + batch

# 3. assign grnas
plot_grna_count_distributions(sceptre_object)

sceptre_object <- sceptre_object |> assign_grnas(parallel = TRUE, n_processors = 2)
#> Running gRNA assignments in parallel. Change directories to /var/folders/7v/5sqjgh8j28lgf8qx3gbtq1h00000gp/T//RtmpHhxNRw/sceptre_logs/ and view the files assign_grnas_*.out for progress updates.
plot(sceptre_object)

print(sceptre_object)
#> An object of class sceptre_object.
#> 
#> Attributes of the data:
#>45919 cells
#>526 responses
#>High multiplicity-of-infection 
#>70 targeting gRNAs (distributed across 35 targets) 
#>25 non-targeting gRNAs 
#>6 covariates (batch, grna_n_nonzero, grna_n_umis, response_n_nonzero, response_n_umis, response_p_mito)
#> 
#> Analysis status:
#> 	 import_data()
#> 	 set_analysis_parameters()
#> 	 assign_grnas()
#> 	 run_qc()
#> 	 run_calibration_check()
#> 	 run_power_check()
#> 	 run_discovery_analysis()
#> 
#> Analysis parameters: 
#> 	• Discovery pairs: data frame with 610 pairs
#> 	• Positive control pairs: data frame with 10 pairs
#> 	• Sidedness of test: left
#> 	• Resampling mechanism: conditional resampling
#> 	• gRNA integration strategy: union
#> 	• Resampling approximation: skew normal
#> 	• Multiple testing adjustment: BH at level 0.1
#> 	• N nonzero treatment cells threshold: not specified
#> 	• N nonzero control cells threshold: not specified
#> 	• Formula object: log(response_n_nonzero) + log(response_n_umis) + log(grna_n_nonzero) + log(grna_n_umis) + batch
#> 
#> gRNA-to-cell assignment information:
#> 	• Assignment method: mixture
#> 	• Mean N cells per gRNA: 567.77
#> 	• Mean N gRNAs per cell (MOI): 1.17 
#> 	• gRNA assignment formula object: log(response_n_nonzero) + log(response_n_umis) + log(grna_n_nonzero) + log(grna_n_umis) + batch

# 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)
#> An object of class sceptre_object.
#> 
#> Attributes of the data:
#>45919 cells (44308 after cellwise QC)
#>526 responses
#>High multiplicity-of-infection 
#>70 targeting gRNAs (distributed across 35 targets) 
#>25 non-targeting gRNAs 
#>6 covariates (batch, grna_n_nonzero, grna_n_umis, response_n_nonzero, response_n_umis, response_p_mito)
#> 
#> Analysis status:
#> 	 import_data()
#> 	 set_analysis_parameters()
#> 	 assign_grnas()
#> 	 run_qc()
#> 	 run_calibration_check()
#> 	 run_power_check()
#> 	 run_discovery_analysis()
#> 
#> Analysis parameters: 
#> 	• Discovery pairs: data frame with 610 pairs (599 after pairwise QC)
#> 	• Positive control pairs: data frame with 10 pairs (10 after pairwise QC)
#> 	• Sidedness of test: left
#> 	• Resampling mechanism: conditional resampling
#> 	• gRNA integration strategy: union
#> 	• Resampling approximation: skew normal
#> 	• Multiple testing adjustment: BH at level 0.1
#> 	• N nonzero treatment cells threshold: 7
#> 	• N nonzero control cells threshold: 7
#> 	• Formula object: log(response_n_nonzero) + log(response_n_umis) + log(grna_n_nonzero) + log(grna_n_umis) + batch
#> 
#> gRNA-to-cell assignment information:
#> 	• Assignment method: mixture
#> 	• Mean N cells per gRNA: 567.77
#> 	• Mean N gRNAs per cell (MOI): 1.17 
#> 	• gRNA assignment formula object: log(response_n_nonzero) + log(response_n_umis) + log(grna_n_nonzero) + log(grna_n_umis) + batch

# 5. run the calibration check
sceptre_object <- run_calibration_check(sceptre_object, parallel = TRUE, n_processors = 2)
#> Constructing negative control pairs.
#> Running calibration_check in parallel. Change directories to /var/folders/7v/5sqjgh8j28lgf8qx3gbtq1h00000gp/T//RtmpHhxNRw/sceptre_logs/ and view the files calibration_check_*.out for progress updates. 
#> 
plot(sceptre_object)

print(sceptre_object)
#> An object of class sceptre_object.
#> 
#> Attributes of the data:
#>45919 cells (44308 after cellwise QC)
#>526 responses
#>High multiplicity-of-infection 
#>70 targeting gRNAs (distributed across 35 targets) 
#>25 non-targeting gRNAs 
#>6 covariates (batch, grna_n_nonzero, grna_n_umis, response_n_nonzero, response_n_umis, response_p_mito)
#> 
#> Analysis status:
#> 	 import_data()
#> 	 set_analysis_parameters()
#> 	 assign_grnas()
#> 	 run_qc()
#> 	 run_calibration_check()
#> 	 run_power_check()
#> 	 run_discovery_analysis()
#> 
#> Analysis parameters: 
#> 	• Discovery pairs: data frame with 610 pairs (599 after pairwise QC)
#> 	• Positive control pairs: data frame with 10 pairs (10 after pairwise QC)
#> 	• Sidedness of test: left
#> 	• Resampling mechanism: conditional resampling
#> 	• gRNA integration strategy: union
#> 	• Resampling approximation: skew normal
#> 	• Multiple testing adjustment: BH at level 0.1
#> 	• N nonzero treatment cells threshold: 7
#> 	• N nonzero control cells threshold: 7
#> 	• Formula object: log(response_n_nonzero) + log(response_n_umis) + log(grna_n_nonzero) + log(grna_n_umis) + batch
#> 
#> gRNA-to-cell assignment information:
#> 	• Assignment method: mixture
#> 	• Mean N cells per gRNA: 567.77
#> 	• Mean N gRNAs per cell (MOI): 1.17 
#> 	• gRNA assignment formula object: log(response_n_nonzero) + log(response_n_umis) + log(grna_n_nonzero) + log(grna_n_umis) + batch
#> 
#> Summary of results:
#> 	• N negative control pairs called as significant: 0/599
#> 	• Mean log-2 FC for negative control pairs: 0.0039

# 6. run the power check
sceptre_object <- run_power_check(sceptre_object, parallel = TRUE, n_processors = 2)
#> Running power_check in parallel. Change directories to /var/folders/7v/5sqjgh8j28lgf8qx3gbtq1h00000gp/T//RtmpHhxNRw/sceptre_logs/ and view the files power_check_*.out for progress updates. 
#> 
plot(sceptre_object)

print(sceptre_object)
#> An object of class sceptre_object.
#> 
#> Attributes of the data:
#>45919 cells (44308 after cellwise QC)
#>526 responses
#>High multiplicity-of-infection 
#>70 targeting gRNAs (distributed across 35 targets) 
#>25 non-targeting gRNAs 
#>6 covariates (batch, grna_n_nonzero, grna_n_umis, response_n_nonzero, response_n_umis, response_p_mito)
#> 
#> Analysis status:
#> 	 import_data()
#> 	 set_analysis_parameters()
#> 	 assign_grnas()
#> 	 run_qc()
#> 	 run_calibration_check()
#> 	 run_power_check()
#> 	 run_discovery_analysis()
#> 
#> Analysis parameters: 
#> 	• Discovery pairs: data frame with 610 pairs (599 after pairwise QC)
#> 	• Positive control pairs: data frame with 10 pairs (10 after pairwise QC)
#> 	• Sidedness of test: left
#> 	• Resampling mechanism: conditional resampling
#> 	• gRNA integration strategy: union
#> 	• Resampling approximation: skew normal
#> 	• Multiple testing adjustment: BH at level 0.1
#> 	• N nonzero treatment cells threshold: 7
#> 	• N nonzero control cells threshold: 7
#> 	• Formula object: log(response_n_nonzero) + log(response_n_umis) + log(grna_n_nonzero) + log(grna_n_umis) + batch
#> 
#> gRNA-to-cell assignment information:
#> 	• Assignment method: mixture
#> 	• Mean N cells per gRNA: 567.77
#> 	• Mean N gRNAs per cell (MOI): 1.17 
#> 	• gRNA assignment formula object: log(response_n_nonzero) + log(response_n_umis) + log(grna_n_nonzero) + log(grna_n_umis) + batch
#> 
#> Summary of results:
#> 	• N negative control pairs called as significant: 0/599
#> 	• Mean log-2 FC for negative control pairs: 0.0039
#> 	• Median positive control p-value: 1.1e-137

# 7. run discovery analysis
sceptre_object <- run_discovery_analysis(sceptre_object, parallel = TRUE, n_processors = 2)
#> Running discovery_analysis in parallel. Change directories to /var/folders/7v/5sqjgh8j28lgf8qx3gbtq1h00000gp/T//RtmpHhxNRw/sceptre_logs/ and view the files discovery_analysis_*.out for progress updates. 
#> 
plot(sceptre_object)

print(sceptre_object)
#> An object of class sceptre_object.
#> 
#> Attributes of the data:
#>45919 cells (44308 after cellwise QC)
#>526 responses
#>High multiplicity-of-infection 
#>70 targeting gRNAs (distributed across 35 targets) 
#>25 non-targeting gRNAs 
#>6 covariates (batch, grna_n_nonzero, grna_n_umis, response_n_nonzero, response_n_umis, response_p_mito)
#> 
#> Analysis status:
#> 	 import_data()
#> 	 set_analysis_parameters()
#> 	 assign_grnas()
#> 	 run_qc()
#> 	 run_calibration_check()
#> 	 run_power_check()
#> 	 run_discovery_analysis()
#> 
#> Analysis parameters: 
#> 	• Discovery pairs: data frame with 610 pairs (599 after pairwise QC)
#> 	• Positive control pairs: data frame with 10 pairs (10 after pairwise QC)
#> 	• Sidedness of test: left
#> 	• Resampling mechanism: conditional resampling
#> 	• gRNA integration strategy: union
#> 	• Resampling approximation: skew normal
#> 	• Multiple testing adjustment: BH at level 0.1
#> 	• N nonzero treatment cells threshold: 7
#> 	• N nonzero control cells threshold: 7
#> 	• Formula object: log(response_n_nonzero) + log(response_n_umis) + log(grna_n_nonzero) + log(grna_n_umis) + batch
#> 
#> gRNA-to-cell assignment information:
#> 	• Assignment method: mixture
#> 	• Mean N cells per gRNA: 567.77
#> 	• Mean N gRNAs per cell (MOI): 1.17 
#> 	• gRNA assignment formula object: log(response_n_nonzero) + log(response_n_umis) + log(grna_n_nonzero) + log(grna_n_umis) + batch
#> 
#> Summary of results:
#> 	• N negative control pairs called as significant: 0/599
#> 	• Mean log-2 FC for negative control pairs: 0.0039
#> 	• Median positive control p-value: 1.1e-137
#> 	• N discovery pairs called as significant: 11/599

# 8. write results
write_outputs_to_directory(sceptre_object = sceptre_object, "~/sceptre_outputs_highmoi/")
#> NULL