#!/usr/bin/python ############################################################################### # NAME: new_methods.py # VERSION: 2.0.0a5 (12DECEMBER2005) # AUTHOR: John B. Cole, PhD ([email protected]) # LICENSE: LGPL ############################################################################### from PyPedal import pyp_newclasses from PyPedal.pyp_utils import pyp_nice_time if __name__ == '__main__': print 'Starting pypedal.py at %s' % (pyp_nice_time()) print '=' * 80 # This should fail because we are providing neither a dictionary # of options or a configuration file name. print 'This load should fail' myped1 = pyp_newclasses.loadPedigree() print myped1 print '-' * 80 # This should fail because we are providing an empty dictionary # and there is no configuration file named pypedal.ini in the # examples directory. options = {} print 'This load should fail'
#!/usr/bin/python ############################################################################### # NAME: new_graphics2.py # VERSION: 2.0.0b10 (27APRIL2006) # AUTHOR: John B. Cole, PhD ([email protected]) # LICENSE: LGPL ############################################################################### from PyPedal import pyp_demog from PyPedal import pyp_graphics from PyPedal import pyp_newclasses from PyPedal import pyp_nrm from PyPedal import pyp_metrics from PyPedal.pyp_utils import pyp_nice_time #import pyp_demog, pyp_graphics, pyp_newclasses, pyp_nrm, pyp_metrics #from pyp_utils import pyp_nice_time if __name__ == '__main__': print 'Starting pypedal.py at %s' % (pyp_nice_time()) example = pyp_newclasses.loadPedigree(optionsfile='new_graphics.ini') if example.kw['messages'] == 'verbose': print '[INFO]: Calling pyp_graphics.draw_pedigree() at %s' % (pyp_nice_time()) pyp_graphics.draw_pedigree(example, gfilename='graphics2', gtitle='graphics2 pedigree', gorient='p')
#!/usr/bin/python ############################################################################### # NAME: new_methods.py # VERSION: 2.0.0a5 (12DECEMBER2005) # AUTHOR: John B. Cole, PhD ([email protected]) # LICENSE: LGPL ############################################################################### from PyPedal import pyp_newclasses from PyPedal.pyp_utils import pyp_nice_time if __name__=='__main__': print 'Starting pypedal.py at %s' % (pyp_nice_time()) print '='*80 # This should fail because we are providing neither a dictionary # of options or a configuration file name. print 'This load should fail' myped1 = pyp_newclasses.loadPedigree() print myped1 print '-'*80 # This should fail because we are providing an empty dictionary # and there is no configuration file named pypedal.ini in the # examples directory. options = {} print 'This load should fail'
############################################################################### # NAME: new_lacy.py # VERSION: 2.0.0b5 (14DECEMBER2005) # AUTHOR: John B. Cole, PhD ([email protected]) # LICENSE: LGPL ############################################################################### from PyPedal import pyp_newclasses from PyPedal import pyp_nrm from PyPedal import pyp_metrics from PyPedal.pyp_utils import pyp_nice_time if __name__ == '__main__': print 'Starting pypedal.py at %s' % (pyp_nice_time()) # Example taken from Lacy (1989), Appendix A. example = pyp_newclasses.loadPedigree(optionsfile='new_lacy.ini',debugLoad=True) example.printoptions() if example.kw['messages'] == 'verbose': print '='*80 print '[INFO]: Calling pyp_metrics.effective_founders_lacy at %s' % (pyp_nice_time()) pyp_metrics.effective_founders_lacy(example) # Example taken from Boichard et al. (1997), Figure 2 / Table II. example2a = pyp_newclasses.loadPedigree(optionsfile='new_format.ini') if example2a.kw['messages'] == 'verbose': print '='*80 print '[INFO]: Calling pyp_metrics.effective_founders_lacy at %s' % (pyp_nice_time()) pyp_metrics.effective_founders_lacy(example2a)
############################################################################### # NAME: new_amatrix.py # VERSION: 2.0.0rc7 (07MAY2008) # AUTHOR: John B. Cole, PhD ([email protected]) # LICENSE: LGPL ############################################################################### from PyPedal import pyp_newclasses from PyPedal import pyp_nrm from PyPedal.pyp_utils import pyp_nice_time import numpy import time options = {} options['messages'] = 'verbose' options['pedfile'] = 'vizsla_ped3.csv' options['pedformat'] = 'asd' options['reorder'] = 1 options['reorder_max_rounds'] = 1000 options['has_header'] = 1 options['sepchar'] = ',' options['pedname'] = 'Viszla Pedigree' options['debug_messages'] = 0 if __name__ == '__main__': print 'PyPedal started at %s' % (pyp_nice_time()) viszla = pyp_newclasses.loadPedigree(options, debugLoad=True) print 'PyPedal stopped at %s' % (pyp_nice_time())
# VERSION: 2.0.0b5 (13DECEMBER2005) # AUTHOR: John B. Cole, PhD ([email protected]) # LICENSE: LGPL ############################################################################### from PyPedal import pyp_graphics from PyPedal import pyp_newclasses from PyPedal.pyp_utils import pyp_nice_time if __name__ == '__main__': example = pyp_newclasses.loadPedigree(optionsfile='new_doug.ini') if example.kw['messages'] == 'verbose': print '[INFO]: Calling pyp_graphics.draw_pedigree() at %s' % ( pyp_nice_time()) pyp_graphics.draw_pedigree(example, gfilename='doug_below', gtitle='Doug the German Shepherd (B)', gorient='p', gname=1, gdirec='', gfontsize=12, garrow=0, gtitloc='b') pyp_graphics.draw_pedigree(example, gfilename='doug_above', gtitle='Doug the German Shepherd (A)', gorient='p',
#options['pedformat'] = 'asdgb' options['pedformat'] = 'asd' options['pedname'] = 'My Pedigree' options['matrix_type'] = 'sparse' options['renumber'] = 0 options['pedigree_is_renumbered'] = 1 if __name__ == '__main__': # example = pyp_newclasses.loadPedigree(optionsfile='new_inbreeding.ini') example = pyp_newclasses.loadPedigree(options) print example print '[DEBUG]: matrix_type = ', example.kw['matrix_type'] print 'Started computing inbreeding at %s' % (pyp_nice_time()) example_inbreeding_vr = pyp_nrm.inbreeding(example,method='vanraden') example_inbreeding_ml = pyp_nrm.inbreeding(example,method='meu_luo') example_inbreeding_qu = pyp_nrm.inbreeding(example,method='mod_meu_luo') print 'Finished computing inbreeding at %s' % (pyp_nice_time()) # print example_inbreeding # print example_inbreeding['fx'][28] print '\nVanRaden : ', example_inbreeding_vr['metadata'] print '\nMeuwissen and Luo : ', example_inbreeding_ml['metadata'] print '\nModified Meuwissen and Luo: ', example_inbreeding_qu['metadata'] # example_2 = pyp_newclasses.loadPedigree(optionsfile='new_inbreeding_2.ini') # example_inbreeding_2 = pyp_nrm.inbreeding(example_2) # print example_inbreeding_2 # print 'f_x for 73543: ', example_inbreeding_2['fx'][example_2.idmap[int('73543')]]
# NAME: new_amatrix.py # VERSION: 2.0.0rc7 (07MAY2008) # AUTHOR: John B. Cole, PhD ([email protected]) # LICENSE: LGPL ############################################################################### from PyPedal import pyp_newclasses from PyPedal import pyp_nrm from PyPedal.pyp_utils import pyp_nice_time import numpy import time if __name__ == '__main__': print 'Starting pypedal.py at %s' % (pyp_nice_time()) example = pyp_newclasses.loadPedigree(optionsfile='new_amatrix.ini') amatrix = pyp_newclasses.NewAMatrix(example.kw) amatrix.form_a_matrix(example.pedigree) # Here's how to save a matrix to a binary file. # amatrix.save('boichard2_pedigree.bin') # Here's how to load a matrix from a binary file. # amatrix2 = pyp_newclasses.NewAMatrix(example.kw) # amatrix2.load('boichard2_pedigree.bin') # Calculate coefficients of inbreeding on this pedigree. print '\tEntering pyp_nrm.inbreeding() at %s' % (pyp_nice_time())
from PyPedal import pyp_newclasses from PyPedal import pyp_nrm from PyPedal import pyp_utils # Create a dictionary to hold options, such as the name of the # input file, and its format. options = {} options['pedfile'] = 'new_amatrix.ped' options['pedname'] = 'A Large Dog Pedigree' options['pedformat'] = 'asdgb' options['messages'] = 'verbose' options['renumber'] = 1 if __name__ == '__main__': print 'Starting pypedal.py at %s' % (pyp_utils.pyp_nice_time()) # example is a PyPedal NewPedigree object that stores the individual # animal records, as well as other information about the pedigree. # Most things are done by calling methods on example, or by passing # it to functions. example = pyp_newclasses.loadPedigree(optionsfile='new_amatrix.ini') # We're going to create an instance of the NewAMatrix class, which we # can use to store relationship matrices, and then create the A matrix # from the pedigree stored in example. Note that we can only store # matrices that we can allocate in memory! amatrix = pyp_newclasses.NewAMatrix(example.kw) amatrix.form_a_matrix(example.pedigree) # Here's how to save the A matrix to a binary file.
############################################################################### # NAME: new_classes.py # VERSION: 2.0.0b5 (13DECEMBER2005) # AUTHOR: John B. Cole, PhD ([email protected]) # LICENSE: LGPL ############################################################################### from PyPedal import pyp_graphics from PyPedal import pyp_newclasses from PyPedal import pyp_nrm from PyPedal.pyp_utils import pyp_nice_time if __name__ == '__main__': print 'Starting pypedal.py at %s' % (pyp_nice_time()) example = pyp_newclasses.loadPedigree(optionsfile='new_classes.ini') if example.kw['messages'] == 'verbose': print '[INFO]: Forming numerator relationship matrix at %s' % ( pyp_nice_time()) my_a = pyp_nrm.fast_a_matrix_r(example.pedigree, example.kw) if example.kw['messages'] == 'verbose': print '[INFO]: Visualizing NRM sparsity at %s' % (pyp_nice_time()) pyp_graphics.rmuller_spy_matrix_pil(my_a, fname='boichard2_spy.png') if example.kw['messages'] == 'verbose':
#options['pedformat'] = 'asdgb' options['pedformat'] = 'asd' options['pedname'] = 'My Pedigree' options['matrix_type'] = 'sparse' options['renumber'] = 0 options['pedigree_is_renumbered'] = 1 if __name__ == '__main__': # example = pyp_newclasses.loadPedigree(optionsfile='new_inbreeding.ini') example = pyp_newclasses.loadPedigree(options) print example print '[DEBUG]: matrix_type = ', example.kw['matrix_type'] print 'Started computing inbreeding at %s' % (pyp_nice_time()) example_inbreeding_vr = pyp_nrm.inbreeding(example, method='vanraden') example_inbreeding_ml = pyp_nrm.inbreeding(example, method='meu_luo') example_inbreeding_qu = pyp_nrm.inbreeding(example, method='mod_meu_luo') print 'Finished computing inbreeding at %s' % (pyp_nice_time()) # print example_inbreeding # print example_inbreeding['fx'][28] print '\nVanRaden : ', example_inbreeding_vr['metadata'] print '\nMeuwissen and Luo : ', example_inbreeding_ml['metadata'] print '\nModified Meuwissen and Luo: ', example_inbreeding_qu['metadata'] # example_2 = pyp_newclasses.loadPedigree(optionsfile='new_inbreeding_2.ini') # example_inbreeding_2 = pyp_nrm.inbreeding(example_2) # print example_inbreeding_2 # print 'f_x for 73543: ', example_inbreeding_2['fx'][example_2.idmap[int('73543')]]
# AUTHOR: John B. Cole, PhD ([email protected]) # LICENSE: LGPL ############################################################################### from PyPedal import pyp_newclasses from PyPedal import pyp_network from PyPedal.pyp_utils import pyp_nice_time try: import networkx except ImportError: logging.error('The networkx module could not be imported in pyp_network. Routines using networkx functionality are not available.') if __name__=='__main__': print 'Starting pypedal.py at %s' % ( pyp_nice_time() ) print '\tLoading pedigree at %s' % ( pyp_nice_time() ) example = pyp_newclasses.loadPedigree(optionsfile='new_networkx.ini') print 'Calling pyp_network.ped_to_graph()' ng = pyp_network.ped_to_graph(example) # print 'The graph has %d nodes' % len(ng.nodes()) # print ng.nodes() # print ng.edges() # ## print 'Drawing graph madeup.ps' ## networkx.drawing.draw(ng) ## networkx.drawing.savefig("madeup.ps") ##
#!/usr/bin/python ############################################################################### # NAME: new_simulate.py # VERSION: 2.0.0b15 (08JUNE2005) # AUTHOR: John B. Cole, PhD ([email protected]) # LICENSE: LGPL ############################################################################### from PyPedal import pyp_newclasses from PyPedal import pyp_graphics from PyPedal import pyp_network from PyPedal import pyp_nrm from PyPedal import pyp_utils if __name__ == '__main__': print 'Simulating pedigree at %s' % pyp_utils.pyp_nice_time() example = pyp_newclasses.loadPedigree(optionsfile='new_simulate.ini') #print 'Calculating inbreeding at %s' % pyp_utils.pyp_nice_time() #@profile #example_inbreeding = pyp_nrm.inbreeding(example, method='vanraden') print 'Finished at %s' % pyp_utils.pyp_nice_time()
############################################################################### # NAME: new_methods.py # VERSION: 2.0.0b5 (19DECEMBER2005) # AUTHOR: John B. Cole, PhD ([email protected]) # LICENSE: LGPL ############################################################################### from PyPedal import pyp_newclasses from PyPedal import pyp_metrics from PyPedal import pyp_nrm from PyPedal import pyp_utils from PyPedal.pyp_utils import pyp_nice_time if __name__=='__main__': print 'Starting pypedal.py at %s' % ( pyp_nice_time() ) example = pyp_newclasses.loadPedigree(optionsfile='new_format.ini') #pyp_utils.assign_offspring(example) #print 'First ID: %s' % ( example.kw['id_first'] ) #print 'Last ID: %s' % ( example.kw['id_last'] ) inbr, reln = inbr, reln = pyp_nrm.inbreeding(example,method='vanraden',rels=1) print 'inbr: ', inbr print 'reln: ', reln example.nrm = pyp_newclasses.NewAMatrix(example.kw) example.nrm.form_a_matrix(example.pedigree) example.nrm.save('Amatrix.txt') inbr2, reln2 = pyp_nrm.inbreeding(example,method='vanraden',rels=1)
############################################################################### # NAME: new_classes.py # VERSION: 2.0.0b5 (13DECEMBER2005) # AUTHOR: John B. Cole, PhD ([email protected]) # LICENSE: LGPL ############################################################################### from PyPedal import pyp_graphics from PyPedal import pyp_newclasses from PyPedal import pyp_nrm from PyPedal.pyp_utils import pyp_nice_time if __name__ == '__main__': print 'Starting pypedal.py at %s' % ( pyp_nice_time() ) example = pyp_newclasses.loadPedigree(optionsfile='new_classes.ini') if example.kw['messages'] == 'verbose': print '[INFO]: Forming numerator relationship matrix at %s' % ( pyp_nice_time() ) my_a = pyp_nrm.fast_a_matrix_r(example.pedigree,example.kw) if example.kw['messages'] == 'verbose': print '[INFO]: Visualizing NRM sparsity at %s' % ( pyp_nice_time() ) pyp_graphics.rmuller_spy_matrix_pil(my_a,fname='boichard2_spy.png') if example.kw['messages'] == 'verbose': print '[INFO]: Visualizing NRM in pseudocolor at %s' % ( pyp_nice_time() )
#!/usr/bin/python ############################################################################### # NAME: new_doug.py # VERSION: 2.0.0b5 (13DECEMBER2005) # AUTHOR: John B. Cole, PhD ([email protected]) # LICENSE: LGPL ############################################################################### from PyPedal import pyp_graphics from PyPedal import pyp_newclasses from PyPedal.pyp_utils import pyp_nice_time if __name__ == '__main__': example = pyp_newclasses.loadPedigree(optionsfile='new_doug.ini') if example.kw['messages'] == 'verbose': print '[INFO]: Calling pyp_graphics.draw_pedigree() at %s' % (pyp_nice_time()) pyp_graphics.draw_pedigree(example, gfilename='doug_below', gtitle='Doug the German Shepherd (B)', gorient='p', gname=1, gdirec='', gfontsize=12, garrow=0, gtitloc='b') pyp_graphics.draw_pedigree(example, gfilename='doug_above', gtitle='Doug the German Shepherd (A)', gorient='p', gname=1, gdirec='', gfontsize=12, garrow=0, gtitloc='t') pyp_graphics.draw_pedigree(example, gfilename='doug_p_rl_notitle', gtitle='', gorient='p', gname=1, gdirec='RL', gfontsize=12)