10XGenomics / single-cell-3prime-paper

83 stars 35 forks source link

downsample_gene_bc_mtx function error #2

Open chenlingantelope opened 6 years ago

chenlingantelope commented 6 years ago

This might be a system incompatability, but when I try to ran the code, it gave me an error about bc_gene_umi_subsampled not being a data table. Adding the setDT function fixes it.

setDT(bc_gene_umi_subsampled) setkey(bc_gene_umi_subsampled, barcode, gene)

linda66liu commented 5 years ago

I got same error 'x not a data table’ in process 'main_process_pure_pbmc.R'. Error info:

1... Filtering mol info Sorting mol info Aggregating mol info .Subsampling Sorting Error in setkeyv(x, cols, verbose = verbose, physical = physical): x is not a data.table Traceback:

  1. lapply(1:length(all_data), function(i) { . cat(sprintf("%d...\n", i)) . .downsample_gene_bc_mtx(all_json[[i]], all_data[[i]], all_mol_info[[i]], . tgt_rpc, target_type = "conf_mapped_reads")[[1]] . })
  2. FUN(X[[i]], ...)
  3. .downsample_gene_bc_mtx(all_json[[i]], all_data[[i]], all_mol_info[[i]], . tgt_rpc, target_type = "conf_mapped_reads") # at line 3 of file
  4. lapply(tgt_rpc, function(tgt_rpc_i) { . cat(".") . if (target_type == "raw_reads") { . tgt_candidate_reads <- tgt_rpc_i n_cells candidate_read_frac . candidate_rpc <- tgt_candidate_reads/n_cells . raw_reads_per_cell <- tgt_rpc_i . } . else if (target_type == "conf_mapped_reads") { . tgt_candidate_reads <- tgt_rpc_i * n_cells . candidate_rpc <- tgt_candidate_reads/n_cells . raw_reads_per_cell <- candidate_rpc/candidate_read_frac . } . if (tgt_candidate_reads > candidate_reads) { . return(NA) . } . subsample_rate <- tgt_candidate_reads/candidate_reads . cat("Subsampling\n") . bc_gene_umi_subsampled <- bc_gene_umi %>% mutate(reads = rbinom(length(reads), . reads, subsample_rate)) . cat("Sorting\n") . setkey(bc_gene_umi_subsampled, barcode, gene) . cat("Re-aggregating\n") . bc_gene_counts <- bc_gene_umi_subsampled[barcode %in% orig_mat_barcodes, . j = list(count = sum(reads > 0)), by = c("barcode", "gene")] . cat("Building matrix\n") . with(bc_gene_counts, sparseMatrix(i = match(barcode, orig_mat_barcodes), . j = 1 + gene, x = count, dims = dim(orig_matrix_data[[transcriptome]]$mat))) . })
  5. FUN(X[[i]], ...)
  6. setkey(bc_gene_umi_subsampled, barcode, gene)
  7. setkeyv(x, cols, verbose = verbose, physical = physical)
  8. stop("x is not a data.table")

I tried to change with 'all_data_table <- as.data.table(all_data) ' Then, Error in: .downsample_gene_bc_mtx(all_json_table[[i]], all_data_table[[i]], : object 'reads' not found Have no idea.

yasinkaymaz commented 5 years ago

Hi, I have the same issue here:

subsampled_purified_mats <- lapply(1:length(all_data), function(i) { # subsample the matrix to match tgt_rpc cat(sprintf("%d...\n", i)) .downsample_gene_bc_mtx(all_json[[i]], all_data[[i]], all_mol_info[[i]], tgt_rpc, 'conf_mapped_reads')[[1]] } ) 1... Filtering mol info Sorting mol info Aggregating mol info .Subsampling Sorting Error in setkeyv(x, cols, verbose = verbose, physical = physical) : x is not a data.table

yasinkaymaz commented 5 years ago

This might be a system incompatability, but when I try to ran the code, it gave me an error about bc_gene_umi_subsampled not being a data table. Adding the setDT function fixes it.

setDT(bc_gene_umi_subsampled) setkey(bc_gene_umi_subsampled, barcode, gene)

Yes, this works. Need to update the ".downsample_gene_bc_mtx" function in the util.R