本文整理汇总了Python中dataset.Dataset.snp_consistency_vector方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.snp_consistency_vector方法的具体用法?Python Dataset.snp_consistency_vector怎么用?Python Dataset.snp_consistency_vector使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dataset.Dataset
的用法示例。
在下文中一共展示了Dataset.snp_consistency_vector方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SumstatSimulation
# 需要导入模块: from dataset import Dataset [as 别名]
# 或者: from dataset.Dataset import snp_consistency_vector [as 别名]
class SumstatSimulation(object):
def __init__(self, name, path=paths.simulations):
self.name = name
self.__dict__.update(
json.load(open(path + name + '.json')))
self.__dataset = Dataset(self.dataset)
def __str__(self):
result = ''
for n in self.__dict__.keys():
if '__' not in n:
result += n + '\t' + str(self.__dict__[n])
return result
def readable_name(self):
return '{},{},h2g={},sample_size={},cond={}'.format(
self.dataset,
self.architecture,
self.h2g,
self.sample_size,
self.condition_on_covariates)
def path_to_genotypes(self):
return self.__dataset.path
def path(self, create=True):
path = self.path_to_genotypes() + self.name + '/'
if create:
fs.makedir(path)
return path
def path_to_beta(self, beta_num, create=True):
path = self.path(create=create) + 'beta.' + str(beta_num) + '/'
if create:
fs.makedir(path)
return path
def beta_file(self, beta_num, mode='rb'):
return open(self.path_to_beta(beta_num) + 'beta', mode)
def noiseless_Y_file(self, beta_num, mode='rb'):
return open(self.path_to_beta(beta_num) + 'noiseless_Y.1darray', mode)
def noisy_Y_file(self, beta_num, index, mode='rb'):
return open(self.path_to_beta(beta_num) +
str(index) + '.Y.1darray', mode)
def individuals_file(self, beta_num, index, mode='rb'):
return open(self.path_to_beta(beta_num) +
str(index) + '.indivs_indices.1darray', mode)
def sumstats_file(self, beta_num, index, mode='rb'):
return open(self.path_to_beta(beta_num) +
str(index) + '.alphahat', mode)
def sumstats_aligned_to_refpanel(self, beta_num, refpanel):
to_flip = self.__dataset.snp_consistency_vector(refpanel)
for alphahat in self.sumstats_files(beta_num):
alphahat[to_flip] *= -1
yield alphahat
def sumstats_files(self, beta_num):
for i in range(1, self.num_samples_per_beta+1):
yield pickle.load(self.sumstats_file(beta_num, i))