Skip to content

[r] Write ragged arrays relatively#4450

Open
mojaveazure wants to merge 9 commits into
mainfrom
phoffman/soma-906-r-mixed-uri-types-in-somaexperiments-created-via
Open

[r] Write ragged arrays relatively#4450
mojaveazure wants to merge 9 commits into
mainfrom
phoffman/soma-906-r-mixed-uri-types-in-somaexperiments-created-via

Conversation

@mojaveazure

@mojaveazure mojaveazure commented Apr 23, 2026

Copy link
Copy Markdown
Member

Calling write_soma() on a Seurat v5 object with ragged arrays using an absolute file URI (eg. /home/user/directory) resulted in the SOMA NDArrays for the ragged Seurat matrices having absolute URIs instead of the intuitive relative arrays. This PR changes URI setting to be relative in this case

Modified SOMA methods:

  • SOMACollectionBase$add_new_sparse_ndarray(): now takes a parameter relative; defaults to TRUE
  • write_soma() methods for Seurat, SingleCellExperiment, and SummarizedExperiment: disallow passing arguments via ...
  • write_soma() methods for Assay, Assay5, DimReduc, Graph, and SeuratCommand properly pass relative to other write-methods

Fixes SOMA-906

@mojaveazure
mojaveazure requested a review from jp-dark April 23, 2026 19:40
@codecov

codecov Bot commented Apr 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.23%. Comparing base (6a59c3e) to head (c326bfc).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4450      +/-   ##
==========================================
- Coverage   85.27%   85.23%   -0.04%     
==========================================
  Files         136      136              
  Lines       21266    21298      +32     
==========================================
+ Hits        18135    18154      +19     
- Misses       3131     3144      +13     
Flag Coverage Δ
r 83.47% <100.00%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
python_api 88.44% <ø> (ø)
libtiledbsoma ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jp-dark
jp-dark requested a review from aaronwolen April 23, 2026 19:55

@jp-dark jp-dark 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.

The test should remove AWS as a dependency.

Comment thread apis/r/tests/testthat/test-14-SeuratIngest.R Outdated
Comment thread apis/r/R/SOMACollectionBase.R Outdated
Calling `write_soma()` on a `Seurat` v5 object with ragged arrays using
an absolute file URI (eg. `/home/user/directory`) resulted in the SOMA
NDArrays for the ragged `Seurat` matrices having absolute URIs instead
of the intuitive relative arrays. This PR changes URI setting to be
relative in this case

Modified SOMA methods:
 - `SOMACollectionBase$private$.set_element()`: for non-Carrara URIs,
   always set the element relatively

Note for reviewers: this PR introduces new tests to write a ragged
`Seurat` v5 object to an absolute file URI and uploads it to S3 to
ensure the member URIs are relative. These tests require the following
before running:
 - package [{aws.s3}](https://cran.r-project.org/package=aws.s3) to be
   installed
 - environment variables `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`
   to be set for authentication
 - environment variable `AWS_S3_BUCKET` to be set to know where to
   upload the SOMA to

If these conditions are met, then the tests run. Otherwise, they are
skipped. Tests also do not run under coverage, on macOS, or on CRAN
(`!extended_tests()`)

These tests do attempt to cleanup on test exit or failure. The uploaded SOMA
will be deleted when the test exits scope. If the bucket provided by
`AWS_S3_BUCKET` does not exist prior to running, it will be created
during the test and deleted when teh test exists scope. If it already
exists, then it will be left alone

As CI does not satisify these conditions, these tests will not run on
CI. Here's an example of these tests running locally
```bash
paul@tiledb-ph:~/software/TileDB-SOMA/apis/r$ AWS_S3_BUCKET='test-ragged-s3' Rscript -e 'devtools::load_all()' -e 'testthat:
:test_file("tests/testthat/test-14-SeuratIngest.R", reporter = "location")'
Start test: Ragged array uploads to S3 (SOMA-906)
  test-14-SeuratIngest.R:618:3 [success]
  test-14-SeuratIngest.R:622:3 [success]
  test-14-SeuratIngest.R:660:3 [success]
  test-14-SeuratIngest.R:662:3 [success]
  test-14-SeuratIngest.R:663:3 [success]
  test-14-SeuratIngest.R:665:5 [success]
  test-14-SeuratIngest.R:665:5 [success]
  test-14-SeuratIngest.R:665:5 [success]
  test-14-SeuratIngest.R:665:5 [success]
End test: Ragged array uploads to S3 (SOMA-906)
```

Fixes [SOMA-906](https://linear.app/tiledb/issue/SOMA-906/r-mixed-uri-types-in-somaexperiments-created-via-write-seurat)
@mojaveazure
mojaveazure force-pushed the phoffman/soma-906-r-mixed-uri-types-in-somaexperiments-created-via branch from 93f0661 to 36ca210 Compare April 24, 2026 18:03
@mojaveazure
mojaveazure requested a review from jp-dark April 24, 2026 18:06
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.

2 participants