I am doing PC analysis and trying to plot the ranking of PCs using a python package called scanpy (for my data I have to use this package) and this line of code:
>>> sc.pl.pca_variance_ratio(adata, log=True, n_pcs = 50)
but getting the following error:
/home/.local/lib/python3.7/site-packages/scanpy/plotting/_anndata.py:550: RuntimeWarning: divide by zero encountered in log
  scores = np.log(scores)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/.local/lib/python3.7/site-packages/scanpy/plotting/_tools/__init__.py", line 194, in pca_variance_ratio
    log=log,
  File "/home/.local/lib/python3.7/site-packages/scanpy/plotting/_anndata.py", line 616, in ranking
    (1.05 if score_max > 0 else 0.95) * score_max,
  File "/home/.local/lib/python3.7/site-packages/matplotlib/pyplot.py", line 1755, in ylim
    ret = ax.set_ylim(*args, **kwargs)
  File "/home/.local/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 4027, in set_ylim
    bottom = self._validate_converted_limits(bottom, self.convert_yunits)
  File "/home/.local/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 3614, in _validate_converted_limits
    raise ValueError("Axis limits cannot be NaN or Inf")
ValueError: Axis limits cannot be NaN or Inf
in the command if I remove log=True or set it as False, I won't get error but the plot is not correct.
I exported adata into a csv file and looked for NaN and Inf but did not find. do you know how to fix the issue?
 
    