-
Notifications
You must be signed in to change notification settings - Fork 5
hivnetworkannotate
Steven Weaver edited this page Jan 28, 2023
·
2 revisions
This script takes the JSON file output by hivnetworkcsv and adds the data dictionary for subject attributes to create an annotated JSON suitable for rendering by hivtrace-viz (https://github.com/veg/hivtrace-viz)
Example command
python3 scripts/hivnetworkannotate -t examples/lanl.tsv -n examples/network.json -f "Country" "Country" "String" "x: 'N/A' f x=='-' else x" -f "Year" "Year" "Number" "x: 'N/A' if x=='-' else x" -f "RiskFactor" "Risk factor" "enum" '{"SG" : "homosexual", "SB" : "bisexual", "SM" : "male sex with male", "SH" : "heterosexual", "SW" : "sex worker", "SU" : "sexual transmission, unspecified type", "PH" : "hemophiliac", "PB" : "Blood transfusion", "PI" : "IV drug use", "MB" : "Mother-baby", "NO" : "Nosocomial", "EX" : "Experimental", "NR" : "not recorded (or unknown)", "OT" : "other", "-" : "N/A"}'
-o, --output: Output the annotated JSON network file to. If not specified, the output will be written to standard output.
-n, --network: The input network file to process. If not specified, the input will be read from standard input.
-x, --missing: If desired, provide a value to inject for nodes that do not have an attribute value specified
-X, --clear: Flush existing attributes
-i, --index: The name of the column that indexes records (patient ID); default is to index on the first column.
-r, --inplace: Write attributes to the input file (cannot be stdin)
-a, --attributes: The JSON file with node attributes
-t, --tab: A TSV file with node attributes
-c, --csv: A CSV file with node attributes
-f, --field: Describe an argument to be added to invididual nodes as "name" "label" "type" "transform"; currently supported types are "String", "enum", "Date", "Number"; transform must be specified as a lambda, an empty string to use an identity map, or a python style dict to specify an enum; "fulldate" is a predefined option to reformat the date using the default hivtrace-viz format
-g, --fields-file: Read in fields from a JSON file
Sergei L Kosakovsky Pond ([email protected])
v1.0.0 (2017-05-09) v1.1.0 (2017-09-04) : added support for 'enums', fixed bugs Note
This script requires the hivclustering library to be installed.