Example #1
0
def getpeds():
	''' Read the pedigrees from sample_pedigrees and return a dict '''
	PEDDIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..', '..', 'sample_pedigrees'))
	peds = {}
	for filename in glob.glob(PEDDIR + '/*ped'):
		ped = list(read_ped(filename).pedigrees)[0]
		pedname = os.path.basename(filename)[:-4]
		peds[pedname] = ped
	return peds
Example #2
0
def getpeds():
    ''' Read the pedigrees from sample_pedigrees and return a dict '''
    PEDDIR = os.path.abspath(
        os.path.join(os.path.abspath(__file__), '..', '..',
                     'sample_pedigrees'))
    peds = {}
    for filename in glob.glob(PEDDIR + '/*ped'):
        ped = list(read_ped(filename).pedigrees)[0]
        pedname = os.path.basename(filename)[:-4]
        peds[pedname] = ped
    return peds
shares = shares2

print 'Reading null distribution'
with open(ndf) as f:
    nulldist = {}
    for line in f:
        l = line.strip().split()
        fam = l[0]
        values = np.array([float(x) for x in l[1:]])
        nulldist[fam] = values

#with open(affectedf) as f:
#    affecteds = { tuple(x.strip().split()) for x in f }
#    fams = {x[0] for x in affecteds}
peds = read_ped(affectedf)
affecteds = {x for x in peds.individuals if x.phenotypes['affected']}
print '{} affected individuals'.format(len(affecteds))

for ind in peds.individuals:
    if ind.phenotypes['affected'] and ind.is_marryin_founder():
        ind.phenotypes['affected'] = None
#for a in affecteds.copy():
#    if a.is_marryin_founder():
#        print 'Removed affected marry-in founder %s' % a
#        affecteds.remove(a)

affecteds = {x.full_label for x in peds.individuals if x.phenotypes['affected']}
print '{} affecteds after removing marry-in founders'.format(len(affecteds))
fams = {x[0] for x in affecteds}
Example #4
0
parser.add_argument('--freq', dest='freqs', nargs=3, action='append')
parser.add_argument('--prefix', type=str, help='prefix for output file',
                    default='simulation')
parser.add_argument('--verbose', action='store_true', dest='verbosity',
                    help='Print verbose output')
parser.add_argument('--output-filter', dest='predicate', default=None,
                    choices=('affected','phenotyped'), action='store')
parser.add_argument('--compress', choices=('bzip2', 'gzip'), action='store')
parser.add_argument('--seed', type=int, help='Random seed', default=None)
args = parser.parse_args()

if args.seed is not None:
    pydigree.set_seed(args.seed)

# Read the pedigrees
template = read_ped(args.template)

# Read the chromosomes
if not args.chromosomes:
    print('No chromosomes specified!')
    exit()
for cfile in args.chromosomes:
    c = read_gs_chromosome_template(cfile)
    template.add_chromosome(c)
for freq in args.freqs:
    chr, idx, maf = freq
    maf = float(maf)
    chr, idx = int(chr), int(idx)
    # TODO: Sort out frequency semantics
    template.chromosomes[chr].frequencies[idx] = 1-maf
    
Example #5
0
parser.add_argument('--freq', dest='freqs', nargs=3, action='append')
parser.add_argument('--prefix', type=str, help='prefix for output file',
                    default='simulation')
parser.add_argument('--verbose', action='store_true', dest='verbosity',
                    help='Print verbose output')
parser.add_argument('--output-filter', dest='predicate', default=None,
                    choices=('affected', 'phenotyped'), action='store')
parser.add_argument('--compress', choices=('bzip2', 'gzip'), action='store')
parser.add_argument('--seed', type=int, help='Random seed', default=None)
args = parser.parse_args()

if args.seed is not None:
    pydigree.set_seed(args.seed)

# Read the pedigrees
template = read_ped(args.template)

# Read the chromosomes
if not args.chromosomes:
    print('No chromosomes specified!')
    exit()

for cfile in args.chromosomes:
    c = read_gs_chromosome_template(cfile)
    template.add_chromosome(c)

for freq in args.freqs:
    chrom, idx, maf = freq
    maf = float(maf)
    chrom, idx = int(chrom), int(idx)
    # TODO: Sort out frequency semantics
Example #6
0

import os
import glob
from pydigree.io import read_ped

PEDDIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..', '..', 'sample_pedigrees'))
peds = {}
for filename in glob.glob(PEDDIR + '/*ped'):
    ped = list(read_ped(filename).pedigrees)[0]
    pedname = os.path.basename(filename)[:-4]
    peds[pedname] = ped

def test_parents():
	ped = peds['fullsib']
	ped['1'].parents() == (None, None)
	ped['3'].parents() == (ped['1'], ped['2'])

def test_isfounder():
	ped = peds['first_cousins']
	assert ped['1'].is_founder()
	assert not ped['3'].is_founder()
	assert ped['4'].is_founder()

def test_depth():
	ped = peds['first_cousins']
	# Parental generation
	assert ped['1'].depth == 0
	# Marryin founder
	assert ped['4'].depth == 0
	# F1