Ejemplo n.º 1
0
def test_init_tree_human_alpha_beta():
    import os
    import pandas as pd
    from tcrdist.repertoire import TCRrep
    from tcrdist.tree import TCRtree

    df = pd.read_csv("dash_human.csv").sample(10).reset_index(drop = True)
    tr = TCRrep(cell_df = df, 
                organism = 'human', 
                chains = ['alpha', 'beta'], 
                db_file = 'alphabeta_gammadelta_db.tsv')
    tcrtree = TCRtree(tcrrep = tr, html_name = 'dash.human.ab.tree.html')
    tcrtree.build_tree()
    assert os.path.isfile('dash.human.ab.tree.html')
Ejemplo n.º 2
0
def test_init_tree_beta():
    import os
    import pandas as pd
    from tcrdist.repertoire import TCRrep
    from tcrdist.tree import TCRtree

    df = pd.read_csv("dash.csv").sample(10).reset_index(drop = True)
    tr = TCRrep(cell_df = df, 
                organism = 'mouse', 
                chains = ['beta'], 
                db_file = 'alphabeta_gammadelta_db.tsv')
    tcrtree = TCRtree(tcrrep = tr, html_name = 'dash.mouse.b.tree.html')
    tcrtree.default_plot_hclust_props['tooltip_cols'].append('ref_size_olga_beta')
    tcrtree.default_plot_hclust_props['tooltip_cols'].append('ref_unique_olga_beta')
    tcrtree.default_plot_hclust_props['tooltip_cols'].append('percent_missing_olga_beta')
    tcrtree.build_tree()
    assert os.path.isfile('dash.mouse.b.tree.html')
Ejemplo n.º 3
0
def test_example_tree_args():
    import os
    import pandas as pd
    from tcrdist.repertoire import TCRrep
    from tcrdist.tree import TCRtree

    df = pd.read_csv("dash.csv").sample(100,
                                        random_state=1).reset_index(drop=True)

    tr = TCRrep(cell_df=df,
                organism='mouse',
                chains=['beta'],
                db_file='alphabeta_gammadelta_db.tsv')

    tcrtree = TCRtree(tcrrep=tr, html_name='dash.mouse.b.tree.html')

    tcrtree.default_hcluster_diff_kwargs = \
            {'clone_df': None,
             'pwmat': None,
             'x_cols': ['epitope'],
             'Z': None,
             'count_col': 'count',
             'subset_ind': None,
             'hclust_method': 'complete',
             'optimal_ordering': True,
             'test_method': 'fishers'}

    tcrtree.default_member_summ_kwargs = \
            {'key_col': 'neighbors_i',
            'count_col': 'count',
            'addl_cols': ['subject'],
            'addl_n': 1}

    tcrtree.default_plot_hclust_props = \
            {'title': '',
            'alpha_col': 'pvalue',
            'alpha': 0.05,
            'tooltip_cols': ['subject',
            'mean_dist',
            'pct_dist_75',
            'pct_dist_50',
            'pct_dist_25',
            'fuzzy_simpson_diversity_75',
            'fuzzy_simpson_diversity_50',
            'fuzzy_simpson_diversity_25',
            'cdr3_b_aa',
            'v_b_gene',
            'j_b_gene',
            'svg_beta',
            'svg_raw_beta',
            'ref_size_beta',
            'ref_unique_beta',
            'percent_missing_beta']}

    tcrtree.build_tree()
Ejemplo n.º 4
0
def test_example_tree():
    """
    An example showing how to create an interactive
    tree from a sample of mouse TCRs 
    """
    import os
    import pandas as pd
    from tcrdist.repertoire import TCRrep
    from tcrdist.tree import TCRtree

    df = pd.read_csv("dash.csv").sample(100,
                                        random_state=1).reset_index(drop=True)

    tr = TCRrep(cell_df=df,
                organism='mouse',
                chains=['beta'],
                db_file='alphabeta_gammadelta_db.tsv')

    tcrtree = TCRtree(tcrrep=tr, html_name='dash.mouse.b.tree.html')

    tcrtree.build_tree()

    assert os.path.isfile('dash.mouse.b.tree.html')
Ejemplo n.º 5
0
def test_example_tree_args():
    import os
    import pandas as pd
    from tcrdist.repertoire import TCRrep
    from tcrdist.tree import TCRtree

    df = pd.read_csv("dash.csv").sample(100, random_state=1).reset_index(drop = True)

    tr = TCRrep(cell_df = df, 
                organism = 'mouse', 
                chains = ['beta'], 
                db_file = 'alphabeta_gammadelta_db.tsv')

    tcrtree = TCRtree(tcrrep = tr, 
          html_name = 'dash.mouse.b.tree.html')

    tcrtree.default_hcluster_diff_kwargs['x_cols'] = ['epitope']

    tcrtree.default_member_summ_kwargs['addl_cols'] : ['subject', 'epitope']

    tcrtree.default_plot_hclust_props['alpha_col'] = 'pvalue'
    tcrtree.default_plot_hclust_props['alpha'] = 1.0

    tcrtree.build_tree()
Ejemplo n.º 6
0
                    count_col='count',
                    other_frequency_threshold=0.01)
IPython.display.SVG(data=svg)

svg = plot_pairings(cell_df=tra.clone_df,
                    cols=['v_a_gene', 'j_a_gene'],
                    count_col='count',
                    other_frequency_threshold=0.01)
IPython.display.SVG(data=svg)

#t = TCRsampler()
# t.download_background_file('ruggiero_mouse_sampler.zip')
#tcrsampler_beta = TCRsampler(default_background='ruggiero_mouse_beta_t.tsv.sampler.tsv')
#tcrsampler_alpha = TCRsampler(default_background='ruggiero_mouse_alpha_t.tsv.sampler.tsv')

tcrtree = TCRtree(tcrrep=tra,
                  html_name=opj(proj_folder, 'Gil_alpha_hierdiff.html'))
tcrtree.default_hcluster_diff_kwargs['x_cols'] = ['cohort']
tcrtree.default_plot_hclust_props['alpha'] = 0.05
tcrtree.default_plot_hclust_props['tooltip_cols'].append('ref_size_olga_alpha')
tcrtree.default_plot_hclust_props['tooltip_cols'].append(
    'ref_unique_olga_alpha')
tcrtree.default_plot_hclust_props['tooltip_cols'].append(
    'percent_missing_olga_alpha')
tcrtree.build_tree()

tcrtree = TCRtree(tcrrep=trb,
                  html_name=opj(proj_folder, 'Gil_beta_hierdiff.html'))
tcrtree.default_hcluster_diff_kwargs['x_cols'] = ['cohort']
tcrtree.default_plot_hclust_props['alpha'] = 0.05
tcrtree.default_plot_hclust_props['tooltip_cols'].append('ref_size_olga_beta')
tcrtree.default_plot_hclust_props['tooltip_cols'].append(