dcjones / proseg

Probabilistic cell segmentation for in situ spatial transcriptomics
Other
45 stars 3 forks source link

Issue running proseg: assertion failed: end <= axis_len #42

Closed kbestak closed 3 weeks ago

kbestak commented 3 weeks ago

Hi,

I'm testing out Proseg (proseg2 branch) on Molecular Cartography data and I'm using a Docker container specified here: https://github.com/dcjones/proseg/issues/33#issuecomment-2445454714

When I run it with the following command:

docker run -v '/workspace/tmp':/input tbencomo/proseg2 proseg /input/sample_4d_r2_s1_proseg.csv --gene-column 'gene' --cell-id-column 'segmentation' --cell-id-unassigned '0' --x-column 'x' --y-column 'y' --z-column 'z'

I get the following output and error:

Using 16 threads
Read 1071780 transcripts
     12041 cells
     99 genes
Estimated full area: 97799790
Full volume: 3422992600
Using grid size 1427.3427. Chunks: 144
thread 'main' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/ndarray-0.16.1/src/impl_methods.rs:557:22:
assertion failed: end <= axis_len
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

What would be the best way to address this and did I miss something in the command specification?

Many thanks and all the best!

dcjones commented 3 weeks ago

Hi @kbestak,

I haven't tried proseg with a molecular cartography dataset yet. If you could try running proseg again with RUST_BACKTRACE=1 proseg ..., I might be able to determine where the error is happening. Otherwise, I'll try to find a similar dataset and add support.

kbestak commented 3 weeks ago

Hi @dcjones,

Here is the output with RUST_BACKTRACE=1

root@017ba774981f:/usr/src/app# export RUST_BACKTRACE=1
root@017ba774981f:/usr/src/app# proseg /input/sample_4d_r2_s1_proseg.csv --gene-column 'gene' --cell-id-column 'segmentation' --cell-id-unassigned '0' --x-column 'x' --y-column 'y' --z-column 'z'
Using 16 threads
Read 1071780 transcripts
     12041 cells
     99 genes
Estimated full area: 97799790
Full volume: 3422992600
Using grid size 1427.3427. Chunks: 144
thread 'main' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/ndarray-0.16.1/src/impl_methods.rs:557:22:
assertion failed: end <= axis_len
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: ndarray::dimension::do_slice
   4: ndarray::impl_methods::<impl ndarray::ArrayBase<S,D>>::slice_mut
   5: proseg::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Here is the output with RUST_BACKTRACE=full

root@017ba774981f:/usr/src/app# export RUST_BACKTRACE=full
root@017ba774981f:/usr/src/app# proseg /input/sample_4d_r2_s1_proseg.csv --gene-column 'gene' --cell-id-column 'segmentation' --cell-id-unassigned '0' --x-column 'x' --y-column 'y' --z-column 'z'
Using 16 threads
Read 1071780 transcripts
     12041 cells
     99 genes
Estimated full area: 97799790
Full volume: 3422992600
Using grid size 1427.3427. Chunks: 144
thread 'main' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/ndarray-0.16.1/src/impl_methods.rs:557:22:
assertion failed: end <= axis_len
stack backtrace:
   0:     0x561ba292f2ea - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h304520fd6a30aa07
   1:     0x561ba29585db - core::fmt::write::hf5713710ce10ff22
   2:     0x561ba292c443 - std::io::Write::write_fmt::hda708db57927dacf
   3:     0x561ba29305d2 - std::panicking::default_hook::{{closure}}::he1ad87607d0c11c5
   4:     0x561ba293023e - std::panicking::default_hook::h81c8cd2e7c59ee33
   5:     0x561ba2930e5f - std::panicking::rust_panic_with_hook::had2118629c312a4a
   6:     0x561ba2930b13 - std::panicking::begin_panic_handler::{{closure}}::h7fa5985d111bafa2
   7:     0x561ba292f7c9 - std::sys::backtrace::__rust_end_short_backtrace::h704d151dbefa09c5
   8:     0x561ba29307d4 - rust_begin_unwind
   9:     0x561ba1f60273 - core::panicking::panic_fmt::h3eea515d05f7a35e
  10:     0x561ba1f602fc - core::panicking::panic::h102d65dbfa674afe
  11:     0x561ba2161a0c - ndarray::dimension::do_slice::h12f063241887bd25
  12:     0x561ba20abc44 - ndarray::impl_methods::<impl ndarray::ArrayBase<S,D>>::slice_mut::h0dcacca2635a0976
  13:     0x561ba1fd9f81 - proseg::main::hcafb02c3da6b2aa0
  14:     0x561ba20d7e83 - std::sys::backtrace::__rust_begin_short_backtrace::h16ccd830dc490dff
  15:     0x561ba20d7e69 - std::rt::lang_start::{{closure}}::h44fcef564ee3e2f5
  16:     0x561ba2924920 - std::rt::lang_start_internal::h4d90db0530245041
  17:     0x561ba2003d55 - main
  18:     0x7f06a1e5e24a - <unknown>
  19:     0x7f06a1e5e305 - __libc_start_main
  20:     0x561ba1f60ac1 - _start
  21:                0x0 - <unknown>

Thanks for looking into it. Molecular Cartography data is a targeted transcriptomic platform with up to 100 targets here provided with a table with x, y, z and gene columns. I've previously performed segmentation and also added the cell label column to the table. Since I was able to provide arguments for the names of files, I don't think the issue is the data. It is also possible this is an error specific to the Docker container.

Let me know if I can provide anything to help test.

dcjones commented 3 weeks ago

I pushed a fix to the proseg2 branch which is my best guess at what the issue is based on the backtrace. Give that a shot, and let me know if you still get this error.

kbestak commented 3 weeks ago

Thank you, I just recreated the docker image and got a different error (listing out the end, but this appeared many times (per spot?):

thread '<unnamed>' panicked at src/sampler/polyagamma/alternate.rs:215:13:
assertion failed: self.x > 0.0
thread '<unnamed>' panicked at src/sampler/polyagamma/alternate.rs:215:13:
assertion failed: self.x > 0.0
thread '<unnamed>' panicked at src/sampler/polyagamma/alternate.rs:215:13:
assertion failed: self.x > 0.0
thread '<unnamed>' panicked at src/sampler/polyagamma/alternate.rs:215:13:
assertion failed: self.x > 0.0
thread '<unnamed>' panicked at src/sampler/polyagamma/alternate.rs:215:13:
assertion failed: self.x > 0.0
thread '<unnamed>' panicked at src/sampler/polyagamma/alternate.rs:215:13:
assertion failed: self.x > 0.0
thread '<unnamed>' panicked at src/sampler/polyagamma/alternate.rs:215:13:
assertion failed: self.x > 0.0

I have confirmed in my input data the x column has all values above 0.

dcjones commented 3 weeks ago

Ok, that's progress! I think I've fixed this issue now, if you'll update and try once more.

kbestak commented 3 weeks ago

It seems I got first issue again

Using 16 threads
Read 1071780 transcripts
     12041 cells
     99 genes
Estimated full area: 97799790
Full volume: 3422992600
Using grid size 1427.3427. Chunks: 144
thread 'main' panicked at /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/ndarray-0.16.1/src/impl_methods.rs:557:22:
assertion failed: end <= axis_len
stack backtrace:
   0:     0x56552ed541ba - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h304520fd6a30aa07
   1:     0x56552ed7d4ab - core::fmt::write::hf5713710ce10ff22
   2:     0x56552ed51313 - std::io::Write::write_fmt::hda708db57927dacf
   3:     0x56552ed554a2 - std::panicking::default_hook::{{closure}}::he1ad87607d0c11c5
   4:     0x56552ed5510e - std::panicking::default_hook::h81c8cd2e7c59ee33
   5:     0x56552ed55d2f - std::panicking::rust_panic_with_hook::had2118629c312a4a
   6:     0x56552ed559e3 - std::panicking::begin_panic_handler::{{closure}}::h7fa5985d111bafa2
   7:     0x56552ed54699 - std::sys::backtrace::__rust_end_short_backtrace::h704d151dbefa09c5
   8:     0x56552ed556a4 - rust_begin_unwind
   9:     0x56552e385273 - core::panicking::panic_fmt::h3eea515d05f7a35e
  10:     0x56552e3852fc - core::panicking::panic::h102d65dbfa674afe
  11:     0x56552e586a1c - ndarray::dimension::do_slice::h7b34710fdbdce13f
  12:     0x56552e511ff4 - ndarray::impl_methods::<impl ndarray::ArrayBase<S,D>>::slice_mut::h39fe3c8a2322721b
  13:     0x56552e3fef91 - proseg::main::h6bfcb4b1e420190d
  14:     0x56552e4bf633 - std::sys::backtrace::__rust_begin_short_backtrace::h5b4cc7edd217a323
  15:     0x56552e4bf619 - std::rt::lang_start::{{closure}}::h3b3cceaeca754d1c
  16:     0x56552ed497f0 - std::rt::lang_start_internal::h4d90db0530245041
  17:     0x56552e428d65 - main
  18:     0x7fe302eda24a - <unknown>
  19:     0x7fe302eda305 - __libc_start_main
  20:     0x56552e385ac1 - _start
  21:                0x0 - <unknown>
dcjones commented 3 weeks ago

Ah ok, I've pushed another fix. Hopefully third time is the charm.

kbestak commented 3 weeks ago

Thank you so much, it's running now!

Using 16 threads
Read 1071780 transcripts
     12041 cells
     99 genes
Estimated full area: 97799790
Full volume: 3422992600
Using grid size 1427.3427. Chunks: 144
00:16:03 ####-------------------------------------------------------- | log-likelihood: -11484692 | assigned: 604585 / 1071780 (56.41%) | non-background: (51.19%)

For additional context, we're in the process of adding multiple new segmentation options to spatial nf-core pipelines and want to add Proseg.

dcjones commented 3 weeks ago

Very cool! Let me know if I can do anything to help with that.