本文整理汇总了Python中rpy2.robjects.IntVector方法的典型用法代码示例。如果您正苦于以下问题:Python robjects.IntVector方法的具体用法?Python robjects.IntVector怎么用?Python robjects.IntVector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rpy2.robjects
的用法示例。
在下文中一共展示了robjects.IntVector方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _convert_vector
# 需要导入模块: from rpy2 import robjects [as 别名]
# 或者: from rpy2.robjects import IntVector [as 别名]
def _convert_vector(obj):
if isinstance(obj, robj.IntVector):
return _convert_int_vector(obj)
elif isinstance(obj, robj.StrVector):
return _convert_str_vector(obj)
# Check if the vector has extra information attached to it that can be used
# as an index
try:
attributes = set(r['attributes'](obj).names)
except AttributeError:
return list(obj)
if 'names' in attributes:
return pd.Series(list(obj), index=r['names'](obj))
elif 'tsp' in attributes:
return pd.Series(list(obj), index=r['time'](obj))
elif 'labels' in attributes:
return pd.Series(list(obj), index=r['labels'](obj))
if _rclass(obj) == 'dist':
# For 'eurodist'. WARNING: This results in a DataFrame, not a Series or list.
matrix = r['as.matrix'](obj)
return convert_robj(matrix)
else:
return list(obj)
示例2: plot_module_eigengene
# 需要导入模块: from rpy2 import robjects [as 别名]
# 或者: from rpy2.robjects import IntVector [as 别名]
def plot_module_eigengene(self, module):
'''
barchart illustrating module eigengene
'''
eigengene = self.eigengenes.get_module_eigengene(module)
params = {}
params['height'] = base().as_numeric(eigengene)
limit = max(abs(base().max(eigengene)[0]), abs(base().min(eigengene)[0]))
ylim = [-1 * limit, limit]
params['ylim'] = ro.IntVector(ylim)
colors = ["red" if e[0] > 0 else "blue" for e in eigengene]
params['col'] = ro.StrVector(colors)
params['border'] = ro.NA_Logical
params['las'] = 2
params['names.arg'] = ro.StrVector(self.eigengenes.samples())
params['cex.names'] = 0.6
params['main'] = "Eigengene: " + module
manager = RManager(eigengene, params)
manager.barchart()
示例3: plot_eigengene_network
# 需要导入模块: from rpy2 import robjects [as 别名]
# 或者: from rpy2.robjects import IntVector [as 别名]
def plot_eigengene_network(self):
'''
wrapper for plotEigengeneNetworks function
plots an eigengene network
'''
params = {}
params['multiME'] = base().as_data_frame(self.transpose_data())
params['setLabels'] = ''
params['marDendro'] = ro.IntVector([0, 4, 1, 2])
params['marHeatmap'] = ro.IntVector([3, 4, 1, 2])
params['cex.lab'] = 0.8
params['xLabelsAngle'] = 90
params['colorLabels'] = False
params['signed'] = True
wgcna().plotEigengeneNetworks(**params)
示例4: set_sample_size
# 需要导入模块: from rpy2 import robjects [as 别名]
# 或者: from rpy2.robjects import IntVector [as 别名]
def set_sample_size(self, sampsize):
# sampsize[0] *= self.other_sample_rate
if self.is_onco_pred and self.is_tsg_pred:
sampsize[1] *= self.driver_sample_rate
sampsize[2] *= self.driver_sample_rate
tmp_total_driver = sampsize[1] + sampsize[2]
else:
sampsize[1] *= self.driver_sample_rate
tmp_total_driver = sampsize[1]
sampsize[0] = int(self.other_sample_ratio * tmp_total_driver)
self.sample_size = ro.IntVector(sampsize)
示例5: r_bats
# 需要导入模块: from rpy2 import robjects [as 别名]
# 或者: from rpy2.robjects import IntVector [as 别名]
def r_bats(self, y, components):
components = components.copy()
if 'seasonal_periods' in components:
components['seasonal_periods'] = ro.IntVector(components['seasonal_periods'])
importr('forecast')
r_bats_func = ro.r['bats']
r_forecast = ro.r['forecast']
r_y = ro.FloatVector(list(y))
r_model = r_bats_func(r_y, **components)
summary = r_forecast(r_model)
# predictions = np.array(summary.rx('fitted')).flatten()
return summary, r_model
示例6: r_tbats
# 需要导入模块: from rpy2 import robjects [as 别名]
# 或者: from rpy2.robjects import IntVector [as 别名]
def r_tbats(self, y, components):
components = components.copy()
if 'seasonal_periods' in components:
components['seasonal_periods'] = ro.IntVector(components['seasonal_periods'])
importr('forecast')
r_bats_func = ro.r['tbats']
r_forecast = ro.r['forecast']
r_y = ro.FloatVector(list(y))
r_model = r_bats_func(r_y, **components)
summary = r_forecast(r_model)
# predictions = np.array(summary.rx('fitted')).flatten()
return summary, r_model
示例7: test_init_from_OrdDict
# 需要导入模块: from rpy2 import robjects [as 别名]
# 或者: from rpy2.robjects import IntVector [as 别名]
def test_init_from_OrdDict():
od = rlc.OrdDict(c=(('a', robjects.IntVector((1,2))),
('b', robjects.StrVector(('c', 'd')))
))
dataf = robjects.DataFrame(od)
assert dataf.rx2('a')[0] == 1
示例8: test_init_from_dict
# 需要导入模块: from rpy2 import robjects [as 别名]
# 或者: from rpy2.robjects import IntVector [as 别名]
def test_init_from_dict():
od = {'a': robjects.IntVector((1,2)),
'b': robjects.StrVector(('c', 'd'))}
dataf = robjects.DataFrame(od)
assert dataf.rx2('a')[0] == 1
示例9: test_init_stringsasfactors
# 需要导入模块: from rpy2 import robjects [as 别名]
# 或者: from rpy2.robjects import IntVector [as 别名]
def test_init_stringsasfactors():
od = {'a': robjects.IntVector((1,2)),
'b': robjects.StrVector(('c', 'd'))}
dataf = robjects.DataFrame(od, stringsasfactor=True)
assert isinstance(dataf.rx2('b'), robjects.FactorVector)
dataf = robjects.DataFrame(od, stringsasfactor=False)
assert isinstance(dataf.rx2('b'), robjects.StrVector)
示例10: test_to_csvfile
# 需要导入模块: from rpy2 import robjects [as 别名]
# 或者: from rpy2.robjects import IntVector [as 别名]
def test_to_csvfile():
fh = tempfile.NamedTemporaryFile(mode = "w", delete = False)
fh.close()
d = {'letter': robjects.StrVector('abc'),
'value' : robjects.IntVector((1, 2, 3))}
dataf = robjects.DataFrame(d)
dataf.to_csvfile(fh.name)
dataf = robjects.DataFrame.from_csvfile(fh.name)
assert dataf.nrow == 3
assert dataf.ncol == 2
示例11: tests_package_from_env
# 需要导入模块: from rpy2 import robjects [as 别名]
# 或者: from rpy2.robjects import IntVector [as 别名]
def tests_package_from_env(self):
env = robjects.Environment()
env['a'] = robjects.StrVector('abcd')
env['b'] = robjects.IntVector((1,2,3))
env['c'] = robjects.r(''' function(x) x^2''')
pck = robjects.packages.Package(env, "dummy_package")
assert isinstance(pck.a, robjects.Vector)
assert isinstance(pck.b, robjects.Vector)
assert isinstance(pck.c, robjects.Function)
示例12: test_new_with_dot_conflict
# 需要导入模块: from rpy2 import robjects [as 别名]
# 或者: from rpy2.robjects import IntVector [as 别名]
def test_new_with_dot_conflict(self):
env = robjects.Environment()
env['a.a_a'] = robjects.StrVector('abcd')
env['a_a.a'] = robjects.IntVector((1,2,3))
env['c'] = robjects.r(''' function(x) x^2''')
with pytest.raises(packages.LibraryError):
robjects.packages.Package(env, "dummy_package")
示例13: test_call_with_sexp
# 需要导入模块: from rpy2 import robjects [as 别名]
# 或者: from rpy2.robjects import IntVector [as 别名]
def test_call_with_sexp():
ri_f = rinterface.baseenv.find('sum')
ro_f = Function(ri_f)
ro_v = robjects.IntVector(array.array('i', [1,2,3]))
s = ro_f(ro_v)
assert s[0] == 6
示例14: test_call
# 需要导入模块: from rpy2 import robjects [as 别名]
# 或者: from rpy2.robjects import IntVector [as 别名]
def test_call():
ri_f = rinterface.baseenv.find('sum')
ro_f = robjects.Function(ri_f)
ro_v = robjects.IntVector(array.array('i', [1,2,3]))
s = ro_f(ro_v)
assert s[0] == 6
示例15: test_init
# 需要导入模块: from rpy2 import robjects [as 别名]
# 或者: from rpy2.robjects import IntVector [as 别名]
def test_init():
identical = ri.baseenv["identical"]
py_a = array.array('i', [1,2,3])
ro_v = robjects.IntVector(py_a)
assert ro_v.typeof == ri.RTYPES.INTSXP
ri_v = ri.IntSexpVector(py_a)
ro_v = robjects.IntVector(ri_v)
assert identical(ro_v, ri_v)[0]
del(ri_v)
assert ro_v.typeof == ri.RTYPES.INTSXP