We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
pl.embedding
Describe the bug When trying to plot variables from obs and var in the same pl.embedding, it fails.
To Reproduce
import muon as mu import scanpy as sc mdata = mu.MuData({"gex": sc.datasets.pbmc3k_processed()}) # works mu.pl.embedding(mdata, "gex:umap", color=["CD8A"]) # works mu.pl.embedding(mdata, "gex:umap", color=["gex:louvain"]) # Key Error mu.pl.embedding(mdata, "gex:umap", color=["gex:louvain", "CD8A"])
KeyError: 'Could not find key louvain in .var_names or .obs.columns.'
--------------------------------------------------------------------------- KeyError Traceback (most recent call last) Cell In[31], line 1 ----> 1 mu.pl.embedding(mdata, "gex:umap", color=["gex:louvain", "CD8A"]) File ~/anaconda3/envs/scirpy_dev/lib/python3.9/site-packages/muon/_core/plot.py:255, in embedding(data, basis, color, use_raw, layer, **kwargs) 252 color = [mod_key_modifier[k] for k in keys] 254 ad = AnnData(obs=obs, obsm=adata.obsm, obsp=adata.obsp, uns=adata.uns) --> 255 return sc.pl.embedding(ad, basis=basis_mod, color=color, **kwargs) File ~/anaconda3/envs/scirpy_dev/lib/python3.9/site-packages/scanpy/plotting/_tools/scatterplots.py:244, in embedding(adata, basis, color, gene_symbols, use_raw, sort_order, edges, edges_width, edges_color, neighbors_key, arrows, arrows_kwds, groups, components, layer, projection, scale_factor, color_map, cmap, palette, na_color, na_in_legend, size, frameon, legend_fontsize, legend_fontweight, legend_loc, legend_fontoutline, vmax, vmin, vcenter, norm, add_outline, outline_width, outline_color, ncols, hspace, wspace, title, show, save, ax, return_fig, **kwargs) 235 # use itertools.product to make a plot for each color and for each component 236 # For example if color=[gene1, gene2] and components=['1,2, '2,3']. 237 # The plots are: [ 238 # color=gene1, components=[1,2], color=gene1, components=[2,3], 239 # color=gene2, components = [1, 2], color=gene2, components=[2,3], 240 # ] 241 for count, (value_to_plot, component_idx) in enumerate( 242 itertools.product(color, idx_components) 243 ): --> 244 color_source_vector = _get_color_source_vector( 245 adata, 246 value_to_plot, 247 layer=layer, 248 use_raw=use_raw, 249 gene_symbols=gene_symbols, 250 groups=groups, 251 ) 252 color_vector, categorical = _color_vector( 253 adata, 254 value_to_plot, (...) 257 na_color=na_color, 258 ) 260 # Order points File ~/anaconda3/envs/scirpy_dev/lib/python3.9/site-packages/scanpy/plotting/_tools/scatterplots.py:1225, in _get_color_source_vector(adata, value_to_plot, use_raw, gene_symbols, layer, groups) 1223 values = adata.raw.obs_vector(value_to_plot) 1224 else: -> 1225 values = adata.obs_vector(value_to_plot, layer=layer) 1226 if groups and is_categorical_dtype(values): 1227 values = values.replace(values.categories.difference(groups), np.nan) File ~/anaconda3/envs/scirpy_dev/lib/python3.9/site-packages/anndata/_core/anndata.py:1375, in AnnData.obs_vector(self, k, layer) 1369 warnings.warn( 1370 "In a future version of AnnData, access to `.X` by passing" 1371 " `layer='X'` will be removed. Instead pass `layer=None`.", 1372 FutureWarning, 1373 ) 1374 layer = None -> 1375 return get_vector(self, k, "obs", "var", layer=layer) File ~/anaconda3/envs/scirpy_dev/lib/python3.9/site-packages/anndata/_core/index.py:191, in get_vector(adata, k, coldim, idxdim, layer) 187 raise ValueError( 188 f"Key {k} could be found in both .{idxdim}_names and .{coldim}.columns" 189 ) 190 elif (in_col + in_idx) == 0: --> 191 raise KeyError( 192 f"Could not find key {k} in .{idxdim}_names or .{coldim}.columns." 193 ) 194 elif in_col: 195 return getattr(adata, coldim)[k].values KeyError: 'Could not find key louvain in .var_names or .obs.columns.'
Expected behaviour Being able to mix features from obs and var in the same embedding plot
System muon 0.1.3 scanpy 1.8.2 mudata 0.2.2
Additional context This still worked as expected in muon 0.1.2
0.1.2
The text was updated successfully, but these errors were encountered:
9bd999e
No branches or pull requests
Describe the bug
When trying to plot variables from obs and var in the same
pl.embedding
, it fails.To Reproduce
Stacktrace
Expected behaviour
Being able to mix features from obs and var in the same embedding plot
System
muon 0.1.3
scanpy 1.8.2
mudata 0.2.2
Additional context
This still worked as expected in muon
0.1.2
The text was updated successfully, but these errors were encountered: