-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds rules, scripts, and config to produce joint t-SNE embeddings per build from all gene segments and find clusters from the resulting embeddings. When the user defines the `embedding` key in their build config, the workflow produces pairwise distances per gene segment, runs t-SNE on those distances, finds clusters with HDBSCAN, and exports the embedding coordinates and clusters in the Auspice JSON.
- Loading branch information
Showing
8 changed files
with
231 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env python3 | ||
import argparse | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) | ||
parser.add_argument("--items", nargs="+", required=True, help="one or more files containing a list of items") | ||
parser.add_argument("--output", required=True, help="list of items shared by all input files (the intersection)") | ||
|
||
args = parser.parse_args() | ||
|
||
with open(args.items[0], "r", encoding="utf-8") as fh: | ||
shared_items = {line.strip() for line in fh} | ||
|
||
for item_file in args.items[1:]: | ||
with open(item_file, "r", encoding="utf-8") as fh: | ||
items = {line.strip() for line in fh} | ||
|
||
shared_items = shared_items & items | ||
|
||
with open(args.output, "w", encoding="utf-8") as oh: | ||
for item in sorted(shared_items): | ||
print(item, file=oh) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""Create Augur-compatible node data JSON from a pandas data frame. | ||
""" | ||
import argparse | ||
import pandas as pd | ||
from augur.utils import write_json | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("--table", help="table to convert to a node data JSON") | ||
parser.add_argument("--index-column", default="strain", help="name of the column to use as an index") | ||
parser.add_argument("--delimiter", default=",", help="separator between columns in the given table") | ||
parser.add_argument("--node-name", default="nodes", help="name of the node data attribute in the JSON output") | ||
parser.add_argument("--output", help="node data JSON file") | ||
|
||
args = parser.parse_args() | ||
|
||
if args.output is not None: | ||
table = pd.read_csv( | ||
args.table, | ||
sep=args.delimiter, | ||
index_col=args.index_column, | ||
dtype=str, | ||
) | ||
|
||
# # Convert columns that aren't strain names or labels to floats. | ||
# for column in table.columns: | ||
# if column != "strain" and not "label" in column: | ||
# table[column] = table[column].astype(float) | ||
|
||
table_dict = table.transpose().to_dict() | ||
write_json({args.node_name: table_dict}, args.output) |