Skip to content

Commit

Permalink
removing text from columns optionally with --remove-site-text
Browse files Browse the repository at this point in the history
  • Loading branch information
aineniamh committed Apr 12, 2024
1 parent b04f51e commit 8823898
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion snipit/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def main(sysargs = sys.argv[1:]):
f_group.add_argument("--high-to-low", action='store_false',
help="If sorted by mutation number is selected, show the sequences with the fewest SNPs closest to the reference. Default: False",
dest="high_to_low")
f_group.add_argument("--remove-site-text",action='store_true',help="Do not annotate text on the individual columns in the figure.",dest="remove_site_text")

s_group = parser.add_argument_group('SNP options')
s_group.add_argument("--show-indels",action='store_true',help="Include insertion and deletion mutations in snipit plot.",dest="show_indels")
Expand Down Expand Up @@ -128,10 +129,11 @@ def main(sysargs = sys.argv[1:]):
args.height,
args.size_option,
args.solid_background,
args.remove_site_text,
args.ambig_mode,
args.flip_vertical,
args.included_positions,
args.excluded_positions,
args.ambig_mode,
args.sort_by_mutation_number,
args.high_to_low,
args.sort_by_id,
Expand Down
13 changes: 8 additions & 5 deletions snipit/scripts/snp_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,7 @@ def make_graph(num_seqs,
height,
size_option,
solid_background,
remove_site_text,
ambig_mode,
flip_vertical=False,
included_positions=None,
Expand Down Expand Up @@ -543,7 +544,7 @@ def make_graph(num_seqs,
fig, ax = plt.subplots(1,1, figsize=(width,height), dpi=250)

y_level = 0

print(remove_site_text)
for record in record_order:

# y position increments, with a gap after the two recombi_refs
Expand All @@ -570,7 +571,8 @@ def make_graph(num_seqs,

# write text adjacent to the SNPs shown with the numeric position
# the text alignment is toggled right/left (top/bottom considering 90-deg rotation) if the plot is flipped
ax.text(position, y_level+(0.55*y_inc), snp, size=9, ha="center", va="bottom" if not flip_vertical else "top", rotation=90)
if not remove_site_text:
ax.text(position, y_level+(0.55*y_inc), snp, size=9, ha="center", va="bottom" if not flip_vertical else "top", rotation=90)

# snp position labels
left_of_box = position-(0.4*spacing)
Expand All @@ -594,11 +596,12 @@ def make_graph(num_seqs,
ax.add_patch(rect)

# sequence variant text
ax.text(position, y_pos*y_inc, var, size=9, ha="center", va="center")
if not remove_site_text:
ax.text(position, y_pos*y_inc, var, size=9, ha="center", va="center")

# reference variant text

ax.text(position, y_inc * -0.2, ref, size=9, ha="center", va="center")
if not remove_site_text:
ax.text(position, y_inc * -0.2, ref, size=9, ha="center", va="center")

#polygon showing mapping from genome to spaced out snps
x = [snp-0.5,snp+0.5,right_of_box,left_of_box,snp-0.5]
Expand Down

0 comments on commit 8823898

Please sign in to comment.