Esempio n. 1
0
def findRelated(bed, outFile, cutoff, kinshipFile=None):

    bed = leapUtils._fixupBed(bed)

    keepArr = leapUtils.findRelated(bed, cutoff, kinshipFile)
    if (outFile is not None):
        print 'Printing output to', outFile
        f = open(outFile, 'w')
        for i, (fid, iid) in enumerate(bed.iid):
            if (keepArr[i]): f.write(fid + ' ' + iid + ' 0\n')
            else: f.write(fid + ' ' + iid + ' 1\n')
        f.close()
    return keepArr
Esempio n. 2
0
def findRelated(bed, outFile, cutoff, kinshipFile=None):

	bed = leapUtils._fixupBed(bed)
	
	keepArr = leapUtils.findRelated(bed, cutoff, kinshipFile)
	if (outFile is not None):
		print 'Printing output to', outFile
		f = open(outFile, 'w')
		for i, (fid,iid) in enumerate(bed.iid):
			if (keepArr[i]): f.write(fid + ' ' + iid + ' 0\n')
			else: f.write(fid + ' ' + iid + ' 1\n')
		f.close()
	return keepArr
Esempio n. 3
0
def eigenDecompose(bed, outFile=None):

	bed = leapUtils._fixupBed(bed)

	#Compute kinship matrix
	t0 = time.time()
	print 'Computing kinship matrix...'	
	XXT = leapUtils.symmetrize(blas.dsyrk(1.0, bed.val, lower=1)) / bed.val.shape[1]
	print 'Done in %0.2f'%(time.time()-t0), 'seconds'

	#Compute eigendecomposition
	S,U = leapUtils.eigenDecompose(XXT)
	if (outFile is not None): np.savez_compressed(outFile, arr_0=U, arr_1=S, XXT=XXT)	
	eigen = dict([])
	eigen['XXT'] = XXT
	eigen['arr_0'] = U
	eigen['arr_1'] = S
	return eigen
Esempio n. 4
0
def eigenDecompose(bed, outFile):

    bed = leapUtils._fixupBed(bed)

    # Compute kinship matrix
    t0 = time.time()
    print "Computing kinship matrix..."
    XXT = leapUtils.symmetrize(blas.dsyrk(1.0, bed.val, lower=1)) / bed.val.shape[1]
    print "Done in %0.2f" % (time.time() - t0), "seconds"

    # Compute eigendecomposition
    S, U = leapUtils.eigenDecompose(XXT)
    if outFile is not None:
        np.savez_compressed(outFile, arr_0=U, arr_1=S, XXT=XXT)
    eigen = dict([])
    eigen["XXT"] = XXT
    eigen["arr_0"] = U
    eigen["arr_1"] = S
    return eigen
Esempio n. 5
0
def eigenDecompose(bed, outFile=None):

    bed = leapUtils._fixupBed(bed)

    #Compute kinship matrix
    t0 = time.time()
    print 'Computing kinship matrix...'
    XXT = leapUtils.symmetrize(blas.dsyrk(1.0, bed.val,
                                          lower=1)) / bed.val.shape[1]
    print 'Done in %0.2f' % (time.time() - t0), 'seconds'

    #Compute eigendecomposition
    S, U = leapUtils.eigenDecompose(XXT)
    if (outFile is not None):
        np.savez_compressed(outFile, arr_0=U, arr_1=S, XXT=XXT)
    eigen = dict([])
    eigen['XXT'] = XXT
    eigen['arr_0'] = U
    eigen['arr_1'] = S
    return eigen