Skip to content

Support the Baysor Cpp implementation - #430

Merged
quentinblampey merged 5 commits into
mainfrom
baysor_cpp_support
Aug 21, 2026
Merged

quentinblampey merged 5 commits into
mainfrom
baysor_cpp_support

Conversation

@alihamraoui

@alihamraoui alihamraoui commented Jun 24, 2026 •

Copy link
Copy Markdown
Collaborator

This PR adds support for Baysor C++ v0.8.2 (issue #427).

What changed

  • Added -o . to the Baysor command so the outputs are written directly into the patch directory instead of a segmentation.csv/ subfolder.

Reverted changes

  • Re-read segmentation_counts.loom with loompy using validate=False and rebuild the AnnData with the correct orientation. The Baysor C++ implementation writes the matrix transposed (cells × genes) relative to the Loom spec (genes × cells), which makes read_loom reject the file.

Loom is not well maintained and supports only a subset of anndata features. The anndata.io.read_loom reader is also deprecated since anndata 0.13 (see https://anndata.readthedocs.io/en/latest/generated/anndata.io.read_loom.html). Switching the Baysor command to TSV output might be the better long-term option.

@quentinblampey

Closes #427

@quentinblampey quentinblampey left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two naive questions (because I didn't try the new version):

  1. The original issue mentions Baysor segmentation fails: missing config.toml, but in the command line you only change the output location, so how did it fix the config.toml issue? Or maybe the issue the user had was not related to the new baysor version?
  2. One other question about backward compatibility (see my review comment)

Switching the Baysor command to TSV output might be the better long-term option.

If Baysor always output a TSV (in both >=0.8 and <0.8 versions) then, yes definitely, it would avoid this read_loom complexity

prior_suffix = f" :{prior_shapes_key}" if prior_shapes_key else "" # use a prior segmentation

return f"{baysor_executable_path} run {polygon_format} -c config.toml transcripts.csv" + prior_suffix
return f"{baysor_executable_path} run {polygon_format} -c config.toml transcripts.csv -o ." + prior_suffix

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it also work with the previous baysor versions? In baysor<0.8, -o is the path to one single file, so I'm not sure what happens if the output file is .?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I tested it on v0.7.1 and cpp_v0.8.2, and it works. The -o option specifies the output path. In cpp_v0.8.2, however, it defaults to segmentation.csv, which is a bit confusing. 😕

@alihamraoui

alihamraoui commented Jun 24, 2026 •

Copy link
Copy Markdown
Collaborator Author

I'm not sure why the user mentioned a missing config.toml.

I think the error message non-zero exit status 0 actually indicates that the command executed successfully, but the output was not what Sopa expected.

I was able to reproduce the same message simply by switching to the Baysor C++ version:

Command '/Users/.../.julia/bin/baysor run --polygon-format GeometryCollection -c config.toml transcripts.csv :sopa_prior'
returned non-zero exit status 0

The fix resolves the issue. But let's switch to TSV output by adding --count-matrix-format tsv to the Baysor command. That should work for all versions.

@quentinblampey
quentinblampey merged commit 500beeb into main Aug 21, 2026
20 checks passed
@quentinblampey
quentinblampey deleted the baysor_cpp_support branch August 21, 2026 13:03
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

Successfully merging this pull request may close these issues.

[Bug] Baysor segmentation fails: missing config.toml

2 participants