kharchenkolab / Baysor

Bayesian Segmentation of Spatial Transcriptomics Data
MIT License
142 stars 29 forks source link

Error when providing prior segmentation mask #75

Closed sebgoti closed 12 months ago

sebgoti commented 1 year ago

Hi Viktor, I am getting the following error when providing a prior segmentation mask (I have tried both with mine and also the one you use on your 'iss' example):

❯ ~/.julia/bin/baysor run pciSeq_3-3.csv DAPI_3-3_mask.tif -x x -y y -g gene -m 8 -s 20 --save-polygons GeoJSON -p
[11:13:16] Info: Run R835f1d812
[11:13:17] Info: (2023-05-10) Run Baysor v0.6.0
[11:13:17] Info: Loading data...
[11:13:23] Info: Loaded 1228540 transcripts
[11:13:29] Info: Loading segmentation mask...
[11:14:02] Info: Done
[11:14:02] Info: Estimating prior segmentation polygons...
ERROR: LoadError: MethodError: no method matching getindex(::Int64, ::StepRange{Int64, Int64}, ::StepRange{Int64, Int64})
Closest candidates are:
  getindex(::Number) at number.jl:95
  getindex(::Union{AbstractChar, Number}, ::CartesianIndex{0}) at multidimensional.jl:867
  getindex(::Number, ::Integer) at number.jl:96
  ...
Stacktrace:
  [1] load_prior_segmentation!(df_spatial::DataFrames.DataFrame, prior_segmentation::String, opts::Baysor.Utils.SegmentationOptions; min_molecules_per_cell::Int64, min_molecules_per_segment::Int64, plot::Bool)
    @ Baysor.CommandLine ~/.julia/packages/Baysor/gSCBA/src/cli/main.jl:208
  [2] 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/scratchspaces/cc9f9468-1fbe-11e9-0acf-e9460511877c/sysimg/libbaysor.dylib:-1
  [3] command_main(ARGS::Vector{String})
    @ Baysor.CommandLine ~/.julia/scratchspaces/cc9f9468-1fbe-11e9-0acf-e9460511877c/sysimg/libbaysor.dylib:-1
  [4] command_main()
    @ Baysor.CommandLine ~/.julia/packages/Comonicon/rMXvw/src/codegen/julia.jl:90
  [5] command_main(; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Baysor ~/.julia/packages/Baysor/gSCBA/src/Baysor.jl:34
  [6] command_main()
    @ Baysor ~/.julia/packages/Baysor/gSCBA/src/Baysor.jl:34
  [7] top-level scope
    @ ~/.julia/bin/baysor:15
  [8] include_string(mapexpr::typeof(identity), mod::Module, code::String, filename::String)
    @ Base ~/.julia/scratchspaces/cc9f9468-1fbe-11e9-0acf-e9460511877c/sysimg/libbaysor.dylib:-1
  [9] _include(mapexpr::Function, mod::Module, _path::String)
    @ Base ~/.julia/scratchspaces/cc9f9468-1fbe-11e9-0acf-e9460511877c/sysimg/libbaysor.dylib:-1
 [10] include(mod::Module, _path::String)
    @ Base ~/.julia/scratchspaces/cc9f9468-1fbe-11e9-0acf-e9460511877c/sysimg/libbaysor.dylib:-1
 [11] exec_options(opts::Base.JLOptions)
    @ Base ~/.julia/scratchspaces/cc9f9468-1fbe-11e9-0acf-e9460511877c/sysimg/libbaysor.dylib:-1
 [12] _start()
    @ Base ~/.julia/scratchspaces/cc9f9468-1fbe-11e9-0acf-e9460511877c/sysimg/libbaysor.dylib:-1
in expression starting at /Users/segonzal/.julia/bin/baysor:15

However, the analysis works well when giving the exact same arguments as above but without including the mask. Have gotten the same error on both MacOS and Centos-Linux.

reillyeo commented 1 year ago

I've had the same issue. Not sure what the problem is but it suffices to just omit -p from your run command. It will no longer generate a plot of your polygons, but will still produce the json file

VPetukhov commented 1 year ago

It might be related to https://github.com/kharchenkolab/Baysor/pull/72 . Could you please try v0.6.1?