Ejemplo n.º 1
0
def Run(counts_file, n, **kwargs):
    '''
    Compute the pairwise distance matrix between all sites and write it out as txt file.
    '''
    ## read counts data
    temp = SM()
    counts = temp.from_file(counts_file)
    ## make simulated data
    format = kwargs.get('format', 'txt')
    out_file = kwargs.get('out_file', counts_file + '_sim_')
    counts.sim_data(n, method='permute', base_file=out_file, format=format)
    print 'wrote ' + out_file + '_[1...%d].txt' % n
    print 'Done!'
Ejemplo n.º 2
0
def Run(counts_file, n, **kwargs):
    '''
    Compute the pairwise distance matrix between all sites and write it out as txt file.
    '''
    ## read counts data
    temp   = SM()
    counts = temp.from_file(counts_file)
    ## make simulated data
    format   = kwargs.get('format','txt')
    out_file = kwargs.get('out_file', counts_file + '_sim_')
    counts.sim_data(n, method = 'permute', base_file = out_file, format = format)    
    print 'wrote ' + out_file + '_[1...%d].txt' %n
    print 'Done!'
Ejemplo n.º 3
0
def Run(counts_file, metric='JSsqrt', **kwargs):
    '''
    Compute the pairwise distance matrix between all sites and write it out as txt file.
    '''
    ## read counts data
    temp = SM()
    counts = temp.from_file(counts_file)
    ## compute sample distances
    fracs = counts.to_fractions('normalize')
    D = fracs.dist_mat(metric=metric)
    ## write distance matrix
    out_file = kwargs.get('out_file', 'sample_dist_' + metric + '.out')
    D.writetxt(out_file)
    print('wrote ' + out_file)
    print('Done!')
Ejemplo n.º 4
0
def Run(counts_file, metric = 'JSsqrt', **kwargs):
    '''
    Compute the pairwise distance matrix between all sites and write it out as txt file.
    '''
    ## read counts data
    temp   = SM()
    counts = temp.from_file(counts_file)
    ## compute sample distances
    fracs = counts.to_fractions('normalize')
    D     = fracs.dist_mat(metric = metric)
    ## write distance matrix
    out_file = kwargs.get('out_file', 'sample_dist_' + metric +'.out')
    D.writetxt(out_file)    
    print 'wrote ' + out_file
    print 'Done!'
Ejemplo n.º 5
0
def RunSparCC(counts_file, algo='SparCC', **kwargs):
    ## read counts data
    print 'reading data'
    temp = SM()
    counts = temp.from_file(counts_file)

    ## Calculate correlations between components using SparCC
    print 'computing correlations'
    cor, cov = counts.basis_corr(algo=algo, **kwargs)

    ## write out results
    print 'writing results'
    cor_file = kwargs.get('cor_file', 'cor_mat_' + algo + '.out')
    cor.writetxt(cor_file)
    print 'wrote ' + cor_file
    if cov is not None:
        cov_file = kwargs.get('cov_file', 'cov_mat_' + algo + '.out')
        cov.writetxt(cov_file)
        print 'wrote ' + cov_file

    print 'Done!'
Ejemplo n.º 6
0
def RunSparCC(counts_file, algo='SparCC', **kwargs):
    ## read counts data
    print 'reading data'
    temp   = SM()
    counts = temp.from_file(counts_file)
    
    ## Calculate correlations between components using SparCC
    print 'computing correlations'
    cor, cov = counts.basis_corr(algo=algo , **kwargs)
    
    ## write out results
    print 'writing results'
    cor_file = kwargs.get('cor_file', 'cor_mat_' + algo + '.out')
    cor.writetxt(cor_file)
    print 'wrote ' + cor_file
    if cov is not None:
        cov_file = kwargs.get('cov_file', 'cov_mat_' + algo + '.out')
        cov.writetxt(cov_file)
        print 'wrote ' + cov_file
    
    print 'Done!'
Ejemplo n.º 7
0
def RunSparCC(counts_file, algo="SparCC", **kwargs):
    ## read counts data
    print "reading data"
    temp = SM()
    counts = temp.from_file(counts_file)

    ## Calculate correlations between components using SparCC
    print "computing correlations"
    cor, cov = counts.basis_corr(algo=algo, **kwargs)

    ## write out results
    print "writing results"
    cor_file = kwargs.get("cor_file", "cor_mat_" + algo + ".out")
    cor.writetxt(cor_file)
    print "wrote " + cor_file
    if cov is not None:
        cov_file = kwargs.get("cov_file", "cov_mat_" + algo + ".out")
        cov.writetxt(cov_file)
        print "wrote " + cov_file

    print "Done!"