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

Unexpected (?) output from MuData.copy() #33

Open
emdann opened this issue Dec 13, 2022 · 1 comment
Open

Unexpected (?) output from MuData.copy() #33

emdann opened this issue Dec 13, 2022 · 1 comment
Milestone

Comments

@emdann
Copy link
Member

emdann commented Dec 13, 2022

Hi there, not sure whether this is really a bug, but if I make certain changes to a MuData.obs (e.g. removing duplicate columns), the obs in the copy becomes different from the original.

Example

adata = sc.datasets.pbmc3k_processed()
adata_highQ = adata[adata.obs['n_counts'] > 2000].copy()
mdata = mudata.MuData({'full':adata,'highQ':adata_highQ}, axis=0)

## Change obs
mdata.obs = mdata['full'].obs.copy()
mdata.obs.columns
Index(['n_genes', 'percent_mito', 'n_counts', 'louvain'], dtype='object')
mdata_copy = mdata.copy()
mdata_copy.obs.columns
Index(['full:n_genes', 'full:percent_mito', 'full:n_counts', 'full:louvain',
       'highQ:n_genes', 'highQ:percent_mito', 'highQ:n_counts',
       'highQ:louvain', 'n_genes', 'percent_mito', 'n_counts', 'louvain'],
      dtype='object'

I understand this comes from the copy method re-initializing the MuData object, but it leads to breaking code where an exact copy is expected.

System

  • Python v3.10
  • MuData v0.2.1
@emdann emdann added the bug Something isn't working label Dec 13, 2022
@gtca
Copy link
Collaborator

gtca commented Jun 1, 2023

Hey @emdann,

This stems from the necessity of .update() — and the fact that by default, the columns are copied from individual modalities.
We might change this behaviour in v0.3 so that the columns are not copied automatically.

Currently what's expected is that the columns should be the same after running .copy() after .update().

@gtca gtca removed the bug Something isn't working label Jun 1, 2023
@gtca gtca added this to the v0.3.0 milestone Jun 1, 2023
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

No branches or pull requests

2 participants