Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[python] Re-enable tiledbsoma.ExperimentAxisQuery #3476

Merged
merged 5 commits into from
Dec 19, 2024
Merged

Conversation

johnkerl
Copy link
Member

@johnkerl johnkerl commented Dec 18, 2024

Issue and/or context: After 1.15.0 was tagged, we found that users can no longer instantiate tiledbsoma.ExperimentAxisQuery.

Repro:

import scanpy as sc
import tiledbsoma
import tiledbsoma.io
import tempfile

pbmc3k = sc.datasets.pbmc3k()
sc.pp.calculate_qc_metrics(pbmc3k, inplace=True)

tmpdir = tempfile.TemporaryDirectory().name
tiledbsoma.io.from_anndata(tmpdir, anndata=pbmc3k, measurement_name="RNA")

exp = tiledbsoma.Experiment.open(tmpdir)

exp.obs.read().concat().to_pandas()
exp.ms["RNA"].var.read().concat().to_pandas()
exp.ms["RNA"].X["data"].read().coos().concat()
exp.obs.read(
    coords=[slice(0, 99)],
    value_filter="total_counts > 4000",
    column_names=["soma_joinid", "obs_id", "total_counts"],
).concat().to_pandas()
exp.ms["RNA"].var.read(
    value_filter="var_id in ['ANXA1', 'IFI44', 'IFI44L', 'OAS1']",
    column_names=["var_id", "gene_ids", "mean_counts"],
).concat().to_pandas()

with tiledbsoma.ExperimentAxisQuery(
    experiment=exp,
    measurement_name="RNA",
    obs_query=tiledbsoma.AxisQuery(
        value_filter="n_genes_by_counts > 1000",
    ),
    var_query=tiledbsoma.AxisQuery(
        value_filter="n_cells_by_counts > 100",
    ),
) as query:
    assert (query.n_obs, query.n_vars) == (532, 4722)
    query.obs().concat().to_pandas()
    query.X(layer_name="data").tables().concat().to_pandas()
    query.to_anndata(X_name="data")

This should produce no output and raise no exceptions. Actual behavior in 1.15.0, which is a regression from 1.14.5:

Traceback (most recent call last):
  File "/home/ubuntu/git/single-cell-data/TileDB-SOMA/x.py", line 35, in <module>
    with tiledbsoma.ExperimentAxisQuery(
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ExperimentAxisQuery() takes no arguments

Changes:

  • Since on [python] Ingest somacore classes #3307 we moved the impl from somacore to tiledbsoma._query, have tiledbsoma re-export the impl from where it is now located
  • Update our unit-test logic to use the same API as exposed to users, namely, tiledbsoma.ExperimentAxisQuery

Notes for Reviewer:

[sc-59686]

Copy link

codecov bot commented Dec 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.32%. Comparing base (bda7d97) to head (6ae4ac1).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3476      +/-   ##
==========================================
+ Coverage   86.27%   86.32%   +0.04%     
==========================================
  Files          55       55              
  Lines        6339     6339              
==========================================
+ Hits         5469     5472       +3     
+ Misses        870      867       -3     
Flag Coverage Δ
python 86.32% <100.00%> (+0.04%) ⬆️

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

Components Coverage Δ
python_api 86.32% <100.00%> (+0.04%) ⬆️
libtiledbsoma ∅ <ø> (∅)

Copy link
Member

@bkmartinjr bkmartinjr left a comment

Choose a reason for hiding this comment

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

two nits. no concern with intention of the PR, so pre-approving on the assumption the nits are easy to fix

@johnkerl johnkerl merged commit dc1060c into main Dec 19, 2024
21 checks passed
@johnkerl johnkerl deleted the kerl/eaq-export branch December 19, 2024 03:15
github-actions bot pushed a commit that referenced this pull request Dec 19, 2024
* [python] Re-enable `tiledbsoma.ExperimentAxisQuery`

* Update unit-test case to use the user-facing API

* code-review feedback

* `somacore.Axis` and `tiledbsoma._query.Axis` are not the same thing

* clarify a confusing internal name
johnkerl added a commit that referenced this pull request Dec 19, 2024
* [python] Re-enable `tiledbsoma.ExperimentAxisQuery`

* Update unit-test case to use the user-facing API

* code-review feedback

* `somacore.Axis` and `tiledbsoma._query.Axis` are not the same thing

* clarify a confusing internal name

Co-authored-by: John Kerl <[email protected]>
ryan-williams added a commit that referenced this pull request Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants