Skip to content

Commit

Permalink
[clade-i] ignore colors for certain categories
Browse files Browse the repository at this point in the history
We don't want an ordering for division & location in the clade-I builds
as these are constantly changing and we want to avoid auspice using
greys for demes
  • Loading branch information
jameshadfield committed Nov 3, 2024
1 parent 5a2fd3c commit b6b793c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions phylogenetic/defaults/clade-i/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ mask:
from_beginning: 800
from_end: 6422
maskfile: "defaults/mask.bed"

colors:
ignore_categories: "division location"
7 changes: 6 additions & 1 deletion phylogenetic/rules/export.smk
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,17 @@ rule colors:
metadata=build_dir + "/{build_name}/metadata.tsv",
output:
colors=build_dir + "/{build_name}/colors.tsv",
params:
ignore_categories=lambda w: config.get("colors", {}).get(
"ignore_categories", ""
),
shell:
"""
r"""
python3 scripts/assign-colors.py \
--ordering {input.ordering} \
--color-schemes {input.color_schemes} \
--output {output.colors} \
--ignore-categories {params.ignore_categories} \
--metadata {input.metadata} 2>&1
"""

Expand Down
4 changes: 4 additions & 0 deletions phylogenetic/scripts/assign-colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
parser.add_argument('--color-schemes', type=str, required=True, help="input color schemes file")
parser.add_argument('--metadata', type=str, help="if provided, restrict colors to only those found in metadata")
parser.add_argument('--output', type=str, required=True, help="output colors tsv")
parser.add_argument('--ignore-categories', type=str, required=False, nargs='*',
help="Do not create colors for these categories")
args = parser.parse_args()

assignment = {}
Expand All @@ -25,6 +27,8 @@
if len(array) == 2:
name = array[0]
trait = array[1]
if name in args.ignore_categories:
continue
if name not in assignment:
assignment[name] = [trait]
else:
Expand Down

0 comments on commit b6b793c

Please sign in to comment.