Skip to content

Error in geometry::delaunayn(p = spatial_locations[, c(sdimx, sdimy, sdimz), : Received error code 1 from qhull. #45

Description

@samuelikim

Hi I'm running into this error after running the default pipeline, here's the full error message:

Error in geometry::delaunayn(p = spatial_locations[, c(sdimx, sdimy, sdimz), :
Received error code 1 from qhull. Qhull error:
QH6239 Qhull precision error: initial Delaunay input sites are cocircular or cospherical. Use option 'Qz' for the Delaunay triangulation or Voronoi diagram of cocircular/cospherical points; it adds a point "at infinity". Alternatively use option 'QJ' to joggle the input. Use option 'Qs' to search all points for the initial simplex.

input sites with last coordinate projected to a paraboloid

  • p4(v5): 2.1e+03 -3.4e+03 -0.8 5e-11
  • p1(v4): 2.1e+03 -3.4e+03 0.8 2.7e+03
  • p0(v3): 2.1e+03 -3.4e+03 0 3.4e+03
  • p2(v2): 2.1e+03 -3.4e+03 -0.8 2.1e+02
  • p3(v1): 2.1e+03 -3.4e+03 -0.8 5e-11

While executing: | qhull d Qbb T0 Pp Qt
Options selected for Qhull 2020.2.r 2020/08/31:
run-id 1295723442 delaunay Qbbound-last Pprecision-ignore Qtriangulate
_pre-merge _zero-centrum Pgood _max-width 2.8 Error-roundoff 6.9e-12
_one-merge 6.2e-11 _near-inside 3.1e-10 Visible-distance 4.2e-11
U-max-coplanar 4.2e-11 Width-ou

My code isa s follows

run_fastReseg_pipeline <- function(
base_dir,
expr_file_name,
tx_file_name,
output_dir_name = "res2_fullPipeline",
pixel_size = 0.12028,
zstep_size = 0.8,
n_cores = 7,
fov_range = NULL # NEW ARGUMENT
) {

2. Set file paths

expr_file <- file.path(base_dir, expr_file_name)
tx_file <- file.path(base_dir, tx_file_name)

3. Load expression matrix

counts <- fread(expr_file)

--- FILTER BY FOV IF SPECIFIED ---

if (!is.null(fov_range)) {
counts <- counts[fov %in% fov_range, ]
}

Negative probes

neg_cols <- grep("Negative", colnames(counts), value = TRUE)
neg_cols_no_add <- grep("NegativeAdd", neg_cols, value = TRUE, invert = TRUE)

Based on the expression matrix, create a Seurat object, run SCT, up to Clusters

cell_ids <- paste0('c_1_', counts[['fov']], '_', counts[['cell_ID']])
rownames(counts) <- cell_ids
all_rnas <- grep("fov|cell_ID|Negative|SystemControl|huCART19-IL18-huCD19|IDO2",
colnames(counts), value = TRUE, invert = TRUE)
counts_mat <- as.matrix(counts[, .SD, .SDcols = all_rnas])
rownames(counts_mat) <- cell_ids
sparse_counts <- as(counts_mat, "dgCMatrix")
sparse_counts <- t(sparse_counts) # Transpose after making sparse
seu <- CreateSeuratObject(counts = sparse_counts)

seu <- SCTransform(seu, verbose = FALSE)
seu <- RunPCA(seu, verbose = FALSE, npcs = 50)
seu <- FindNeighbors(seu, reduction = "pca", dims = 1:30)
seu <- FindClusters(seu, resolution = 1.2, algorithm = 4)

4. Load and process transcript file

fullTx <- data.table::fread(tx_file)
if (!is.null(fov_range)) {
fullTx <- fullTx[fov %in% fov_range, ]
}
fullTx[['transcript_id']] <- seq_len(nrow(fullTx))
fullTx <- fullTx[cell_ID != 0, ]
fullTx <- fullTx[, .SD, .SDcols = c('transcript_id', 'cell', 'x_global_px',
'y_global_px', 'z', 'target', 'fov')]

5. Set parameters

clust <- as.character(seu$seurat_clusters)
names(clust) <- colnames(seu)

outDir_full <- file.path(base_dir, output_dir_name)
options(mc.cores = n_cores)

6. Run FastReseg pipeline

refineAll_res <- FastReseg::fastReseg_full_pipeline(
counts = counts_mat,
clust = clust,
refProfiles = NULL,
transcript_df = fullTx,
transDF_fileInfo = NULL,
filepath_coln = 'file_path',
prefix_colns = NULL,
fovOffset_colns = c('stage_Y','stage_X'),
pixel_size = pixel_size,
zstep_size = zstep_size,
transID_coln = 'transcript_id',
transGene_coln = "target",
cellID_coln = "cell",
spatLocs_colns = c('x_global_px', 'y_global_px', 'z'),
extracellular_cellID = NULL,
flagModel_TransNum_cutoff = 50,
molecular_distance_cutoff = 2.7,
cellular_distance_cutoff = NULL,
score_baseline = NULL,
lowerCutoff_transNum = NULL,
higherCutoff_transNum = NULL,
imputeFlag_missingCTs = TRUE,
flagCell_lrtest_cutoff = 5,
svmClass_score_cutoff = -2,
groupTranscripts_method = "dbscan",
spatialMergeCheck_method = "leidenCut",
cutoff_spatialMerge = 0.5,
path_to_output = outDir_full,
save_intermediates = TRUE,
return_perCellData = TRUE,
combine_extra = FALSE,
ctrl_genes = neg_cols_no_add
)

return(refineAll_res)
}

refineAll_res <- run_fastReseg_pipeline(
base_dir = base_dir,
expr_file_name = "test.csv.gz",
tx_file_name = "test.csv.gz",
output_dir_name = "res2_fullPipeline_06202025",
pixel_size = 0.12028,
zstep_size = 0.8,
n_cores = 7
)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions