Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error estimating prior segmentation polygons #32

Closed
GMaciag opened this issue Dec 7, 2021 · 1 comment
Closed

Error estimating prior segmentation polygons #32

GMaciag opened this issue Dec 7, 2021 · 1 comment

Comments

@GMaciag
Copy link

GMaciag commented Dec 7, 2021

Hi Viktor

This looks like such a great package, thank you very much for it. I tried using it on my own data while supplying prior segmentation from a DAPI staining, but I get an error. I tried both segmenting on my own with Mesmer (DeepCell) as well as in ImageJ following your tutorial in Readme. Both times it failed with the same error message.

Command:
baysor run -x x_c -y y_c -z z_c --gene gene -o ./results_C1-2/ -i 500 --force-2d -p --n-clusters 7 ../C1-2_results.txt ../C1-2_segmented_fiji.tif

Output:

┌ Warning: No config file provided. Using default parameters.
└ @ Baysor ~/.julia/packages/Baysor/tda03/src/cli/main.jl:96
[14:22:30] Info: (2021-12-07) Run Baysor v0.5.1
[14:22:30] Info: Loading data...
[14:22:48] Info: Loaded 126550 transcripts
[14:22:49] Info: Loading segmentation mask...
[14:23:05] Info: Done
[14:23:05] Info: Estimating prior segmentation polygons...
[14:23:10] Error: MethodError(LightGraphs.kruskal_mst, ({165106, 163115} undirected simple Int64 graph with Float64 weights,), 0x0000000000007b62)
|
|                 border_mst(border_points::Vector{Vector{UInt32}}; min_edge_length::Float64, max_edge_length::Float64) at boundary_estimation.jl:65
|                 border_mst(border_points::Vector{Vector{UInt32}}) at boundary_estimation.jl:42
|                 _broadcast_getindex_evalf at broadcast.jl:670 [inlined]
|                 _broadcast_getindex at broadcast.jl:643 [inlined]
|                 getindex at broadcast.jl:597 [inlined]
|                 copy at broadcast.jl:943 [inlined]
|                 materialize at broadcast.jl:904 [inlined]
|                 extract_polygons_from_label_grid(grid_labels::Matrix{UInt32}; min_border_length::Int64, shape_method::Symbol, max_dev::Float64, exclude_labels::Vector{Int64}, offset::Vector{Float64}, grid_step::Float64) at boundary_estimation.jl:231
|                 (::Baysor.var"#extract_polygons_from_label_grid##kw")(::NamedTuple{(:grid_step,), Tuple{Float64}}, ::typeof(Baysor.extract_polygons_from_label_grid), grid_labels::Matrix{UInt32}) at boundary_estimation.jl:223
|                 load_prior_segmentation(df_spatial::DataFrames.DataFrame, args::Dict{String, Any}) at main.jl:297
|                 load_and_preprocess_data!(args::Dict{String, Any}) at main.jl:335
|                 run_cli_main(args::Vector{String}) at main.jl:442
|                 run_cli(args::Vector{String}) at common.jl:118
|                 run_cli() at common.jl:103
|                 top-level scope at baysor:3
|                 eval at boot.jl:373 [inlined]
|                 include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String) at loading.jl:1196
|                 _include(mapexpr::Function, mod::Module, _path::String) at loading.jl:1253
|                 include(mod::Module, _path::String) at Base.jl:420
|                 exec_options(opts::Base.JLOptions) at client.jl:292
|                 _start() at client.jl:495
└ Baysor /Users/xvk205/.julia/packages/Baysor/tda03/src/cli/common.jl:132

EDIT:

I've just tried running it without any prior segmentation (only providing the scale parameter) and I'm getting a similar error.

Command:
baysor run -x x_c -y y_c -z z_c --gene gene -o ./results_C1-2/ -i 500 --force-2d -p --n-clusters 7 -s 40 ../C1-2_results.txt

Output:

┌ Warning: No config file provided. Using default parameters.
└ @ Baysor ~/.julia/packages/Baysor/tda03/src/cli/main.jl:96
[14:55:31] Info: (2021-12-07) Run Baysor v0.5.1
[14:55:31] Info: Loading data...
[14:55:50] Info: Loaded 126550 transcripts
[14:55:51] Info: Estimating noise level
[14:55:57] Info: Done
[14:55:59] Info: Clustering molecules...
Progress: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| Time: 0:00:14
  Iteration:                  306
  Max. difference:            0.0010753232764250476
  Fraction of probs changed:  0.6586013433425524
[14:56:17] Info: Algorithm stopped after 306 iterations. Error: 0.00108. Converged: true.
[14:56:17] Info: Done
[14:56:19] Info: Initializing algorithm. Scale: 40.0, scale std: 10.0, initial #components: 84366, #molecules: 126550.
[14:56:21] Info: Using 2D coordinates
Progress: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| Time: 0:01:28
  Iteration:        500
  Noise level, %:   22.36
  Num. components:  1455
[14:57:55] Info: Processing complete.
[14:58:02] Info: Estimating local colors
[14:58:32] Info: Saving results to ./results_C1-2/segmentation.csv
[14:58:33] Info: Plot diagnostics
[14:59:38] Info: Estimating boundary polygons
[15:00:07] Error: MethodError(LightGraphs.kruskal_mst, ({144, 157} undirected simple Int64 graph with Float64 weights,), 0x0000000000007b62)
|
|                 border_mst(border_points::Vector{Vector{UInt32}}; min_edge_length::Float64, max_edge_length::Float64) at boundary_estimation.jl:65
|                 border_mst(border_points::Vector{Vector{UInt32}}) at boundary_estimation.jl:42
|                 _broadcast_getindex_evalf at broadcast.jl:670 [inlined]
|                 _broadcast_getindex at broadcast.jl:643 [inlined]
|                 getindex at broadcast.jl:597 [inlined]
|                 copy at broadcast.jl:943 [inlined]
|                 materialize at broadcast.jl:904 [inlined]
|                 extract_polygons_from_label_grid(grid_labels::Matrix{UInt16}; min_border_length::Int64, shape_method::Symbol, max_dev::Float64, exclude_labels::Vector{Int64}, offset::Vector{Float64}, grid_step::Float64) at boundary_estimation.jl:231
|                 (::Baysor.var"#extract_polygons_from_label_grid##kw")(::NamedTuple{(:min_border_length, :shape_method, :max_dev, :exclude_labels, :offset, :grid_step), Tuple{Int64, Symbol, Float64, Vector{Int64}, Vector{Float64}, Float64}}, ::typeof(Baysor.extract_polygons_from_label_grid), grid_labels::Matrix{UInt16}) at boundary_estimation.jl:223
|                 boundary_polygons(pos_data::Matrix{Float64}, cell_labels::Vector{Int64}; min_x::Nothing, max_x::Nothing, grid_step::Float64, min_border_length::Int64, shape_method::Symbol, max_dev::Float64, bandwidth::Float64, exclude_labels::Vector{Int64}, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}) at boundary_estimation.jl:270
|                 boundary_polygons at boundary_estimation.jl:254 [inlined]
|                 #boundary_polygons#214 at boundary_estimation.jl:248 [inlined]
|                 (::Baysor.var"#boundary_polygons##kw")(::NamedTuple{(:grid_step, :bandwidth), Tuple{Float64, Float64}}, ::typeof(Baysor.boundary_polygons), spatial_df::DataFrames.DataFrame, args::Vector{Int64}) at boundary_estimation.jl:248
|                 plot_transcript_assignment_panel(df_res::DataFrames.DataFrame, assignment::Vector{Int64}, args::Dict{String, Any}; clusters::Vector{Int64}, prior_polygons::Vector{Matrix{Float64}}, gene_colors::Vector{ColorTypes.Lab{Float64}}) at main.jl:212
|                 (::Baysor.var"#plot_transcript_assignment_panel##kw")(::NamedTuple{(:clusters, :prior_polygons, :gene_colors), Tuple{Vector{Int64}, Vector{Matrix{Float64}}, Vector{ColorTypes.Lab{Float64}}}}, ::typeof(Baysor.plot_transcript_assignment_panel), df_res::DataFrames.DataFrame, assignment::Vector{Int64}, args::Dict{String, Any}) at main.jl:205
|                 save_segmentation_results(bm_data::Baysor.BmmData{2}, gene_names::Vector{String}, args::Dict{String, Any}; mol_clusts::NamedTuple{(:exprs, :assignment, :diffs, :assignment_probs, :change_fracs), Tuple{Matrix{Float64}, Vector{Int64}, Vector{Float64}, Matrix{Float64}, Vector{Float64}}}, comp_segs::Nothing, prior_polygons::Vector{Matrix{Float64}}) at main.jl:414
|                 (::Baysor.var"#save_segmentation_results##kw")(::NamedTuple{(:mol_clusts, :comp_segs, :prior_polygons), Tuple{NamedTuple{(:exprs, :assignment, :diffs, :assignment_probs, :change_fracs), Tuple{Matrix{Float64}, Vector{Int64}, Vector{Float64}, Matrix{Float64}, Vector{Float64}}}, Nothing, Vector{Matrix{Float64}}}}, ::typeof(Baysor.save_segmentation_results), bm_data::Baysor.BmmData{2}, gene_names::Vector{String}, args::Dict{String, Any}) at main.jl:394
|                 run_cli_main(args::Vector{String}) at main.jl:479
|                 run_cli(args::Vector{String}) at common.jl:118
|                 run_cli() at common.jl:103
|                 top-level scope at baysor:3
|                 eval at boot.jl:373 [inlined]
|                 include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String) at loading.jl:1196
|                 _include(mapexpr::Function, mod::Module, _path::String) at loading.jl:1253
|                 include(mod::Module, _path::String) at Base.jl:420
|                 exec_options(opts::Base.JLOptions) at client.jl:292
|                 _start() at client.jl:495
└ Baysor /Users/xvk205/.julia/packages/Baysor/tda03/src/cli/common.jl:132
@VPetukhov
Copy link
Collaborator

Hi @GMaciag ,
Probably it's not relevant anymore, but the new version of the package (v0.6) uses a different method for polygon estimation and shouldn't have this error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants