예제 #1
0
    def from_genomesimla(filename):
        """
        Reads positions and frequencies from a genomeSIMLA template file

        :param filename: path to the template
        :type filename: string
        :returns: Template containing the data from the file
        :rtype: ChromosomeTemplate
        """
        return read_gs_chromosome_template(filename)
예제 #2
0
    def from_genomesimla(filename):
        """
        Reads positions and frequencies from a genomeSIMLA template file

        :param filename: path to the template
        :type filename: string
        :returns: Template containing the data from the file
        :rtype: ChromosomeTemplate
        """
        return read_gs_chromosome_template(filename)
예제 #3
0
from pydigree.io.genomesimla import read_gs_chromosome_template
from pydigree.population import logistic_growth

parser = argparse.ArgumentParser()
parser.add_argument("--chromosomes", dest="chromosomes", nargs="+", help="genomeSIMLA format chromosome templates")
parser.add_argument("--n0", dest="n0", type=int, help="Initial pool size", default=5000)
parser.add_argument("--rate", dest="rate", type=float, help="Growth rate", default=1.0)
parser.add_argument("--final", type=int, help="Final pool size", default=50000)
parser.add_argument("--gens", type=int, default=20)
parser.add_argument("--initial", help="Prefix for initial data for pool (plink format)")
args = parser.parse_args()

if not (args.chromosomes or args.initial):
    print("One of --chromosomes or --initial required")
    exit(1)

if args.initial:
    pop = pyd.io.read_plink(prefix=args.initial)
    pool = ChromosomePool.from_population(pop)
else:
    chroms = [read_gs_chromosome_template(x) for x in args.chromosomes]
    pool = ChromosomePool(chromosomes=chroms, size=args.n0)
    print("Creating pool")
    pool.initialize_pool(args.n0)

gensize = lambda x: int(logistic_growth(pool.n0, args.rate, args.final, x))

for x in range(args.gens):
    print("Generation {}: {}".format(x, gensize(x)))
    pool.iterate_pool(gensize(x))
예제 #4
0
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
    
# Simulation method
if args.method.lower() == 'constrained':
    sim = ConstrainedMendelianSimulation(template, replications=args.replications)
elif args.method.lower() == 'genedrop':
    sim = NaiveGeneDroppingSimulation(template, replications=args.replications)

# Read effects file
예제 #5
0
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
    template.chromosomes[chrom].frequencies[idx] = 1-maf

# Simulation method
if args.method.lower() == 'constrained':
    sim = ConstrainedMendelianSimulation(template, 
        replications=args.replications)
elif args.method.lower() == 'genedrop':
    sim = NaiveGeneDroppingSimulation(template, replications=args.replications)
예제 #6
0
파일: sim_pool.py 프로젝트: y-chai/pydigree
from pydigree.population import logistic_growth

parser = argparse.ArgumentParser()
parser.add_argument('--chromosomes', dest='chromosomes',nargs='+', 
                    help='genomeSIMLA format chromosome templates')
parser.add_argument('--n0', dest='n0', type=int, help='Initial pool size', default=5000)
parser.add_argument('--rate', dest='rate', type=float, help='Growth rate', default=1.0)
parser.add_argument('--final', type=int, help='Final pool size', default=50000)
parser.add_argument('--gens', type=int, default=20)
parser.add_argument('--initial', help='Prefix for initial data for pool (plink format)')
args = parser.parse_args()

if not (args.chromosomes or args.initial):
	print('One of --chromosomes or --initial required')
	exit(1)

if args.initial:
	pop = pyd.io.read_plink(prefix=args.initial)
	pool = ChromosomePool.from_population(pop)
else:
	chroms = [read_gs_chromosome_template(x) for x in args.chromosomes]
	pool = ChromosomePool(chromosomes=chroms, size=args.n0)
	print('Creating pool')
	pool.initialize_pool(args.n0)

gensize = lambda x: int(logistic_growth(pool.n0, args.rate, args.final, x))

for x in range(args.gens):
    print('Generation {}: {}'.format(x, gensize(x)))
    pool.iterate_pool(gensize(x))
예제 #7
0
 def from_genomesimla(filename):
     return read_gs_chromosome_template(filename)