print('Pearson Correlation between feature corr and blosum',
          pearsonr(corr_scores, blos_scores)[0])


if __name__ == "__main__":

    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument('exp_name', help='Name of experiment')
    args = parser.parse_args()

    min_total = 100
    filetype = 'pdf'

    cache_path = get_cache_path() / f'{args.exp_name}.pickle'
    args, feature_to_weighted_sums, weight_totals = pickle.load(
        open(cache_path, "rb"))
    print(args)
    print(weight_totals)

    report_dir = get_reports_path(
    ) / 'attention_analysis/blosum' / args.exp_name
    report_dir.mkdir(parents=True, exist_ok=True)

    create_figures(feature_to_weighted_sums, weight_totals, min_total,
                   report_dir, filetype)

    with open(report_dir / 'args.json', 'w') as f:
        json.dump(vars(args), f)
Beispiel #2
0
    print('Saving', fname)
    plt.savefig(fname, format=filetype)
    plt.close()


if __name__ == "__main__":

    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument('exp_name', help='Name of experiment')
    parser.add_argument('--min_total', type=int, default=100)
    args = parser.parse_args()

    use_bonferroni = True
    if use_bonferroni:
        print('Using bonferroni')
    min_total = args.min_total
    filetype = 'pdf'
    print(args.exp_name)
    cache_path = get_cache_path() / f'{args.exp_name}.pickle'
    report_dir = get_reports_path() / 'attention_analysis' / f'{args.exp_name}_topheads'
    pathlib.Path(report_dir).mkdir(parents=True, exist_ok=True)

    cache_args, feature_to_weighted_sum, weight_total = pickle.load(open(cache_path, "rb"))
    with open(report_dir / 'args.json', 'w') as f:
        json.dump(vars(cache_args), f)
    for feature_name, weighted_sum in feature_to_weighted_sum.items():
        create_figure(feature_name, weighted_sum, weight_total, report_dir, min_total=min_total, filetype=filetype,
                      use_bonferroni=use_bonferroni, max_seq_len=cache_args.max_seq_len)
Beispiel #3
0
    '1': 'Strand',
    '2': 'Turn/Bend'
}

if __name__ == "__main__":

    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument('exp_names', nargs='+', help='Names of experiments')
    args = parser.parse_args()

    min_total = 100
    filetype = 'pdf'

    report_dir = get_reports_path() / 'attention_analysis/edge_features_combined'
    pathlib.Path(report_dir).mkdir(parents=True, exist_ok=True)

    feature_data = []
    include_features = [contact_map_pattern, secondary_to_pattern, binding_site_pattern]
    for exp in args.exp_names:
        cache_path = get_cache_path() / f'{exp}.pickle'
        args, feature_to_weighted_sum, weight_total = pickle.load(open(cache_path, "rb"))
        with open(report_dir / f'args_{exp}.json', 'w') as f:
            json.dump(vars(args), f)
        for feature, weighted_sum in feature_to_weighted_sum.items():
            for p in include_features:
                m = p.match(feature)
                desc = None
                if m:
                    if p == contact_map_pattern:
Beispiel #4
0
                      'precision:', results['precision'], 'recall:',
                      results['recall'], 'precision at k:',
                      results['precision_at_k'])
                scores[num_layers - 1] = results['precision_at_k']
        except FileNotFoundError:
            print('Skipping', fname)
            continue
    feature_scores.append(scores)

    # Probing contact map results
    features.append('Contact Map')
    scores = [0] * 12
    for num_layers in list(range(1, 13)):
        fname = data_path / 'probing' / f'contact_map_{num_layers}/results.json'
        try:
            with open(fname) as infile:
                results = json.load(infile)
                print('contact maps', num_layers, 'f1:', results['f1'],
                      'precision:', results['precision'], 'recall:',
                      results['recall'], 'precision at k:',
                      results['precision_at_k'])
                scores[num_layers - 1] = results['precision_at_k']
        except FileNotFoundError:
            print('Skipping', fname)
            continue
    feature_scores.append(scores)

    report_dir = get_reports_path() / 'probing'
    pathlib.Path(report_dir).mkdir(parents=True, exist_ok=True)
    report(features, feature_scores, report_dir)