Gory details

wrapper

class biorpy.betteR.BetteR(converter=<function convertToR at 0x1099310c8>)[source]

Wrapper for rpy2.robjects.R

__init__(converter=<function convertToR at 0x1099310c8>)[source]

Initialize the RPy2 wrapper instance

addHandler_(handler)[source]

Add a biorpy.betteR.Handler.

initInteractive()[source]

Checks to see if we’re running interactively (eg ipython), and if so, starts the event manager in RPy2. (This allows resizing of interactive plot windows.)

class biorpy.betteR.Handler(rname, pyname=None, defaults=None, converter=<function convertToR at 0x1099310c8>)[source]

Wrapper for R objects to implement:

  1. default arguments
  2. argument conversion
  3. output conversion
__init__(rname, pyname=None, defaults=None, converter=<function convertToR at 0x1099310c8>)[source]
Parameters:
  • name – name of the R function
  • defaults – a dictionary of default arguments to the function
  • outputs – a dictionary whose values are lists of functions used to extract values from the return R value. For example: {“p.value”:[rx(“p.value”), item(0), item(0)]}
  • converter – a conversion function used to convert python objects into R objects
help()[source]

Displays the R help for the current object

biorpy.betteR.item(i)[source]

Short name for operator.itemgetter()

biorpy.betteR.rx(name)[source]

extracts a value by name from an R object

conversion

class biorpy.conversion.ResultWrapper(result)[source]

Represents output from R as a dictionary-like object, with conversion of each value to a pandas DataFrame or a numpy.array if possible

Attributes that contain a period in R can usually be accessed directly from python by omitting the period (eg, ‘p.value’ can be accessed from ‘pvalue’)

biorpy.conversion.convertToR(obj)[source]

Convert Pandas/Numpy objects to R objects.

If the inumpyut object is a Pandas DataFrame, convert it to an R DataFrame. If it’s a Series, treat it like a vector/numpy array.

biorpy.conversion.pandasDataFrameToRPy2DataFrame(df, strings_as_factors=False)[source]

Convert a pandas DataFrame to a R data.frame.

Parameters:
  • df – The DataFrame being converted
  • strings_as_factors – Whether to turn strings into R factors (default: False)
Returns:

An R data.frame