kharchenkolab / Baysor

Bayesian Segmentation of Spatial Transcriptomics Data
https://kharchenkolab.github.io/Baysor/
MIT License
152 stars 31 forks source link

ERROR: MethodError: no method matching boundary_polygons_from_grid(::Matrix{UInt32}; grid_step::Float64) #82

Closed sarahyk closed 1 year ago

sarahyk commented 1 year ago

Hi all, I'm using the new v0.6.1 version of Baysor and version 1.9.0 of julia on resolve data but get this error when using the basyor run command:

[10:18:56] Info: Run R2f79db67c
[10:18:56] Info: (2023-06-08) Run Baysor v0.6.1
[10:18:56] Info: Loading data...
[10:18:59] Info: Loaded 1840683 transcripts
[10:19:05] Info: Loading segmentation mask...
[10:19:08] Info: Done
[10:19:08] Info: Estimating prior segmentation polygons...
ERROR: MethodError: no method matching boundary_polygons_from_grid(::Matrix{UInt32}; grid_step::Float64)

Closest candidates are:
  boundary_polygons_from_grid(::Matrix{<:Unsigned}) got unsupported keyword argument "grid_step"
   @ Baysor /home/viktor_petukhov/.julia/dev/Baysor/src/processing/data_processing/boundary_estimation.jl:67
  boundary_polygons_from_grid(::Matrix{<:Unsigned}, ::Int64) got unsupported keyword argument "grid_step"
   @ Baysor /home/viktor_petukhov/.julia/dev/Baysor/src/processing/data_processing/boundary_estimation.jl:67

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 /home/viktor_petukhov/.julia/dev/Baysor/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 /home/viktor_petukhov/.julia/dev/Baysor/src/cli/main.jl:108
 [3] command_main(ARGS::Vector{String})
   @ Baysor.CommandLine /home/viktor_petukhov/.julia/packages/Comonicon/rMXvw/src/codegen/julia.jl:343
 [4] command_main
   @ /home/viktor_petukhov/.julia/packages/Comonicon/rMXvw/src/codegen/julia.jl:90 [inlined]
 [5] julia_main()
   @ Baysor.CommandLine /home/viktor_petukhov/.julia/packages/Comonicon/rMXvw/src/frontend/cast.jl:481
 [6] julia_main(; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ Baysor /home/viktor_petukhov/.julia/dev/Baysor/src/Baysor.jl:42
 [7] julia_main()
   @ Baysor /home/viktor_petukhov/.julia/dev/Baysor/src/Baysor.jl:42
 [8] top-level scope
   @ none:1

I'm not quite sure what's going wrong or how to troubleshoot, so any help would be appreciated! The same data is able to be successfully processed using v0.5.1.

pakiessling commented 1 year ago

@VPetukhov

Can confirm that v0.6.1 and v.0.6.0 binaries produce the error on starmap example data when using prior segmentation. Let me know if I can help somehow, would really love to use the package!

sarahyk commented 1 year ago

hi @pakiessling, have you had any success running the newer version of baysor through other installation methods like docker? I've been trying to find a solution to get this to run, but haven't had any luck yet

pakiessling commented 1 year ago

@sarahyk I did some more investigating and was able to avoid the boundary_polygons_from_grid error by removing the report flag from my command like this: baysor run -c ./data/starmap.toml -o ./output_dapi_star_nohup ./data/molecules.csv ./data/segmentation.tiff The bad news is that no output at all is generated, just a log file with the last entry Processing complete...

This is also happening in the docker for me 😞

78 mentions downgrading julia to 1.8.5 so I will give that a shot next...

pakiessling commented 1 year ago

@sarahyk Managed to get baysor 0.6.1 to work. The key is to downgrade Julia to 1.8.5 like so:

conda create -y -n baysor-test julia=1.8.5
conda activate baysor-test
julia -e 'using Pkg; Pkg.add(PackageSpec(url="https://github.com/kharchenkolab/Baysor.git")); Pkg.build()'

After that I tested baysor on the test osmfish data:

export JULIA_NUM_THREADS=30
baysor  run \
-c ./data/osmfish.toml -o ./output_osmfish3 -p --save-polygons=geojson ./data/mRNA_coords_raw_counting.csv :random

and received reports, the csv's and polygons 🥳

harrymueller commented 1 year ago

Hi, I'm getting a similar issue with Baysor 0.6.1 and Julia 1.8.5 on Vizgen MERFISH data: ERROR: LoadError: MethodError: no method matching boundary_polygons_from_grid(::Matrix{UInt32}; grid_step=5.0).

Command: baysor+1.8.5 run ./transcript_subset_0.csv -o ./baysor-output -c ./baysor.toml --save-polygons GeoJSON --plot --count-matrix-format loom ./bin_mask.tiff

I've attached the stack trace, along with the configuration TOML:

This only occurs when passing in the pre-segmented image, Baysor works fine without the image.

Additionally, the OSM-FISH example and the ISS example do not work - the same error occurs.

HaojiaWu commented 1 year ago

I am getting the same error. Have to go back to v0.5.1... @VPetukhov can you take a look?

VPetukhov commented 1 year ago

Hi everyone, Thanks for the report! Fixed that in the dev branch. Will release it with v0.6.2 soon.

VPetukhov commented 1 year ago

v0.6.2 is released now, so should be fixed