Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions scripts/assign-colors
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ if __name__ == '__main__':

parser.add_argument('--ordering', type=str, required=True,
help="""Input TSV file defining the color ordering where the first
column is the field and the second column is the trait in that field.
column is the category and the second column is the trait in that category.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[sidebar] I always struggle to name these things, especially when they have a value attached. Category / trait / value seems pretty good.

Blank lines are ignored. Lines starting with '#' will be ignored as comments.""")
parser.add_argument('--color-schemes', type=str, required=True,
help="Input color schemes where each line is a different color scheme separated by tabs.")
Expand All @@ -23,6 +23,16 @@ if __name__ == '__main__':
metadata. If the metadata includes a 'focal' column that only contains
boolean values, then restrict colors to traits for rows where 'focal'
is set to True.""")
parser.add_argument('--ignore-categories', type=str, default=[], nargs='*',
help="""Do not create colors for these categories even if they are
included in the metadata and ordering TSV. This is useful for ignoring
categories in specific builds even if they share the same default
ordering TSV.""")
Comment on lines +26 to +30
Copy link
Copy Markdown
Member

@jameshadfield jameshadfield Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[discussion] An alternative UI would be to have ordering TSVs for different categories and then allow multiple --ordering values. Thoughts? Do we plan on vendoring some big ordering list, or copy-paste across repos?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that there will be some overlap in ordering but not always. Even for division/location, the ordering may depend on where the pathogen is circulating? I'd think each pathogen would have it's own ordering TSV to support their own uses.

parser.add_argument('--force-include-categories', type=str, default=[],nargs='*',
help="""Force include all color orderings for these categories even if
there are traits not included in the metadata TSV. This is useful for
creating colorings for traits not (yet) present in metadata to solve
bootstrapping issue.""")
Comment on lines +31 to +35
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea what a "bootstrapping issue" is. I suspect this is a valid use-case, but perhaps adjust the argument help text?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I'm not 100% sure what the bootstrapping issue is either, I was just trying to support the changes added in mpox from nextstrain/mpox@f9221c0.

parser.add_argument('--output', type=str, required=True,
help="Output colors TSV file to be passed to augur export.")
args = parser.parse_args()
Expand All @@ -42,6 +52,8 @@ if __name__ == '__main__':
else:
name = array[0]
trait = array[1]
if name in args.ignore_categories:
continue
if name not in assignment:
assignment[name] = [trait]
else:
Expand All @@ -53,7 +65,7 @@ if __name__ == '__main__':
if args.metadata:
metadata = pd.read_csv(args.metadata, delimiter='\t')
for name, trait in assignment.items():
if name in metadata:
if name in metadata and name not in args.force_include_categories:
if 'focal' in metadata and metadata['focal'].dtype == 'bool':
focal_list = metadata.loc[metadata['focal'], name].unique()
subset_focal = [x for x in assignment[name] if x in focal_list]
Expand Down