Open sapiomr opened 1 month ago
Ran into this error on Xenium data. Had to preprocess Xenium data extensively to get it to be compatible with Baysor, but still throwing an error. Seems to be related to some kind of unexpected negative value?
[10:30:44] Info: Algorithm stopped after 602 iterations. Error: 0.00973. Converged: true. [10:30:45] Info: Done [10:31:05] Info: Initializing algorithm. Scale: -1.0, scale std: -2.5, initial #components: 3642150, #molecules: 18210754. [10:39:45] Info: Using the following additional information about molecules: [:confidence, :cluster, :prior_segmentation] [10:39:45] Info: Using 3D coordinates ERROR: LoadError: DomainError with -25.54793000219695: sqrt was called with a negative real argument but will only return a complex result if called with a complex argument. Try sqrt(Complex(x)). Stacktrace: [1] throw_complex_domainerror(f::Symbol, x::Float64) @ Base.Math ./math.jl:33 [2] sqrt @ ./math.jl:686 [inlined] [3] var_posterior(prior_std::Float64, prior_std_std::Float64, eigen_value::Float64; n_samples::Int64, prior_n_samples::Int64) @ Baysor.Processing ~/.julia/packages/Baysor/nJ00T/src/processing/distributions/MvNormal.jl:25 [4] #43 @ ./broadcast.jl:1327 [inlined] [5] macro expansion @ ~/.julia/packages/StaticArrays/O6dgq/src/broadcast.jl:140 [inlined] [6] __broadcast @ ~/.julia/packages/StaticArrays/O6dgq/src/broadcast.jl:128 [inlined] [7] _broadcast @ ~/.julia/packages/StaticArrays/O6dgq/src/broadcast.jl:124 [inlined] [8] copy @ ~/.julia/packages/StaticArrays/O6dgq/src/broadcast.jl:62 [inlined] [9] materialize @ ./broadcast.jl:903 [inlined] [10] var_posterior(prior::Baysor.Processing.ShapePrior{3}, eigen_values::StaticArraysCore.SVector{3, Float64}; n_samples::Int64) @ Baysor.Processing ~/.julia/packages/Baysor/nJ00T/src/processing/distributions/MvNormal.jl:19 [11] adjust_cov_by_prior!(Σ::StaticArraysCore.MMatrix{3, 3, Float64, 9}, prior::Baysor.Processing.ShapePrior{3}; n_samples::Int64) @ Baysor.Processing ~/.julia/packages/Baysor/nJ00T/src/processing/models/Component.jl:45 [12] maximize!(dist::Baysor.Processing.MvNormalF{3, 9}, x::SubArray{Float64, 2, Matrix{Float64}, Tuple{Base.Slice{Base.OneTo{Int64}}, Vector{Int64}}, false}; center_probs::Nothing, shape_prior::Baysor.Processing.ShapePrior{3}, n_samples::Int64) @ Baysor.Processing ~/.julia/packages/Baysor/nJ00T/src/processing/distributions/MvNormal.jl:143 [13] maximize!(c::Baysor.Processing.Component{3}, pos_data::SubArray{Float64, 2, Matrix{Float64}, Tuple{Base.Slice{Base.OneTo{Int64}}, Vector{Int64}}, false}, comp_data::SubArray{Int64, 1, Vector{Int64}, Tuple{Vector{Int64}}, false}; nuclei_probs::Nothing, min_nuclei_frac::Float64) @ Baysor.Processing ~/.julia/packages/Baysor/nJ00T/src/processing/models/Component.jl:25 [14] maximize!(data::Baysor.Processing.BmmData{3}) @ Baysor.Processing ~/.julia/packages/Baysor/nJ00T/src/processing/bmm_algorithm/bmm_algorithm.jl:196 [15] bmm!(data::Baysor.Processing.BmmData{3}; min_molecules_per_cell::Int64, n_iters::Int64, new_component_frac::Float64, new_component_weight::Float64, assignment_history_depth::Int64, verbose::Bool, component_split_step::Int64, refine::Bool) @ Baysor.Processing ~/.julia/packages/Baysor/nJ00T/src/processing/bmm_algorithm/bmm_algorithm.jl:345 [16] bmm! @ ~/.julia/packages/Baysor/nJ00T/src/processing/bmm_algorithm/bmm_algorithm.jl:333 [inlined] [17] run_segmentation(df_spatial::DataFrames.DataFrame, gene_names::Vector{String}, opts::Baysor.Utils.SegmentationOptions; plot_opts::Baysor.Utils.PlottingOptions, min_molecules_per_cell::Int64, estimate_ncvs::Bool, plot::Bool, save_polygons::Bool, run_id::String) @ Baysor.Processing ~/.julia/packages/Baysor/nJ00T/src/processing/utils/cli_wrappers.jl:58 [18] run(coordinates::String, prior_segmentation::String; config::Baysor.Utils.RunOptions, x_column::String, y_column::String, z_column::String, gene_column::String, min_molecules_per_cell::Int64, scale::Float64, scale_std::String, n_clusters::Int64, prior_segmentation_confidence::Float64, output::String, plot::Bool, save_polygons::String, no_ncv_estimation::Bool, count_matrix_format::String) @ Baysor.CommandLine ~/.julia/packages/Baysor/nJ00T/src/cli/main.jl:123 [19] command_main(ARGS::Vector{String}) @ Baysor.CommandLine ~/.julia/packages/Comonicon/AXDxW/src/codegen/julia.jl:343 [20] command_main() @ Baysor.CommandLine ~/.julia/packages/Comonicon/AXDxW/src/codegen/julia.jl:90 [21] command_main(; kwargs::@Kwargs{}) @ Baysor ~/.julia/packages/Baysor/nJ00T/src/Baysor.jl:41
This appears to be due to scale value being set to "-1"
Ran into this error on Xenium data. Had to preprocess Xenium data extensively to get it to be compatible with Baysor, but still throwing an error. Seems to be related to some kind of unexpected negative value?
[10:30:44] Info: Algorithm stopped after 602 iterations. Error: 0.00973. Converged: true. [10:30:45] Info: Done [10:31:05] Info: Initializing algorithm. Scale: -1.0, scale std: -2.5, initial #components: 3642150, #molecules: 18210754. [10:39:45] Info: Using the following additional information about molecules: [:confidence, :cluster, :prior_segmentation] [10:39:45] Info: Using 3D coordinates ERROR: LoadError: DomainError with -25.54793000219695: sqrt was called with a negative real argument but will only return a complex result if called with a complex argument. Try sqrt(Complex(x)). Stacktrace: [1] throw_complex_domainerror(f::Symbol, x::Float64) @ Base.Math ./math.jl:33 [2] sqrt @ ./math.jl:686 [inlined] [3] var_posterior(prior_std::Float64, prior_std_std::Float64, eigen_value::Float64; n_samples::Int64, prior_n_samples::Int64) @ Baysor.Processing ~/.julia/packages/Baysor/nJ00T/src/processing/distributions/MvNormal.jl:25 [4] #43 @ ./broadcast.jl:1327 [inlined] [5] macro expansion @ ~/.julia/packages/StaticArrays/O6dgq/src/broadcast.jl:140 [inlined] [6] __broadcast @ ~/.julia/packages/StaticArrays/O6dgq/src/broadcast.jl:128 [inlined] [7] _broadcast @ ~/.julia/packages/StaticArrays/O6dgq/src/broadcast.jl:124 [inlined] [8] copy @ ~/.julia/packages/StaticArrays/O6dgq/src/broadcast.jl:62 [inlined] [9] materialize @ ./broadcast.jl:903 [inlined] [10] var_posterior(prior::Baysor.Processing.ShapePrior{3}, eigen_values::StaticArraysCore.SVector{3, Float64}; n_samples::Int64) @ Baysor.Processing ~/.julia/packages/Baysor/nJ00T/src/processing/distributions/MvNormal.jl:19 [11] adjust_cov_by_prior!(Σ::StaticArraysCore.MMatrix{3, 3, Float64, 9}, prior::Baysor.Processing.ShapePrior{3}; n_samples::Int64) @ Baysor.Processing ~/.julia/packages/Baysor/nJ00T/src/processing/models/Component.jl:45 [12] maximize!(dist::Baysor.Processing.MvNormalF{3, 9}, x::SubArray{Float64, 2, Matrix{Float64}, Tuple{Base.Slice{Base.OneTo{Int64}}, Vector{Int64}}, false}; center_probs::Nothing, shape_prior::Baysor.Processing.ShapePrior{3}, n_samples::Int64) @ Baysor.Processing ~/.julia/packages/Baysor/nJ00T/src/processing/distributions/MvNormal.jl:143 [13] maximize!(c::Baysor.Processing.Component{3}, pos_data::SubArray{Float64, 2, Matrix{Float64}, Tuple{Base.Slice{Base.OneTo{Int64}}, Vector{Int64}}, false}, comp_data::SubArray{Int64, 1, Vector{Int64}, Tuple{Vector{Int64}}, false}; nuclei_probs::Nothing, min_nuclei_frac::Float64) @ Baysor.Processing ~/.julia/packages/Baysor/nJ00T/src/processing/models/Component.jl:25 [14] maximize!(data::Baysor.Processing.BmmData{3}) @ Baysor.Processing ~/.julia/packages/Baysor/nJ00T/src/processing/bmm_algorithm/bmm_algorithm.jl:196 [15] bmm!(data::Baysor.Processing.BmmData{3}; min_molecules_per_cell::Int64, n_iters::Int64, new_component_frac::Float64, new_component_weight::Float64, assignment_history_depth::Int64, verbose::Bool, component_split_step::Int64, refine::Bool) @ Baysor.Processing ~/.julia/packages/Baysor/nJ00T/src/processing/bmm_algorithm/bmm_algorithm.jl:345 [16] bmm! @ ~/.julia/packages/Baysor/nJ00T/src/processing/bmm_algorithm/bmm_algorithm.jl:333 [inlined] [17] run_segmentation(df_spatial::DataFrames.DataFrame, gene_names::Vector{String}, opts::Baysor.Utils.SegmentationOptions; plot_opts::Baysor.Utils.PlottingOptions, min_molecules_per_cell::Int64, estimate_ncvs::Bool, plot::Bool, save_polygons::Bool, run_id::String) @ Baysor.Processing ~/.julia/packages/Baysor/nJ00T/src/processing/utils/cli_wrappers.jl:58 [18] run(coordinates::String, prior_segmentation::String; config::Baysor.Utils.RunOptions, x_column::String, y_column::String, z_column::String, gene_column::String, min_molecules_per_cell::Int64, scale::Float64, scale_std::String, n_clusters::Int64, prior_segmentation_confidence::Float64, output::String, plot::Bool, save_polygons::String, no_ncv_estimation::Bool, count_matrix_format::String)
@ Baysor.CommandLine ~/.julia/packages/Baysor/nJ00T/src/cli/main.jl:123 [19] command_main(ARGS::Vector{String}) @ Baysor.CommandLine ~/.julia/packages/Comonicon/AXDxW/src/codegen/julia.jl:343 [20] command_main() @ Baysor.CommandLine ~/.julia/packages/Comonicon/AXDxW/src/codegen/julia.jl:90 [21] command_main(; kwargs::@Kwargs{}) @ Baysor ~/.julia/packages/Baysor/nJ00T/src/Baysor.jl:41