khramts / assocplots

MIT License
32 stars 14 forks source link

Using Manhattan plot on Drosophila? #7

Open thecochenille opened 4 years ago

thecochenille commented 4 years ago

Hi,

I would like to know if the script can handle other organisms than humans. I tried to use it with result from Drosophila (less chr and different position numbers) and I get the following error:

What I input:

manhattan(     dfnew[3], dfnew[2],dfnew[1].astype(str), 'SSP index',
               plot_type='single',
               chrs_plot=[str(i) for i in range(1,10)],
               chrs_names=chrs_names,
               cut = 0,
               title='lnwing SSP index',
               xlabel='chromosome',
               ylabel='-log10(p-value)',
               lines= [],
               colors = colors,
               scaling = '-log10')

Error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-129-109ad6b8698c> in <module>
      9                lines= [],
     10                colors = colors,
---> 11                scaling = '-log10')

/opt/anaconda3/lib/python3.7/site-packages/assocplots/manhattan.py in manhattan(p1, pos1, chr1, label1, p2, pos2, chr2, label2, plot_type, chrs_plot, chrs_names, cut, colors, title, xlabel, ylabel, top1, top2, lines, lines_colors, zoom, scaling)
    120             plt.subplot(1,1,1)
    121         plt.plot([shift[-1], shift[-1]], [0, 1000], '-k', lw=0.5, color='lightgray')
--> 122         plt.xlim([0, shift[-1]])
    123 
    124         if plot_type != 'single':

/opt/anaconda3/lib/python3.7/site-packages/matplotlib/pyplot.py in xlim(*args, **kwargs)
   1432     if not args and not kwargs:
   1433         return ax.get_xlim()
-> 1434     ret = ax.set_xlim(*args, **kwargs)
   1435     return ret
   1436 

/opt/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py in set_xlim(self, left, right, emit, auto, xmin, xmax)
   3240         self._process_unit_info(xdata=(left, right))
   3241         left = self._validate_converted_limits(left, self.convert_xunits)
-> 3242         right = self._validate_converted_limits(right, self.convert_xunits)
   3243 
   3244         old_left, old_right = self.get_xlim()

/opt/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py in _validate_converted_limits(self, limit, convert)
   3156             if (isinstance(converted_limit, Real)
   3157                     and not np.isfinite(converted_limit)):
-> 3158                 raise ValueError("Axis limits cannot be NaN or Inf")
   3159             return converted_limit
   3160 

ValueError: Axis limits cannot be NaN or Inf

I formatted the dataframe exactly like your example dataset.

Thanks!

khramts commented 4 years ago

Hello Isabelle, It looks like you have NaN or Inf values in your dataframe. Could you check if that is the case? If so, can you try to filter it out and run this again?

Thank you for your interest. This is not limited to human data and should be adaptable to the chr and positions which you enter. Regards, Katya

On Wed, Apr 22, 2020 at 2:42 PM Isabelle M. Vea notifications@github.com wrote:

Hi,

I would like to know if the script can handle other organisms than humans. I tried to use it with result from Drosophila (less chr and different position numbers) and I get the following error:

What I input:

manhattan( dfnew[3], dfnew[2],dfnew[1].astype(str), 'SSP index', plot_type='single', chrs_plot=[str(i) for i in range(1,10)], chrs_names=chrs_names, cut = 0, title='lnwing SSP index', xlabel='chromosome', ylabel='-log10(p-value)', lines= [], colors = colors, scaling = '-log10')

Error:


ValueError Traceback (most recent call last)

in 9 lines= [], 10 colors = colors, ---> 11 scaling = '-log10') /opt/anaconda3/lib/python3.7/site-packages/assocplots/manhattan.py in manhattan(p1, pos1, chr1, label1, p2, pos2, chr2, label2, plot_type, chrs_plot, chrs_names, cut, colors, title, xlabel, ylabel, top1, top2, lines, lines_colors, zoom, scaling) 120 plt.subplot(1,1,1) 121 plt.plot([shift[-1], shift[-1]], [0, 1000], '-k', lw=0.5, color='lightgray') --> 122 plt.xlim([0, shift[-1]]) 123 124 if plot_type != 'single': /opt/anaconda3/lib/python3.7/site-packages/matplotlib/pyplot.py in xlim(*args, **kwargs) 1432 if not args and not kwargs: 1433 return ax.get_xlim() -> 1434 ret = ax.set_xlim(*args, **kwargs) 1435 return ret 1436 /opt/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py in set_xlim(self, left, right, emit, auto, xmin, xmax) 3240 self._process_unit_info(xdata=(left, right)) 3241 left = self._validate_converted_limits(left, self.convert_xunits) -> 3242 right = self._validate_converted_limits(right, self.convert_xunits) 3243 3244 old_left, old_right = self.get_xlim() /opt/anaconda3/lib/python3.7/site-packages/matplotlib/axes/_base.py in _validate_converted_limits(self, limit, convert) 3156 if (isinstance(converted_limit, Real) 3157 and not np.isfinite(converted_limit)): -> 3158 raise ValueError("Axis limits cannot be NaN or Inf") 3159 return converted_limit 3160 ValueError: Axis limits cannot be NaN or Inf I formatted the dataframe exactly like your example dataset. Thanks! — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub , or unsubscribe .