Katsevich-Lab / sceptre

An R package for single-cell CRISPR screen data analysis emphasizing statistical rigor, massive scalability, and ease of use.
https://katsevich-lab.github.io/sceptre/
GNU General Public License v3.0
26 stars 8 forks source link

object '_sceptre_threshold_count_matrix' not found #63

Closed yaxiliu-1996 closed 11 months ago

yaxiliu-1996 commented 1 year ago

Thanks for the launch of excellent SCEPTRE (0.9.0) ! as I didn't get the 0.9.1 release. I encountered several issues seeming to be some function missing:

  1. When I run construct_cis_pairs(), the error is reported : object '_sceptre_compute_genes_within_distance' not found edit(construct_cis_pairs), it goes like function (sceptre_object, positive_control_pairs = data.frame(), distance_threshold = 500000L, response_position_data_frame = gene_position_data_frame_grch38) { if (!all(colnames(response_position_data_frame) %in% c("response_id", "chr", "position"))) { stop("response_position_data_frame must contain columns 'response_id', 'chr', and 'position'.") } grna_target_data_frame <- data.table::as.data.table(sceptre_object@grna_target_data_frame) response_ids <- rownames(sceptre_object@response_matrix) distance_threshold <- as.integer(distance_threshold) grna_targets_to_exclude <- c("non-targeting", as.character(positive_control_pairs$grna_target)) grna_target_data_frame <- dplyr::filter(grna_target_data_frame, !(grna_target %in% grna_targets_to_exclude)) response_position_data_frame <- dplyr::filter(response_position_data_frame, response_id %in% response_ids) unique_chrs <- unique(grna_target_data_frame$chr) out_pairs <- dplyr::select(as.data.frame(data.table::rbindlist(lapply(X = unique_chrs, FUN = function(unique_chr) { response_position_data_frame_curr_chr <- response_position_data_frame[response_position_data_frame$chr == unique_chr, ] response_posits <- response_position_data_frame_curr_chr$position response_ids <- response_position_data_frame_curr_chr$response_id grna_target_data_frame_curr_chr <- grna_target_data_frame[grna_target_data_frame$chr == unique_chr, ] unique_grna_targets <- unique(grna_target_data_frame_curr_chr$grna_target) data.table::rbindlist(lapply(X = unique_grna_targets, FUN = function(unique_grna_target) { x <- grna_target_data_frame_curr_chr[grna_target_data_frame_curr_chr$grna_target == unique_grna_target, ] min_posit <- min(x$start) max_posit <- max(x$end) midpoint <- as.integer(floor((min_posit + max_posit)/2)) paired_responses <- response_ids[compute_genes_within_distance(midpoint, response_posits, distance_threshold)] if (length(paired_responses) >= 1L) { data.table::data.table(response_id = paired_responses, grna_target = unique_grna_target) } else { NULL } })) }))), grna_target, response_id) return(out_pairs) }

    However, i have no problems to run the construct_trans_pairs().
  2. When I run assign_grnas(), the error is reported: object '_sceptre_threshold_count_matrix' not found, or object '_sceptre_compute_n_grnas_per_cell_vector' not found edit(assign_grnas), it shows: function (sceptre_object, method = "default", print_progress = TRUE, parallel = FALSE, ...) { sceptre_object <- perform_status_check_and_update(sceptre_object, "assign_grnas") if (identical(method, "default")) { method <- if (sceptre_object@low_moi) "maximum" else "mixture" } hyperparameters_default <- if (method == "maximum") { list(umi_fraction_threshold = 0.8) } else if (method == "thresholding") { list(threshold = 5) } else if (method == "mixture") { list(n_em_rep = 5L, pi_guess_range = c(1e-05, 0.1), g_pert_guess_range = log(c(10, 5000)), n_nonzero_cells_cutoff = 10L, backup_threshold = 5, probability_threshold = 0.8, formula_object = auto_construct_formula_object(cell_covariates = sceptre_object@covariate_data_frame, include_grna_covariates = TRUE)) } hyperparameters <- list(...) if (length(hyperparameters) == 0L) hyperparameters <- hyperparameters_default for (hyperparam_name in names(hyperparameters)) hyperparameters_default[[hyperparam_name]] <- hyperparameters[[hyperparam_name]] hyperparameters <- hyperparameters_default invisible(check_assign_grna_inputs(sceptre_object, method, hyperparameters)) reset_response_precomps <- sceptre_object@low_moi && (!identical(sceptre_object@grna_assignment_method, method) || !identical(sceptre_object@grna_assignment_hyperparameters, hyperparameters)) if (reset_response_precomps) sceptre_object@response_precomputations <- list() sceptre_object@grna_assignment_method <- method sceptre_object@grna_assignment_hyperparameters <- hyperparameters sceptre_object <- assign_grnas_to_cells(sceptre_object, print_progress, parallel) return(sceptre_object) }

Could you help me to solve the above issues? Thanks so much !

timothy-barry commented 1 year ago

Hi, thanks for opening the issue.

It seems that some (or all) of the C++ functions are not visible. Could you please let me know what happens when you enter the following in the console?

sceptre:::compute_cell_covariates_cpp

Next, what happens when you enter this?

sceptre:::compute_genes_within_distance

Finally, what happens when you enter this?

sceptre:::compute_genes_within_distance(midpoint = 10,
gene_tss_posits = as.integer(c(5, 10, 12)),
distance_threshold = 2L)
yaxiliu-1996 commented 1 year ago

Thank you so much for the reply !

sceptre:::compute_cell_covariates_cpp _function (i, p, x, n_genes, n_cells, mt_gene_idxs, compute_p_mito) { .Call(_sceptre_compute_cell_covariates_cpp, i, p, x, n_genes, n_cells, mt_gene_idxs, compute_p_mito) } <bytecode: 0x563cee130060>

_ `sceptre:::compute_genes_within_distance` _function (midpoint, gene_tss_posits, distance_threshold) { .Call(`_sceptre_compute_genes_within_distance`, midpoint, gene_tss_posits, distance_threshold) } _ ``` sceptre:::compute_genes_within_distance(midpoint = 10, + gene_tss_posits = as.integer(c(5, 10, 12)), + distance_threshold = 2L) ``` _Error in sceptre:::compute_genes_within_distance(midpoint = 10, gene_tss_posits = as.integer(c(5, : object '_sceptre_compute_genes_within_distance' not found_
timothy-barry commented 1 year ago

Got it. Followup question: are you able to call the import_data() function without problems?

My first recommendation would be to delete and reinstall the sceptre package. Please see this portion of the FAQ for instructions on how to do this. If this does not work, then we can continue to troubleshoot.

yaxiliu-1996 commented 1 year ago

I can call import_data() without problems. I follow your recommendation and reinstall the sceptre 0.9.1, but still does not work and the same error exists when I call construct_cis_pairs .

Error in compute_genes_within_distance(midpoint, response_posits, distance_threshold) : object '_sceptre_compute_genes_within_distance' not found

timothy-barry commented 1 year ago

I see. And can you let me know what happens when you run the following code?

sceptre:::obtain_pointer_vector(i = as.integer(c(0, 5, 9, 10)), dim = 10L)
yaxiliu-1996 commented 1 year ago

Sure, I got this:

sceptre:::obtain_pointer_vector(i = as.integer(c(0, 5, 9, 10)), dim = 10L) [1] 0 1 1 1 1 1 2 2 2 2 3

timothy-barry commented 1 year ago

OK, so we have confirmed that some C++ functions are visible but others are not. Unfortunately, it is not clear why this is the case. I am really sorry, but I have not seen this before and I do not think I have a solution. Do you have access to another computer that you could try? For example, a cluster or a lab desktop or something? It should also be possible to use sceptre on a cloud service like AWS or Azure.

yaxiliu-1996 commented 1 year ago

OK. I will have a try. Thanks a lot !

timothy-barry commented 1 year ago

Great. Please let me know how that goes! (I'm keeping this thread open 🙂)

timothy-barry commented 1 year ago

Hi, is there any update on this? :)

timothy-barry commented 11 months ago

Hi, I am closing this issue. Feel free to open another issue if you encounter further problems.