kmayerb / tcrdist3

flexible CDR based distance metrics
MIT License
53 stars 17 forks source link

build_tree not working with gd TCRs #88

Closed sschattgen closed 1 year ago

sschattgen commented 1 year ago

Hi Koshlan,

I'm trying to build trees using human gd TCRs and I'm encountering the following issue. I believe it is related to being gd data since I can use it with ab ok. Thoughts?

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

tcrtree = TCRtree(tcrrep = tr, 
                  html_name = 'BM_gdTCR_ALL.html')

tcrtree.build_tree()
['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_g_aa', 'v_g_gene', 'j_g_gene', 'svg_gamma', 'svg_raw_gamma', 'ref_size_gamma', 'ref_unique_gamma', 'percent_missing_gamma']
---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
Untitled-6 in <module>
     <a href='untitled:Untitled-6?line=37'>38</a>                   html_name = 'BM_gdTCR_ALL_gamma.html')
     <a href='untitled:Untitled-6?line=38'>39</a> 
---> <a href='untitled:Untitled-6?line=39'>40</a> tcrtree.build_tree()

c:\ProgramData\Anaconda3\envs\tcrdist3\lib\site-packages\tcrdist\tree.py in build_tree(self)
    124 
    125         print(self.default_plot_hclust_props['tooltip_cols'])
--> 126         _auto_hdiff2(   tcrrep                       = self.tcrrep,
    127                         html_name                    = self.html_name,
    128                         pwmat_str_b                  = self.pwmat_str_b,

c:\ProgramData\Anaconda3\envs\tcrdist3\lib\site-packages\tcrdist\tree.py in _auto_hdiff2(tcrrep, html_name, pwmat_str_b, pwmat_str_a, single, generate_svgs, combine_olga, verbose, prune, default_hcluster_diff_kwargs, default_member_summ_kwargs, default_plot_hclust_props)
    354 
    355     if default_hcluster_diff_kwargs['pwmat'] is None:
--> 356         if verbose : print(f"pwmat set with {pwmat_str}")
    357         default_hcluster_diff_kwargs['pwmat'] = getattr(tcrrep, pwmat_str)
    358     else:

UnboundLocalError: local variable 'pwmat_str' referenced before assignment
kmayerb commented 1 year ago

Currently TCRtree only works with alpha/beta TCRs