def __init__(self, shell, Rconverter=Rconverter, pyconverter=np.asarray, cache_display_data=False): """ Parameters ---------- shell : IPython shell pyconverter : callable To be called on values in ipython namespace before assigning to variables in rpy2. cache_display_data : bool If True, the published results of the final call to R are cached in the variable 'display_cache'. """ super(RMagics, self).__init__(shell) self.cache_display_data = cache_display_data self.r = ro.R() self.Rstdout_cache = [] self.pyconverter = pyconverter self.Rconverter = Rconverter
def r_mannwhitneyu(sample1, sample2, exact=True, alternative="two.sided"): sample1 = "c({})".format(str(list(sample1))[1:-1]) sample2 = "c({})".format(str(list(sample2))[1:-1]) robjects.R()("""wres <- wilcox.test({}, {}, alternative="{}"{}); rm(sample1); rm(sample2);""".format(sample1, sample2, alternative, ", exact=TRUE" if exact else "")) wres = robjects.r['wres'] uval = wres[0][0] pval = wres[2][0] return uval, pval
print "cwd is", os.getcwd() print "uid is", os.getuid() print "loaded", __file__ print sys.executable import math import pandas as pd from rpy2 import robjects from rpy2.robjects.packages import importr from rpy2.robjects import pandas2ri from rpy2.robjects import numpy2ri from rpy2.rinterface import RRuntimeError, NULL print(robjects.R()(".libPaths()")) base = importr('base') pandas2ri.activate() numpy2ri.activate() robjects.numpy2ri.activate() ccprofiler = importr('CCprofiler') print("imported from r:", ccprofiler) backend_cache = OrderedDict() def cached_run_secexploerer(protein_ids, id_type):