Beispiel #1
0
#!/usr/bin/python

###############################################################################
# NAME: new_graphics.py
# VERSION: 2.0.0b5 (19DECEMBER2005)
# AUTHOR: John B. Cole, PhD ([email protected])
# LICENSE: LGPL
###############################################################################

from PyPedal import pyp_graphics
from PyPedal import pyp_newclasses
from PyPedal import pyp_nrm

if __name__ == '__main__':

    example = pyp_newclasses.loadPedigree(optionsfile='new_renumbering.ini')

    print '-'*80
    print 'INFO: Pedigree ID map: %s' % (example.idmap)
    print '-'*80
    print 'INFO: Pedigree ID reverse map: %s' % (example.backmap)
    print '-'*80
    myinbr = pyp_nrm.inbreeding(example)
    print 'INFO: Coefficients of inbreeding: %s' % (myinbr)

    pyp_graphics.draw_pedigree(example,gfilename='new_renumbering',gtitle='My  Pedigree')
Beispiel #2
0
from PyPedal import pyp_network
import networkx

if __name__ == '__main__':

    for i in range(1):
        print 'Simulating and drawing pedigree %d' % (i)
        example = pyp_newclasses.loadPedigree(optionsfile='new_simulate.ini')
        print example

        #_gfn = 'simulated_pedigree_%d' % ( i )
        _gfn = 'simulated_pedigree'
        _gt = 'Simulated Pedigree %d' % (i)
        pyp_graphics.draw_pedigree(example,
                                   gfilename=_gfn,
                                   gtitle=_gt,
                                   gformat='ps',
                                   garrow=0,
                                   gclusters=0)

        #print 'Animal\tOriginal\tSire\tDam\tSex\tGen'
        #for _p in example.pedigree:
        #print '%s\t%s\t\t%s\t%s\t%s\t%s' % ( _p.animalID, _p.originalID, _p.sireID, _p.damID, _p.sex, _p.gen )

        #print example.idmap

        pg = pyp_network.ped_to_graph(example)

        pgd = networkx.is_directed_acyclic_graph(pg)
        print 'is_directed_acyclic_graph: %s' % (pgd)

        pgu = pg.to_undirected()
Beispiel #3
0
                                           width=example.nrm.nrm.shape[0])

    #pyp_db.loadPedigreeTable(example)
    pyp_db.deleteTable(example)
    pyp_db.populatePedigreeTable(example)
    coi_by_year = pyp_reports.meanMetricBy(example, metric='fa', byvar='by')
    print 'coi_by_year: ', coi_by_year
    cby = coi_by_year
    del (cby[1900])
    pyp_graphics.plot_line_xy(coi_by_year,
                              gfilename='dog_coi_by_year',
                              gtitle='',
                              gxlabel='Birth year',
                              gylabel='Coefficient of inbreeding')

    pyp_graphics.draw_pedigree(example,
                               gfilename='dog_pedigree',
                               gtitle='Dog pedigree',
                               gformat='jpg',
                               gsize='f')

    pyp_graphics.plot_founders_by_year(
        example,
        gfilename='dog_founders_by_year',
        gtitle='Number of founders within each birthyear')

    pyp_graphics.plot_founders_pct_by_year(
        example,
        gfilename='dog_founder_pct',
        gtitle='Percentage of founders within each birthyear')
Beispiel #4
0
from PyPedal import pyp_graphics
from PyPedal import pyp_newclasses
from PyPedal import pyp_nrm
from PyPedal import pyp_reports
from PyPedal.pyp_utils import pyp_nice_time

if __name__ == '__main__':

    example = pyp_newclasses.loadPedigree(optionsfile='new_graphics.ini')
#     example_inbreeding = pyp_nrm.inbreeding(example)

    pyp_graphics.rmuller_spy_matrix_pil(example.nrm.nrm, fname='dog_sparsity.png', cutoff=0.01, do_outline=0, height=example.nrm.nrm.shape[0], width=example.nrm.nrm.shape[0])

    pyp_graphics.rmuller_pcolor_matrix_pil(example.nrm.nrm, fname='dog_long_pcolored.png', do_outline=0, height=example.nrm.nrm.shape[0], width=example.nrm.nrm.shape[0])

    #pyp_db.loadPedigreeTable(example)
    pyp_db.deleteTable(example)
    pyp_db.populatePedigreeTable(example)
    coi_by_year = pyp_reports.meanMetricBy(example, metric='fa', byvar='by')
    print 'coi_by_year: ', coi_by_year
    cby = coi_by_year
    del(cby[1900])
    pyp_graphics.plot_line_xy(coi_by_year, gfilename='dog_coi_by_year',
        gtitle='', gxlabel='Birth year', gylabel='Coefficient of inbreeding')

    pyp_graphics.draw_pedigree(example, gfilename='dog_pedigree', gtitle='Dog pedigree',gformat='jpg',gsize='f')

    pyp_graphics.plot_founders_by_year(example, gfilename='dog_founders_by_year', gtitle='Number of founders within each birthyear')

    pyp_graphics.plot_founders_pct_by_year(example, gfilename='dog_founder_pct', gtitle='Percentage of founders within each birthyear')
Beispiel #5
0
    #coi_by_year

    #print ib
    #for _e in example.pedigree:
    #print _e.name, _e.fa

    print example.kw['paper_size']

    #print example.backmap
    ## Use with new_renumbering.ped.
    #pyp_reports.pdf3GenPed([56,72], example)
    ## Use with horse.ped.
    #pyp_reports.pdf3GenPed(["Pie's Joseph","Green's Dingo"], example)
    #pyp_reports.pdf3GenPed("Green's Dingo", example,reportfile='greens_dingo_pedigree.pdf')
    #pyp_reports.pdf3GenPed(example.namemap.keys(), example)

    pyp_graphics.draw_pedigree(example, gfilename='greens_dingo_pedigree', \
  gtitle="Green's Dingo pedigree", gname=1, gformat='ps', garrow=1)

    #matings = {}
    #for s in example.metadata.unique_sire_list:
    #    for d in example.metadata.unique_dam_list:
    #        matings[example.pedigree[s-1].name] = example.pedigree[d-1].name
    #pyp_metrics.mating_coi_group(matings,example,names=1)

    pg = pyp_network.ped_to_graph(example)
    #print pg, pg.degree(), pg.nodes()
    census = pyp_network.dyad_census(pg, debug=1)
    print 'max dyads:\t', ((pg.order() * (pg.order() - 1)) / 2)
    print 'census:\t\t', census
Beispiel #6
0
#!/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')
Beispiel #7
0
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')
Beispiel #8
0
#!/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')
Beispiel #9
0
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())

    pyp_graphics.rmuller_pcolor_matrix_pil(my_a, fname='boichard2_pcolor.png')

    pyp_graphics.draw_pedigree(example, gfilename='boichard2_pedigree', \
        gtitle='', gorient='p', gdirec='RL', gfontsize=12)

    print 'Stopping pypedal.py at %s' % (pyp_nice_time())
Beispiel #10
0
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() )

    pyp_graphics.rmuller_pcolor_matrix_pil(my_a,fname='boichard2_pcolor.png')

    pyp_graphics.draw_pedigree(example, gfilename='boichard2_pedigree', \
        gtitle='', gorient='p', gdirec='RL', gfontsize=12)

    print 'Stopping pypedal.py at %s' % ( pyp_nice_time() )
Beispiel #11
0
#!/usr/bin/python

###############################################################################
# NAME: new_hartl.py
# VERSION: 2.0.0b12 (15MAY2060)
# AUTHOR: John B. Cole, PhD ([email protected])
# LICENSE: LGPL
###############################################################################

from PyPedal import pyp_graphics
from PyPedal import pyp_newclasses
from PyPedal import pyp_nrm

if __name__ == '__main__':

    example = pyp_newclasses.loadPedigree(optionsfile='new_hartl.ini')

    pyp_graphics.draw_pedigree(
        example,
        gfilename='hartlandclark',
        gtitle='Pedigree from van Noordwijck and Scharloo (1981)',
        gorient='p',
        gname=0,
        gdirec='',
        gfontsize=12,
        garrow=0)

    example_inbreeding = pyp_nrm.inbreeding(example)
    print example_inbreeding
Beispiel #12
0
from PyPedal import  pyp_newclasses
from PyPedal import  pyp_graphics
from PyPedal import  pyp_network
import networkx

if __name__ == '__main__':

    for i in range(1):
        print 'Simulating and drawing pedigree %d' % ( i )
        example = pyp_newclasses.loadPedigree(optionsfile='new_simulate.ini')
        print example

        #_gfn = 'simulated_pedigree_%d' % ( i )
        _gfn = 'simulated_pedigree'
        _gt = 'Simulated Pedigree %d' % ( i )
        pyp_graphics.draw_pedigree(example, gfilename=_gfn, gtitle=_gt, gformat='ps', garrow=0, gclusters=0)

        #print 'Animal\tOriginal\tSire\tDam\tSex\tGen'
        #for _p in example.pedigree:
            #print '%s\t%s\t\t%s\t%s\t%s\t%s' % ( _p.animalID, _p.originalID, _p.sireID, _p.damID, _p.sex, _p.gen )

        #print example.idmap

        pg = pyp_network.ped_to_graph(example)

        pgd = networkx.is_directed_acyclic_graph(pg)
        print 'is_directed_acyclic_graph: %s' % ( pgd )

        pgu = pg.to_undirected()
        pgc = networkx.is_connected(pgu)
        print 'is_connected: %s' % ( pgc )
Beispiel #13
0
    #coi_by_year

    #print ib
    #for _e in example.pedigree:
        #print _e.name, _e.fa

    print example.kw['paper_size']

    #print example.backmap
    ## Use with new_renumbering.ped.
    #pyp_reports.pdf3GenPed([56,72], example)
    ## Use with horse.ped.
    #pyp_reports.pdf3GenPed(["Pie's Joseph","Green's Dingo"], example)
    #pyp_reports.pdf3GenPed("Green's Dingo", example,reportfile='greens_dingo_pedigree.pdf')
    #pyp_reports.pdf3GenPed(example.namemap.keys(), example)

    pyp_graphics.draw_pedigree(example, gfilename='greens_dingo_pedigree', \
		gtitle="Green's Dingo pedigree", gname=1, gformat='ps', garrow=1)

    #matings = {}
    #for s in example.metadata.unique_sire_list:
    #    for d in example.metadata.unique_dam_list:
    #        matings[example.pedigree[s-1].name] = example.pedigree[d-1].name
    #pyp_metrics.mating_coi_group(matings,example,names=1)

    pg = pyp_network.ped_to_graph(example)
    #print pg, pg.degree(), pg.nodes()
    census = pyp_network.dyad_census(pg,debug=1)
    print 'max dyads:\t', ( ( pg.order()*(pg.order()-1) ) / 2 )
    print 'census:\t\t', census
Beispiel #14
0
#!/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)
Beispiel #15
0
#!/usr/bin/python

###############################################################################
# NAME: new_hartl.py
# VERSION: 2.0.0b12 (15MAY2060)
# AUTHOR: John B. Cole, PhD ([email protected])
# LICENSE: LGPL
###############################################################################

from PyPedal import pyp_graphics
from PyPedal import pyp_newclasses
from PyPedal import pyp_nrm

if __name__ == '__main__':

    example = pyp_newclasses.loadPedigree(optionsfile='new_hartl.ini')

    pyp_graphics.draw_pedigree(example, gfilename='hartlandclark',
        gtitle='Pedigree from van Noordwijck and Scharloo (1981)',
        gorient='p', gname=0, gdirec='', gfontsize=12, garrow=0)

    example_inbreeding = pyp_nrm.inbreeding(example)
    print example_inbreeding