Comments (4)
This seems to have expected behaviour:
import numpy as np
from anndata import AnnData
from muon import prot as pt
adata = AnnData(np.arange(1000).reshape(-1, 10))
adata.raw = adata
pt.pp.clr(adata)
print(adata.X[:2,:2])
# [[0. 0.00276899]
# [0.02767339 0.03004515]]
print(adata.raw.X[:2,:2])
# [[ 0. 1.]
# [10. 11.]]
Any idea how your observation can be reproduced?
from muon.
Very interesting!
Here is my attempt:
import muon as mu
import anndata
import numpy as np
x = np.array([[10, 10],
[10, 20]], dtype=float)
adata = anndata.AnnData(x)
adata.raw = adata
mu.prot.pp.clr(adata)
print(adata.X)
# [[0.64662716 0.50558292]
# [0.64662716 0.83979984]]
print(adata.raw.X)
# [[0.64662716 0.50558292]
# [0.64662716 0.83979984]]
print(mu.__version__) # 0.1.5
print(anndata.__version__) # 0.9.2
print(sc.__version__) # 1.9.3
Also I noticed that giving inplace = False solves the problem for me:
x = np.array([[10, 10],
[10, 20]], dtype=float)
adata = anndata.AnnData(x)
adata.raw = adata
adata = mu.prot.pp.clr(adata, inplace=False)
print(adata.X)
# [[0.64662716 0.50558292]
# [0.64662716 0.83979984]]
print(adata.raw.X)
# [[10. 10.]
# [10. 20.]]
Still I would like to understand what is going on and avoid an unnecessary copying operation. Any suggestions are welcome!
from muon.
I found the source of the problem.
x = np.array([[10, 20]], dtype=float)
adata = anndata.AnnData(x)
adata.raw = adata
print(adata.X is adata.raw.X) # Prints True
For me, apparently, adata.X IS adata.raw.X. That is why when clr normalizes X, raw.X is also normalized.
I don't know if this is the intended behavior of raw and I don't know why I am having this issue whilst @gtca is not.
@gtca would you mind sharing which version of Anndata you are using?
from muon.
Indeed, in anndata v0.8:
id(adata.raw.X) == id(adata.X)
# => False
whereas in anndata v0.9.2 as well as in anndata v.10:
id(adata.raw.X) == id(adata.X)
# => True
Probably a new issue in the anndata repo is a better place to track this then: scverse/anndata#1139!
from muon.
Related Issues (20)
- OSError: Unable to synchronously create attribute (object header message is too large) HOT 1
- "OptionError: 'Pattern matched multiple keys'" traceback in tutorial
- Is being developed? HOT 2
- MOFA error when data has been created using `axis=-1`
- Batch correction for joint modality umap
- Enable `gene_symbols` argument in mu.pl.embedding HOT 1
- Sum duplicate rows in muon.atac.tl.count_fragments_features
- How can I concatenate multiple `muon` data samples? HOT 2
- ValueError: could not broadcast input array from shape HOT 2
- float overflow in dsb normalization HOT 1
- dsb normalization results do not replicate results with the original DSBNormalizeProtein function in R
- mu.pl.scatter() fails when providing color
- Add fragment file path to a merged mudata object HOT 1
- ImportError: cannot import name '_compute_connectivities_umap' from 'scanpy.neighbors' HOT 9
- Improve module import time HOT 1
- Test against pre-releases
- Invalid function call in independent component analysis (tl.ica)
- Error with muon import HOT 3
- WNN integration raise error while adding connectivities into mdata.obsp
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from muon.