def _get_coef(gene, models, matrix_manager, variances, t1, t2): model_1 = models.loc[t1] snps_1 = set(model_1.index.get_level_values(0)) if len(snps_1) == 0: return None model_2 = models.loc[t2] snps_2 = set(model_2.index.get_level_values(0)) if len(snps_2) == 0: return None s1, s2, matrix = matrix_manager.get_2(gene, snps_1, snps_2) if len(s1) == 0 or len(s2) == 0: return None w1 = model_1.loc[s1].weight.values w2 = model_2.loc[s2].weight.values denom = numpy.float64(numpy.sqrt(variances[t1] * variances[t2])) if denom == 0: return numpy.nan num = numpy.float64(_d(_d(w1, matrix), w2)) coef = num / denom return coef
def _get_coef_2(gene, models, matrix_manager, variances, t1, t2): model_1 = models[t1] snps_1 = set(model_1.keys()) if len(snps_1) == 0: return None model_2 = models[t2] snps_2 = set(model_2.keys()) if len(snps_2) == 0: return None s1, s2, matrix = matrix_manager.get_2(gene, snps_1, snps_2) if len(s1) == 0 or len(s2) == 0: return None w1 = numpy.array([model_1[x] for x in s1], dtype=numpy.float64) w2 = numpy.array([model_2[x] for x in s2], dtype=numpy.float64) denom = numpy.float64(numpy.sqrt(variances[t1] * variances[t2])) if denom == 0: return numpy.nan num = numpy.float64(_d(_d(w1, matrix), w2)) coef = num / denom return coef
def _get_coef(gene, models, matrix_manager, variances, t1, t2): model_1 = models.loc[t1] snps_1 = set(model_1.index.get_level_values(0)) if len(snps_1) == 0: return None model_2 = models.loc[t2] snps_2 = set(model_2.index.get_level_values(0)) if len(snps_2) == 0: return None s1, s2, matrix = matrix_manager.get_2(gene, snps_1, snps_2) if len(s1) == 0 or len(s2) == 0: return None w1 = model_1.loc[s1].weight.values w2 = model_2.loc[s2].weight.values denom = numpy.float64(numpy.sqrt(variances[t1] * variances[t2])) if denom == 0: return numpy.nan num = numpy.float64(_d(_d(w1, matrix), w2)) coef = num/denom return coef
def _get_coef_2(gene, models, matrix_manager, variances, t1, t2): model_1 = models[t1] snps_1 = set(model_1.keys()) if len(snps_1) == 0: return None model_2 = models[t2] snps_2 = set(model_2.keys()) if len(snps_2) == 0: return None s1, s2, matrix = matrix_manager.get_2(gene, snps_1, snps_2) if len(s1) == 0 or len(s2) == 0: return None w1 = numpy.array([model_1[x] for x in s1], dtype=numpy.float64) w2 = numpy.array([model_2[x] for x in s2], dtype=numpy.float64) denom = numpy.float64(numpy.sqrt(variances[t1] * variances[t2])) if denom == 0: return numpy.nan num = numpy.float64(_d(_d(w1, matrix), w2)) coef = num/denom return coef
def _get_variance(models, matrix_manager, gene, tissue): model = models.loc[tissue] snps = set(model.index.get_level_values(0).values) #Remember that only those snps with data in the GWAS will get loaded. snps, matrix = matrix_manager.get(gene, snps, strict_whitelist=False) if len(snps) == 0: return None weights = model.loc[snps].weight.values variance = _d(_d(weights, matrix), weights) variance = numpy.float64(variance) return variance
def _get_variance_2(models, matrix_manager, gene, tissue): model = models[tissue] snps = set(model.keys()) #Remember that only those snps with data in the GWAS will get loaded. snps, matrix = matrix_manager.get(gene, snps, strict_whitelist=False) if len(snps) == 0: return None weights = numpy.array([model[x] for x in snps], dtype=numpy.float64) variance = _d(_d(weights, matrix), weights) variance = numpy.float64(variance) return variance