Skip to content

Commit

Permalink
add meta_info_to_emphasize to lb scatter plots
Browse files Browse the repository at this point in the history
  • Loading branch information
psathyrella committed Feb 24, 2024
1 parent f09698a commit 971c326
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions python/lbplotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def get_tree_in_line(line, is_true_line, aa=False): # NOTE unlike treeutils.get
# ----------------------------------------------------------------------------------------
# NOTE that this isn't symmetric wrt x/y vars -- some combos require one var to be x, and the other y (otherwise it'll crash cause it can't figure out how to calculate the values)
def make_lb_scatter_plots(xvar, baseplotdir, lb_metric, lines_to_use, fnames=None, is_true_line=False, colorvar=None, only_overall=False, only_iclust=False, add_uids=False, yvar=None, choose_among_families=False,
add_jitter=False, min_ptile=80., n_iclust_plot_fnames=None, use_relative_affy=False, queries_to_include=None, add_stats=None, xlabel=None, ylabel=None, title_str=''): # <is_true_line> is there because we want the true and inferred lines to keep their trees in different places, because the true line just has the one, true, tree, while the inferred line could have a number of them (yes, this means I maybe should have called it the 'true-tree' or something)
add_jitter=False, min_ptile=80., n_iclust_plot_fnames=None, use_relative_affy=False, queries_to_include=None, meta_info_to_emphasize=None, meta_emph_formats=None, add_stats=None, xlabel=None, ylabel=None, title_str=''): # <is_true_line> is there because we want the true and inferred lines to keep their trees in different places, because the true line just has the one, true, tree, while the inferred line could have a number of them (yes, this means I maybe should have called it the 'true-tree' or something)
# ----------------------------------------------------------------------------------------
def add_warn(tstr, targs):
if 'warn_text' in targs:
Expand All @@ -452,6 +452,9 @@ def add_warn(tstr, targs):
return
if queries_to_include is not None:
add_uids = True
if meta_info_to_emphasize is not None:
add_uids = True
meta_emph_key, meta_emph_val = list(meta_info_to_emphasize.items())[0]
cdist_pt_keys = [s+'-ptile' for s in cdist_keys]
if yvar is None:
yvar = lb_metric
Expand Down Expand Up @@ -578,7 +581,14 @@ def yvalfcn(i): return cdist_ptiles[line['unique_ids'][i]]
assert False
iclust_plotvals[colorvar].append(colorval) # I think any uid in <line> should be in the tree, but may as well handle the case where it isn't
if add_uids:
iclust_plotvals['uids'].append(uid if queries_to_include is None or uid in queries_to_include else None) # use to add None here instead of <uid> if this node didn't have an affinity value, but that seems unnecessary, I can worry about uid config options later when I actually use the uid dots for something
if meta_info_to_emphasize is None:
iclust_plotvals['uids'].append(uid if queries_to_include is None or uid in queries_to_include else None) # use to add None here instead of <uid> if this node didn't have an affinity value, but that seems unnecessary, I can worry about uid config options later when I actually use the uid dots for something
else:
# estr = utils.meta_emph_str(meta_emph_key, meta_emph_val, formats=meta_emph_formats) # use this if you want the emph value to show up, but for now i like having the uid
uval = None
if utils.meta_info_equal(meta_emph_key, meta_emph_val, utils.antnval(line, meta_emph_key, iseq), formats=meta_emph_formats):
uval = utils.antnval(line, 'alternate-uids', iseq, use_default=True, default_val=uid)
iclust_plotvals['uids'].append(uval)
if len(iclust_plotvals[xvar]) == 0:
continue
iskargs = copy.deepcopy(scatter_kwargs)
Expand Down
2 changes: 1 addition & 1 deletion python/treeutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2243,7 +2243,7 @@ def plot_tree_metrics(args, plotdir, metrics_to_calc, antn_list, is_simu=False,
if not args.only_csv_plots: # all the various scatter plots are really slow
if 'lb-scatter' in plot_cfg:
for xv, yv in [(xv, yv) for xv, yv in [('cons-dist-aa', 'aa-lbi'), ('aa-lbi', 'lbi')] if xv in metrics_to_calc and yv in metrics_to_calc]:
lbplotting.make_lb_scatter_plots(xv, plotdir, yv, antn_list, fnames=fnames, is_true_line=is_simu, colorvar='affinity' if has_affinities and 'cons-dist' in xv else None, add_jitter='cons-dist' in xv, n_iclust_plot_fnames=None if has_affinities else 8, queries_to_include=args.queries_to_include) #, add_stats='correlation')
lbplotting.make_lb_scatter_plots(xv, plotdir, yv, antn_list, fnames=fnames, is_true_line=is_simu, colorvar='affinity' if has_affinities and 'cons-dist' in xv else None, add_jitter='cons-dist' in xv, n_iclust_plot_fnames=None if has_affinities else 8, queries_to_include=args.queries_to_include, meta_info_to_emphasize=args.meta_info_to_emphasize, meta_emph_formats=args.meta_emph_formats) #, add_stats='correlation')
if ete_path is not None and has_trees and 'tree' in plot_cfg:
lbplotting.plot_lb_trees(args, metrics_to_calc, plotdir, antn_list, ete_path, workdir, is_true_line=is_simu, fnames=fnames)
subdirs = [d for d in os.listdir(plotdir) if os.path.isdir(plotdir + '/' + d)]
Expand Down
2 changes: 1 addition & 1 deletion python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1497,7 +1497,7 @@ def getseq(sfo): # could use recursive .get(, .get()), but i just feel like mak

if print_added_str:
print(' added %d %s seqs to line (originally with %d)%s' % (len(seqfos_to_add), print_added_str, original_len, '' if len(seqfos_to_add)>16 else ': %s' % ' '.join(s['name'] for s in seqfos_to_add)))
if debug:
if debug and not line.get('is_fake_paired', False):
print_reco_event(line, label='after adding %d seq%s:'%(len(aligned_seqfos), plural(len(aligned_seqfos))), extra_str=' ', queries_to_emphasize=[s['name'] for s in aligned_seqfos])

# ----------------------------------------------------------------------------------------
Expand Down

0 comments on commit 971c326

Please sign in to comment.