When I use sc.pp.log1p(adata) and then sc.pp.log1p(adata, layer='other') it warns me that the data has already been logged even though I am logging a layer as opposed to adata.X.
Would be nice to flag logging for each layer instead of when anything is logged.
import scanpy as sc
adata = sc.datasets.pbmc3k_processed()
adata.layers['other'] = adata.X
sc.pp.log1p(adata, layer='other')
sc.pp.log1p(adata)
WARNING: adata.X seems to be already log-transformed.
scanpy==1.5.2.dev5+ge5d246aa anndata==0.7.3 umap==0.3.10 numpy==1.18.5 scipy==1.5.0 pandas==1.0.5 scikit-learn==0.23.1 statsmodels==0.11.1 python-igraph==0.7.1 louvain==0.6.1 leidenalg==0.7.0
Happens here:
Where does .uns['log1p'] get set other than there?
Hi @gheimberg,
In your example you are not using a deepcopy to assign adata.X to adata.layers['other']. So when you log transform the data in the layer, it automatically log transforms the data in adata.X as well, as you just passed the reference. That being said, this is still a bug as even with a adata.X.copy() the warning is given.
Guys we should just keep the layer info here in log1p:
data.uns['log1p'] = {'base': base}
like
data.uns['log1p'][layer] = {'base': base}
Most helpful comment
Guys we should just keep the layer info here in log1p:
data.uns['log1p'] = {'base': base}
like
data.uns['log1p'][layer] = {'base': base}