コード例 #1
0
def main():
    parser = argparse.ArgumentParser(
        description='LOL HI THERE',
        formatter_class=argparse.ArgumentDefaultsHelpFormatter)
    parser.add_argument('--use-supervars', action='store_true')
    # This takes Pairtree rather than PWGS inputs, which seems a little weird,
    # but it's okay -- the PWGS inputs are the supervariants, but we need to know
    # which variants correspond to each cluster in the original Pairtree inputs.
    parser.add_argument('tree_summary', help='JSON-formatted tree summaries')
    parser.add_argument('mutation_list',
                        help='JSON-formatted list of mutations')
    parser.add_argument(
        'mutation_assignment',
        help='JSON-formatted list of SSMs and CNVs assigned to each subclone')
    parser.add_argument('pairtree_params_fn')
    parser.add_argument('neutree_fn')
    args = parser.parse_args()

    results = ResultLoader(args.tree_summary, args.mutation_list,
                           args.mutation_assignment)
    if args.use_supervars:
        params = inputparser.load_params(args.pairtree_params_fn)
        base_clusters = params['clusters']
        garbage = params['garbage']
    else:
        base_clusters = None
        garbage = []

    ntree = convert_results(results, base_clusters, garbage,
                            args.use_supervars)
    neutree.save(ntree, args.neutree_fn)
コード例 #2
0
ファイル: convert_outputs.py プロジェクト: xtmgah/pairtree
def main():
  parser = argparse.ArgumentParser(
    description='LOL HI THERE',
    formatter_class=argparse.ArgumentDefaultsHelpFormatter
  )
  parser.add_argument('pairtree_results_fn')
  parser.add_argument('params_fn')
  parser.add_argument('neutree_fn')
  args = parser.parse_args()

  results = resultserializer.Results(args.pairtree_results_fn)
  params = inputparser.load_params(args.params_fn)
  ntree = convert(results, params['garbage'])
  neutree.save(ntree, args.neutree_fn)
コード例 #3
0
ファイル: convert_outputs.py プロジェクト: xtmgah/pairtree
def write_neutree(results, garbage, neutree_fn):
    adjms = [R['adjm'] for R in results]
    structs = [util.convert_adjmatrix_to_parents(A) for A in adjms]
    llhs = [R['llh'] for R in results]
    clusterings = [R['clusters'] for R in results]
    phis = [R['phi'] for R in results]
    N = len(structs)
    counts = np.ones(N)
    ntree = neutree.Neutree(
        structs=structs,
        phis=phis,
        counts=counts,
        logscores=llhs,
        clusterings=clusterings,
        garbage=garbage,
    )
    neutree.save(ntree, neutree_fn)
コード例 #4
0
ファイル: convert_outputs.py プロジェクト: xtmgah/pairtree
def convert(sampid, params_fn, trees_fn, neutree_fn):
    adjms, llhs, phis, clusterings = pastri_util.load_results(
        sampid, params_fn, trees_fn)
    if len(adjms) == 0:
        return
    structs = [util.convert_adjmatrix_to_parents(A) for A in adjms]
    N = len(structs)
    params = inputparser.load_params(params_fn)
    ntree = neutree.Neutree(
        structs=structs,
        phis=phis,
        counts=np.ones(N),
        logscores=llhs,
        clusterings=clusterings,
        garbage=params['garbage'],
    )
    neutree.save(ntree, neutree_fn)
コード例 #5
0
def convert(params_fn, calder_mats_fn, calder_trees_fn, neutree_fn):
    params = inputparser.load_params(params_fn)

    mats, row_labels, col_labels = _load_mats(calder_mats_fn)
    assert row_labels['Fhat'][0] == 'samples'
    svids = row_labels['Fhat'][1:]
    assert svids == common.sort_vids(svids)

    struct = _load_struct(svids, calder_trees_fn)
    ntree = neutree.Neutree(
        structs=[struct],
        phis=[mats['Fhat']],
        counts=np.array([1]),
        logscores=np.array([0.]),
        clusterings=[params['clusters']],
        garbage=params['garbage'],
    )
    neutree.save(ntree, neutree_fn)