I'm having problems with using ggplot with rpy2 for dataframes I construct
in python.  For dataframes that I import it's no problem.

For example, if I run this example from the website, it works no problem:

 datasets = importr('datasets')
 mtcars = datasets.mtcars
 gp = ggplot2.ggplot(mtcars)
 pp = gp + \
 ggplot2.aes_string(x='wt', fill='factor(cyl)') + \
 ggplot2.geom_histogram()
 pp.plot()

However, if I try to construct my own dataframe, it fails

 gene_inf =
{'eth':ro.StrVector(['D','D','C']),'cp':ro.FloatVector([.2,.3,.4])}
 gene_inf_df = ro.DataFrame(gene_inf)
 gene_inf_df = ro.r['data.frame'](**gene_inf)
 gp = ggplot2.ggplot(gene_inf_df)
 pp = gp + ggplot2.aes_string(x='cp')
 pp = gp + ggplot2.geom_histogram()
 pp.plot()

Error: attempt to apply non-function
Traceback (most recent call last):
  File "make_histograms_from_summary.py", line 99, in <module>

 plot_histogram(sum.regions[region_id],region_id,name,o.outdir,genome_info)
  File "make_histograms_from_summary.py", line 66, in plot_histogram
    pp.plot()
  File
"/net/gs/vol1/home/psudmant/local_installations/python-2.6.4/lib/python2.6/site-packages/rpy2/robjects/lib/ggplot2.py",
line 32, in plot
    self._rprint(self, vp = vp)
  File
"/net/gs/vol1/home/psudmant/local_installations/python-2.6.4/lib/python2.6/site-packages/rpy2/robjects/functions.py",
line 81, in __call__
    return super(SignatureTranslatedFunction, self).__call__(*args,
**kwargs)
  File
"/net/gs/vol1/home/psudmant/local_installations/python-2.6.4/lib/python2.6/site-packages/rpy2/robjects/functions.py",
line 35, in __call__
    res = super(Function, self).__call__(*new_args, **new_kwargs)
rpy2.rinterface.RRuntimeError: Error: attempt to apply non-function

Anyone have any ideas?  It would be really helpful, thank you.

-- 
Peter
------------------------------------------------------------------------------
_______________________________________________
rpy-list mailing list
rpy-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rpy-list

Reply via email to