from pymix import mixture import random from pymix.parse import readMixture from pymix.util.alphabet import Alphabet from pymix.util.dataset import DataSet VNTR = Alphabet(['.', '2/4', '2/7', '3/4', '3/7', '4/4', '4/6', '4/7', '4/8', '4/9', '7/7']) DIAG = Alphabet(['.', '0', '8', '1']) data = DataSet() # iq.txt = iq and achievement test fields from pheno.txt # drd4_len.txt = drd4 vntr types, only number of repeats data.fromFiles(["filt_WISC_WIAT_DISC_134.txt"]) # ,"DRD4_134_len.txt" m = readMixture('pheno_best.py') print "Without deterministic anealing:" m.randMaxEM(data, 100, 30, 0.1, tilt=0, silent=0) print "\nWith deterministic annealing:" m.randMaxEM(data, 100, 30, 0.1, tilt=1, silent=0)
for i in range(2): compPrior.append(DirichletDistribution(4, [1.02, 1.02, 1.02, 1.02])) for i in range(2): compPrior.append(NormalGammaDistribution(1.0, 2.0, 3.0, 4.0)) mixPrior = MixturePrior(0.7, 0.7, piPrior, compPrior) DNA = Alphabet(['A', 'C', 'G', 'T']) comps = [] for i in range(G): dlist = [] for j in range(2): phi = random_vector(4) dlist.append(DiscreteDistribution(4, phi, DNA)) for j in range(2): mu = j + 1.0 sigma = j + 0.5 dlist.append(NormalDistribution(mu, sigma)) comps.append(ProductDistribution(dlist)) pi = random_vector(G) m = BayesMixtureModel(G, pi, comps, mixPrior, struct=1) mixture.writeMixture(m, 'test.bmix') m2 = readMixture('test.bmix') print m2 print m2.prior