Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

can't perform sequential mu.pp.filter_obs #43

Closed
Labels
bugSomething isn't working
@crichgriffin

Description

@crichgriffin

I want to perform multiple filtering steps on my object e.g.:

mu.pp.filter_obs(mdata, 'n_genes_by_counts', lambda x: (x >= 100))mu.pp.filter_obs(mdata,  'total_counts', lambda x: (x >= 500) & (x <= 50000)

Error message:

muon/_core/preproc.py in filter_obs(data, var, func)    733         # filter_obs() for each modality    734         for m, mod in data.mod.items():--> 735             obsmap = data.obsmap[m][obs_subset]    736             obsmap = obsmap[obsmap != 0] - 1    737             filter_obs(mod, mod.obs_names[obsmap])anndata/_core/aligned_mapping.py in __getitem__(self, key)    146     147     def __getitem__(self, key: str) -> V:--> 148         return self._data[key]    149     150     def __setitem__(self, key: str, value: V):KeyError: 'x'

Minimal working example:

import numpy as npimport muon as mux = mu.AnnData(X=np.random.normal(size=1000).reshape(-1, 100))y = mu.AnnData(X=np.random.normal(size=2000).reshape(-1, 100))md = mu.MuData({"x": x, "y": y})md['x'].obs['total_count'] = md['x'].X.sum(axis=1)md['x'].obs['min_count'] = md['x'].X.min(axis=1)md.update()# filter one of the modalities.mu.pp.filter_obs(md, 'x:min_count', lambda x: (x < -2))mu.pp.filter_obs(md, 'x:total_count', lambda x: (x >0))

If you putmd.update() between the two filter statements it does work. But to me this is not ideal if you are filtering on lots of categories sequentially

Is this desired behaviour ot something that could be updated such that one could just one runupdate command after sequential filters??

  • OS: CentOS Linux release 7.8.2003 (Core)
  • Python 3.9.5
  • Versions of libraries involved
    • numpy 1.20.3
    • muon 0.1.1

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp