Hi, I am using the data that was transformed from Seurat to Scanpy following the official guidence. Everything works fine. For example, I could plot a PAGA layout in Scanpy. However, one thing that I cannot is to run “scanpy.pp.highly_variable_genes”.
It resulted in error no matter in python 3.6 or python 3.8. Could anyone help me with this issue? I think that may be a problem of my data. Because the example data runs correctly without any error information .
in python 3.6:
>>> sc.pp.highly_variable_genes(adata)
/mnt/c/Users/grimw/CELLECT/enter/envs/stagewiseNN_old/lib/python3.6/site-packages/scanpy/preprocessing/_highly_variable_genes.py:208: RuntimeWarning: invalid value encountered in log
dispersion = np.log(dispersion)
Traceback (most recent call last):
File “”, line 1, in
File “/mnt/c/Users/grimw/CELLECT/enter/envs/stagewiseNN_old/lib/python3.6/site-packages/scanpy/preprocessing/_highly_variable_genes.py”, line 440, in highly_variable_genes
flavor=flavor,
File “/mnt/c/Users/grimw/CELLECT/enter/envs/stagewiseNN_old/lib/python3.6/site-packages/scanpy/preprocessing/_highly_variable_genes.py”, line 223, in _highly_variable_genes_single_batch
gen_indices = np.where(one_gene_per_bin[df[‘mean_bin’].values])[0].tolist()
File “/mnt/c/Users/grimw/CELLECT/enter/envs/stagewiseNN_old/lib/python3.6/site-packages/pandas/core/series.py”, line 906, in getitem
return self._get_with(key)
File “/mnt/c/Users/grimw/CELLECT/enter/envs/stagewiseNN_old/lib/python3.6/site-packages/pandas/core/series.py”, line 946, in _get_with
return self.loc[key]
File “/mnt/c/Users/grimw/CELLECT/enter/envs/stagewiseNN_old/lib/python3.6/site-packages/pandas/core/indexing.py”, line 879, in getitem
return self._getitem_axis(maybe_callable, axis=axis)
File “/mnt/c/Users/grimw/CELLECT/enter/envs/stagewiseNN_old/lib/python3.6/site-packages/pandas/core/indexing.py”, line 1099, in _getitem_axis
return self._getitem_iterable(key, axis=axis)
File “/mnt/c/Users/grimw/CELLECT/enter/envs/stagewiseNN_old/lib/python3.6/site-packages/pandas/core/indexing.py”, line 1037, in _getitem_iterable
keyarr, indexer = self._get_listlike_indexer(key, axis, raise_missing=False)
File “/mnt/c/Users/grimw/CELLECT/enter/envs/stagewiseNN_old/lib/python3.6/site-packages/pandas/core/indexing.py”, line 1240, in _get_listlike_indexer
indexer, keyarr = ax._convert_listlike_indexer(key)
File “/mnt/c/Users/grimw/CELLECT/enter/envs/stagewiseNN_old/lib/python3.6/site-packages/pandas/core/indexes/base.py”, line 3216, in _convert_listlike_indexer
indexer = self._convert_list_indexer(keyarr)
File “/mnt/c/Users/grimw/CELLECT/enter/envs/stagewiseNN_old/lib/python3.6/site-packages/pandas/core/indexes/category.py”, line 598, in _convert_list_indexer
indexer = self.categories._convert_list_indexer(keyarr)
File “/mnt/c/Users/grimw/CELLECT/enter/envs/stagewiseNN_old/lib/python3.6/site-packages/pandas/core/indexes/interval.py”, line 533, in _convert_list_indexer
raise KeyError
KeyError
in python 3.8:
>>> sc.pp.highly_variable_genes(adata)
/mnt/c/Users/grimw/CELLECT/enter/envs/stagewiseNN/lib/python3.8/site-packages/scanpy/preprocessing/_highly_variable_genes.py:200: RuntimeWarning: invalid value encountered in expm1
X = np.expm1(X)
Traceback (most recent call last):
File “”, line 1, in
File “/mnt/c/Users/grimw/CELLECT/enter/envs/stagewiseNN/lib/python3.8/site-packages/scanpy/preprocessing/_highly_variable_genes.py”, line 434, in highly_variable_genes
df = _highly_variable_genes_single_batch(
File “/mnt/c/Users/grimw/CELLECT/enter/envs/stagewiseNN/lib/python3.8/site-packages/scanpy/preprocessing/_highly_variable_genes.py”, line 215, in _highly_variable_genes_single_batch
df[‘mean_bin’] = pd.cut(df[‘means’], bins=n_bins)
File “/mnt/c/Users/grimw/CELLECT/enter/envs/stagewiseNN/lib/python3.8/site-packages/pandas/core/reshape/tile.py”, line 292, in cut
fac, bins = _bins_to_cuts(
File “/mnt/c/Users/grimw/CELLECT/enter/envs/stagewiseNN/lib/python3.8/site-packages/pandas/core/reshape/tile.py”, line 419, in _bins_to_cuts
raise ValueError(
ValueError: Bin edges must be unique: array([nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
nan, nan, nan, nan, nan, nan, nan, nan]).
You can drop duplicate edges by setting the ‘duplicates’ kwarg