Exemple #1
0
def measured_genotype_association(extrapredictor):
    model = MixedModel(peds,
                       outcome=args.outcome,
                       fixed_effects=args.fixefs + [extrapredictor])
    model.add_genetic_effect()
    model.fit_model()

    # Under the null (i.e. most loci in the genome) estimates of beta
    # for alleles should be close to zero most of the time. If they're
    # near zero, they're not explaining any of the variance in the
    # response variable, so variance component estimates shouldn't be
    # far from the null model. If we start with the null model's estimates
    # we can probably save an iteration or two of scoring (or probably like
    # a hundred iterations of expectation-maximization), and get to our
    # null result sooner. If we're not there, we'll move out to real estimate
    # anyway so it's essentially a free optimization.
    model.maximize(method=args.maxmethod,
                   starts=null_model.variance_components,
                   verbose=args.verbose,
                   restricted=False)
    return model
Exemple #2
0
def measured_genotype_association(extrapredictor):
    model = MixedModel(peds,
                       outcome=args.outcome,
                       fixed_effects=args.fixefs + [extrapredictor])
    model.add_genetic_effect()
    model.fit_model()

    # Under the null (i.e. most loci in the genome) estimates of beta
    # for alleles should be close to zero most of the time. If they're
    # near zero, they're not explaining any of the variance in the
    # response variable, so variance component estimates shouldn't be
    # far from the null model. If we start with the null model's estimates
    # we can probably save an iteration or two of scoring (or probably like
    # a hundred iterations of expectation-maximization), and get to our
    # null result sooner. If we're not there, we'll move out to real estimate
    # anyway so it's essentially a free optimization.
    model.maximize(method=args.maxmethod,
                   starts=null_model.variance_components,
                   verbose=args.verbose,
                   restricted=False)
    return model
Exemple #3
0
if args.only is not None:
    only = frozenset(args.only)

print('Reading pedigree')
peds = pyd.io.read_ped(args.ped)
print('Reading phenotypes')
pyd.io.read_phenotypes(peds, args.phen)
print('Reading genotypes')
genodata = pyd.io.plink.read_plink(pedfile=args.geno,
                                   mapfile=args.map)

peds.update(genodata)

print('Fitting polygenic model')
null_model = MixedModel(peds, outcome=args.outcome, fixed_effects=args.fixefs)
null_model.add_genetic_effect()
null_model.fit_model()
null_model.maximize(method=args.maxmethod,
                    verbose=args.verbose,
                    restricted=False)
null_model.summary()
llik_null = null_model.loglikelihood()


def parse_range(rangestr):
    chrom, span = rangestr.split(':')
    chrom = chrom.replace('chr', '')
    span = [int(x) for x in span.split('-')]
    return chrom, span[0], span[1]
Exemple #4
0
                    help='Enter IPython shell after maximization')
parser.add_argument('--d7', '--dominance', action='store_true', dest='d7',
                    help='Include dominance term in model')
parser.add_argument('--garbley', action='store_true',
                    help='Replace y values with random normal deviates')
parser.add_argument('--inflate', action='store_true')
parser.add_argument(
    '--center', action='store_true', help='Center outcome data')
args = parser.parse_args()


print('Reading files')
peds = pydigree.io.read_ped(args.pedf)
pydigree.io.read_phenotypes(peds, args.phenf)

m = MixedModel(peds, outcome=args.outcome, fixed_effects=args.fixefs)
print('Calculating Kinships')
m.add_genetic_effect()

if args.d7:
    m.add_genetic_effect(kind='dominance')

print('Done')
m.fit_model()

if args.center:
    m.y = m._centery()

if args.inflate:
    m.y *= 100
if args.garbley:
Exemple #5
0
if args.only is not None:
    only = frozenset(args.only)

print('Reading pedigree')
peds = pyd.io.read_ped(args.ped)
print('Reading phenotypes')
pyd.io.read_phenotypes(peds, args.phen)
print('Reading genotypes')
genodata = pyd.io.plink.read_plink(pedfile=args.geno,
                                   mapfile=args.map)

peds.update(genodata)

print('Fitting polygenic model')
null_model = MixedModel(peds, outcome=args.outcome, fixed_effects=args.fixefs)
null_model.add_genetic_effect()
null_model.fit_model()
null_model.maximize(method=args.maxmethod,
                    verbose=args.verbose,
                    restricted=False)
null_model.summary()
llik_null = null_model.loglikelihood()


def parse_range(rangestr):
    chrom, span = rangestr.split(':')
    chrom = chrom.replace('chr', '')
    span = [int(x) for x in span.split('-')]
    return chrom, span[0], span[1]
Exemple #6
0
                    nargs='*', default=None)
parser.add_argument('--interact', action='store_true',
                    help='Enter IPython shell after maximization')
parser.add_argument('--d7', '--dominance', action='store_true', dest='d7',
                    help='Include dominance term in model')
parser.add_argument('--garbley', action='store_true',
                    help='Replace y values with random normal deviates')
parser.add_argument('--inflate', action='store_true')
args = parser.parse_args()


print('Reading files')
peds = pydigree.io.read_ped(args.pedf)
pydigree.io.read_phenotypes(peds, args.phenf)

m = MixedModel(peds, outcome=args.outcome, fixed_effects=args.fixefs)
print('Calculating Kinships')
m.add_genetic_effect()

if args.d7:
    m.add_genetic_effect(kind='dominance')

print('Done')
m.fit_model()

if args.inflate:
    m.y *= 100
if args.garbley:
    m.y = np.matrix(np.random.normal(10, 5, len(m.y))).T

starts = args.starts