, layer= does not appear to be working

Hi, I’m trying to use a layer in but scanpy seems to just use adata.X.

I have previously run scVI and obtained the log1p of its normalized counts and have stored them in layers:

AnnData object with n_obs × n_vars = 80642 × 641

layers: 'counts', 'scVI_normalized', 'scVI_normalized_log1p'

Here are the ranges of my layers:

Layers:                                                       min         max
   X                                                         0.00    33241.00
   counts                                                    0.00    33241.00
   scVI_normalized                                           0.00    20319.66
   scVI_normalized_log                                       0.00        9.92

I do the following:, groupby='consensus_clusters', use_rep="X_scVI"), 'consensus_clusters', method='wilcoxon', use_raw=False, layer='scVI_normalized_log1p',
                        key_added = "wilcoxon_consensus_clusters")

When I try to display the data with, n_genes=8, 
                                key="wilcoxon_consensus_clusters", groupby="consensus_clusters", 

the range of the gene values on the heatmap is over 30000, so it appears to be using adata.X rather than adata.layers['scVI_normalized_log1p']

Am I missing something?

I am on scanpy 1.8.2 which is the latest installed with conda from conda-forge

thanks for any help

If I force adata.X to contain the data in the layer I want:

adata.X = adata.layers['scVI_normalized_log1p'].copy()

and repeat the calls:, 'consensus_clusters', method='wilcoxon', use_raw=False, layer='scVI_normalized_log1p',
                        key_added = "wilcoxon_consensus_clusters"), n_genes=8, 
                                key="wilcoxon_consensus_clusters", groupby="consensus_clusters", 

I get the correct range, i.e. things behave as I would have expected if the layer parameter was being respected.