-
Notifications
You must be signed in to change notification settings - Fork 1
scripts/assign-colors updates for mpox #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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. | ||
| 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.") | ||
|
|
@@ -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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() | ||
|
|
@@ -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: | ||
|
|
@@ -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] | ||
|
|
||
There was a problem hiding this comment.
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.