Imputation real allelic R2 user Kantale
From PyPedia
Contents |
[edit] Documentation
Computes the R2 (or coefficient of determination) between a real and an imputed genotype.
[edit] Parameters
<inputs> </inputs>
[edit] Return
A float value
[edit] See also
Imputation Allelic R2 user Kantale, Correlation_user_Kantale
[edit] Code
def Imputation_real_allelic_R2_user_Kantale( imputed_allele_1 = None, imputed_allele_2 = None, imputed_gprobs = None, real_genotypes = None, missing = "0", ): if len(imputed_gprobs) != len(real_genotypes): raise Exception("Imputed and real gentypes should have equal legth") real_values = [] imputation_values = [] for real_alleles, gprobs in zip(real_genotypes, imputed_gprobs): real_allele_1, real_allele_2 = real_alleles if real_allele_1 == missing or real_allele_2 == missing: continue if real_allele_1 == imputed_allele_1 and real_allele_2 == imputed_allele_1: real_value = 0.0 elif (real_allele_1 == imputed_allele_1 and real_allele_2 == imputed_allele_2) or (real_allele_1 == imputed_allele_2 and real_allele_2 == imputed_allele_1): real_value = 1.0 elif real_allele_1 == imputed_allele_2 and real_allele_2 == imputed_allele_2: real_value = 2.0 else: #Discordance between REAL and imputed values return -1.0 # imputation_value = (0.0 * gprobs[0]) + (1.0 * gprobs[1]) + (2.0 * gprobs[2]) imputation_value = gprobs[1] + (2.0 * gprobs[2]) real_values += [real_value] imputation_values += [imputation_value] cor = Correlation_user_Kantale(real_values, imputation_values, lib="pyp") r2 = cor * cor return r2
[edit] Unit Tests
def uni1(): return True
[edit] Development Code
def Imputation_real_allelic_R2_user_Kantale(): pass
[edit] Permissions
[edit] Documentation Permissions
Kantale
[edit] Code Permissions
Kantale
[edit] Unit Tests Permissions
Kantale