YeoLab / flotilla

Reproducible machine learning analysis of gene expression and alternative splicing data
http://yeolab.github.io/flotilla/docs
BSD 3-Clause "New" or "Revised" License
121 stars 26 forks source link

Flotilla fails with ValueError while executing "plot_pca" command #327

Closed shassathe closed 8 years ago

shassathe commented 8 years ago

I was able to generate a flotilla study with my data successfully. I am looking to generate pca plots using the "plot_pca" command:

%matplotlib inline
viz = stem_study.plot_pca(show_vectors=False, markersize=15)

However, "plot_pca" returns a ValueError with the following prompt

ValueError                                Traceback (most recent call last)
<ipython-input-12-4fda588d8572> in <module>()
      1 get_ipython().magic(u'matplotlib inline')
----> 2 viz = stem_study.plot_pca(show_vectors=False, markersize=15)
      3 #plt.savefig('/home/shsathe/projects/sebastian_run2/Paper_Figures/Stem_Cells_PCA.png', format='png')

/home/shsathe/anaconda/lib/python2.7/site-packages/flotilla-0.3.0-py2.7.egg/flotilla/study.pyc in plot_pca(self, data_type, x_pc, y_pc, sample_subset, feature_subset, title, featurewise, plot_violins, show_point_labels, reduce_kwargs, color_samples_by, bokeh, most_variant_features, std_multiplier, scale_by_variance, **kwargs)
    860                 bokeh=bokeh, most_variant_features=most_variant_features,
    861                 scale_by_variance=scale_by_variance,
--> 862                 **kwargs)
    863 
    864         elif "splicing".startswith(data_type):

/home/shsathe/anaconda/lib/python2.7/site-packages/flotilla-0.3.0-py2.7.egg/flotilla/data_model/base.pyc in plot_pca(self, **kwargs)
    597         """Call ``plot_dimensionality_reduction`` with PCA specifically"""
    598         return self.plot_dimensionality_reduction(reducer=DataFramePCA,
--> 599                                                   **kwargs)
    600 
    601     def _subset(self, data, sample_ids=None, feature_ids=None,

/home/shsathe/anaconda/lib/python2.7/site-packages/flotilla-0.3.0-py2.7.egg/flotilla/data_model/base.pyc in plot_dimensionality_reduction(self, x_pc, y_pc, sample_ids, feature_ids, featurewise, reducer, plot_violins, groupby, label_to_color, label_to_marker, order, reduce_kwargs, title, most_variant_features, std_multiplier, scale_by_variance, **plotting_kwargs)
    592         # **plotting_kwargs)
    593         return visualized.plot(title=title,
--> 594                                plot_violins=plot_violins, **plotting_kwargs)
    595 
    596     def plot_pca(self, **kwargs):

/home/shsathe/anaconda/lib/python2.7/site-packages/flotilla-0.3.0-py2.7.egg/flotilla/visualize/decomposition.pyc in plot(self, ax, title, plot_violins, show_point_labels, show_vectors, show_vector_labels, markersize, legend, bokeh, metadata, plot_loadings, n_components)
    284                 self.ax_empty.axis('off')  # self.fig_reduced = plt.gcf()
    285 
--> 286                 self.plot_loadings_heatmap(n_components=n_components)
    287 
    288             else:

/home/shsathe/anaconda/lib/python2.7/site-packages/flotilla-0.3.0-py2.7.egg/flotilla/visualize/decomposition.pyc in plot_loadings_heatmap(self, n_features, n_components)
    523         ymin = np.zeros(ymax.shape)
    524         x = np.arange(ymax.shape[0])
--> 525         self.ax_explained_variance.plot(ymax, 'o-', color='#262626')
    526         self.ax_explained_variance.fill_between(x, ymin, ymax,
    527                                                 color='lightgrey')

/home/shsathe/anaconda/lib/python2.7/site-packages/matplotlib/__init__.pyc in inner(ax, *args, **kwargs)
   1809                     warnings.warn(msg % (label_namer, func.__name__),
   1810                                   RuntimeWarning, stacklevel=2)
-> 1811             return func(ax, *args, **kwargs)
   1812         pre_doc = inner.__doc__
   1813         if pre_doc is None:

/home/shsathe/anaconda/lib/python2.7/site-packages/matplotlib/axes/_axes.pyc in plot(self, *args, **kwargs)
   1426 
   1427         for line in self._get_lines(*args, **kwargs):
-> 1428             self.add_line(line)
   1429             lines.append(line)
   1430 

/home/shsathe/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in add_line(self, line)
   1697             line.set_clip_path(self.patch)
   1698 
-> 1699         self._update_line_limits(line)
   1700         if not line.get_label():
   1701             line.set_label('_line%d' % len(self.lines))

/home/shsathe/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in _update_line_limits(self, line)
   1708         Figures out the data limit of the given line, updating self.dataLim.
   1709         """
-> 1710         path = line.get_path()
   1711         if path.vertices.size == 0:
   1712             return

/home/shsathe/anaconda/lib/python2.7/site-packages/matplotlib/lines.pyc in get_path(self)
    924         """
    925         if self._invalidy or self._invalidx:
--> 926             self.recache()
    927         return self._path
    928 

/home/shsathe/anaconda/lib/python2.7/site-packages/matplotlib/lines.pyc in recache(self, always)
    609                 x = ma.asarray(xconv, np.float_).filled(np.nan)
    610             else:
--> 611                 x = np.asarray(xconv, np.float_)
    612             x = x.ravel()
    613         else:

/home/shsathe/anaconda/lib/python2.7/site-packages/numpy/core/numeric.pyc in asarray(a, dtype, order)
    472 
    473     """
--> 474     return array(a, dtype, copy=False, order=order)
    475 
    476 def asanyarray(a, dtype=None, order=None):

ValueError: could not convert string to float: pc_5
olgabot commented 8 years ago

Hmm I'm not sure exactly what the error is here. I'll look into it.

LeenMachine commented 8 years ago

I have the same issue as above

On Fri, Dec 11, 2015 at 5:54 PM, Olga Botvinnik notifications@github.com wrote:

Hmm I'm not sure exactly what the error is here. I'll look into it.

— Reply to this email directly or view it on GitHub https://github.com/YeoLab/flotilla/issues/327#issuecomment-164095531.

olgabot commented 8 years ago

can either of you do "study.save('studyname')" and zip the folder it creates in ~/flotilla_projects and send it to me?

On Tue, Jan 19, 2016 at 10:26 AM Leen notifications@github.com wrote:

I have the same issue as above

On Fri, Dec 11, 2015 at 5:54 PM, Olga Botvinnik notifications@github.com wrote:

Hmm I'm not sure exactly what the error is here. I'll look into it.

— Reply to this email directly or view it on GitHub https://github.com/YeoLab/flotilla/issues/327#issuecomment-164095531.

— Reply to this email directly or view it on GitHub https://github.com/YeoLab/flotilla/issues/327#issuecomment-172942315.

LeenMachine commented 8 years ago

Hey sorry Olga, did anyone get back to you?

If not I can do this.

I need to get this working again.

Thanks,

Leen

On Tue, Jan 19, 2016 at 1:18 PM, Olga Botvinnik notifications@github.com wrote:

can either of you do "study.save('studyname')" and zip the folder it creates in ~/flotilla_projects and send it to me?

On Tue, Jan 19, 2016 at 10:26 AM Leen notifications@github.com wrote:

I have the same issue as above

On Fri, Dec 11, 2015 at 5:54 PM, Olga Botvinnik < notifications@github.com> wrote:

Hmm I'm not sure exactly what the error is here. I'll look into it.

— Reply to this email directly or view it on GitHub <https://github.com/YeoLab/flotilla/issues/327#issuecomment-164095531 .

— Reply to this email directly or view it on GitHub https://github.com/YeoLab/flotilla/issues/327#issuecomment-172942315.

— Reply to this email directly or view it on GitHub https://github.com/YeoLab/flotilla/issues/327#issuecomment-172989990.

mlovci commented 8 years ago

Changing https://github.com/YeoLab/flotilla/blob/master/flotilla/visualize/decomposition.py#L522

from

ymax = self.explained_variance_ratio_[:n_components]

to:

ymax = self.explained_variance_ratio_[:n_components].values

fixes the problem i think.

LeenMachine commented 8 years ago

Cool can we do that? :)

Leen

On Wed, Jan 27, 2016 at 11:12 AM, Michael Lovci notifications@github.com wrote:

Changing https://github.com/YeoLab/flotilla/blob/master/flotilla/visualize/decomposition.py#L522

from

ymax = self.explained_varianceratio[:n_components]

to:

ymax = self.explained_varianceratio[:n_components].values

fixes the problem i think.

— Reply to this email directly or view it on GitHub https://github.com/YeoLab/flotilla/issues/327#issuecomment-175803063.

mlovci commented 8 years ago

Go for it... On Jan 27, 2016 11:31 AM, "Leen" notifications@github.com wrote:

Cool can we do that? :)

Leen

On Wed, Jan 27, 2016 at 11:12 AM, Michael Lovci notifications@github.com wrote:

Changing

https://github.com/YeoLab/flotilla/blob/master/flotilla/visualize/decomposition.py#L522

from

ymax = self.explained_varianceratio[:n_components]

to:

ymax = self.explained_varianceratio[:n_components].values

fixes the problem i think.

— Reply to this email directly or view it on GitHub https://github.com/YeoLab/flotilla/issues/327#issuecomment-175803063.

— Reply to this email directly or view it on GitHub https://github.com/YeoLab/flotilla/issues/327#issuecomment-175812398.

LeenMachine commented 8 years ago

Fixed it. Boom.