ChemSpace.js
In this section ChemSpace.js methods, events and attributes are documented. Attributes influence various parameters of the visualization. The only obligatory attribute is the target attribute which defines the ID of the HTML target element.
Attributes
{ "target" : "YourOwnDivId", //the ID of the target element "height" : 800, // the height of visualization "width" : target_width, // the width of visualization (default is the width of target element) "font": "Helvetica", // font "label_color": "gray", // the background color of icons label "shapes": { // default color and radius of points, the width of stroke "order": ["circle", "triangle", "square", "hexagon", "rhombus"], "default": { "radius": 4, "strokeWidth": 1, "fill": "#C2C2C2", "stroke": null, }, }, "path": { // default color and radius of points, the width of stroke "strokeWidth": 1, "stroke": 'gray', }, "links": { // default color and radius of points, the width of stroke "draw": true, "attrs": { "strokeWidth": 2, "stroke": '#666666', } }, "color": { // color scale settings "scale": "RdLrGr", // color scale "value_type": "percentile", // color by percentile/value "index": 2, // feature index/category "params": {"min": 0, "max": 100, "middle": 50} }, "point_size": { // color scale settings "scale": {"min": 2, "middle": 4, "max": 6}, "value_type": "percentile", // color by percentile/value "index": 3, // feature index/category "params": {"min": 0, "max": 100, "middle": 50} }, "coordinates": { // coordinates, x, y feature indexes "x": 0, "y": 1, }, "highlight_color": "black", // color used to highlight points through the highlight_points method "navigation_toggle": { // show/hide navigation elements "axis_labels": true, "axis": true, "diagonal": true, "export_button": true, "color_scale": true, "point_size": true }, "align_to_grid": false, // align points/molecules to grid "compounds": { // compound settings compound_url: null, // url on server to fetch molecules (optional) format: "chemspace", draw: true, // whether to draw compounds limit: 50, // maximum limit of drawn compounds size: 200, // default size of molecules tooltip_compound_size: 200, // size of compound in the tooltip smilesDrawer: { // smilesDrawer settings bondThickness: 1, fontSizeLarge: 7, fontSizeSmall: 4, } }, "categories": {"order": false}, // categories order "resolution": 1, // resolution of chemical space (the division of chemical space canvas on squares with a given size in pixels) "colors": ["#d62728", "#2ca02c", "#1f77b4", "#ff7f0e", "#aec7e8", "#ffbb78", "#98df8a", "#ff9896", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf", "#c5b0d5", "#c49c94", "#f7b6d2", "#c7c7c7", "#dbdb8d", "#9edae5"] // default colors }
Methods
read_data_from_file("path/to/file.json"); read_data(json); read_data_from_file(/path/to/json/file); draw(); redraw(); redraw_points([point_id, point_id, ...]); add_path({"label": "label", "color": "color", "points":[point_id, point_id ...]}); add_category(category); update_category(category, action); remove_category(category_name); add_feature(feature); remove_feature(feature_name); update_settings(settings); highlight_points(point_ids, color); unhighlight_points();
Events
/** * @name ChemSpace#point_click * @event * @param {function} function() callback function for click on a single point event * @eventData {string} string point ID * @eventData {object} event event object * @example * instance.events.point_click = ( * function(point_id, evt) { * alert(point_id); * } * ); * */ "point_click": function(point_id, evt){ return; }, /** * @name ChemSpace#path_click * @event * @param {function} function() callback function for click on a path event * @eventData {object} object path object representation * @eventData {object} event event object * @example * instance.events.path_click = ( * function(path, evt) { * alert(path); * } * ); * */ "path_click": function(path, evt){ return; }, /** * @name ChemSpace#link_click * @event * @param {function} function() callback function for click on a link event * @eventData {object} object point ids linked by the link * @eventData {object} event event object * @example * instance.events.link_click = ( * function(point_ids, evt) { * alert(point_ids); * } * ); * */ "link_click": function(point_ids, evt){ return; }, /** * @name ChemSpace#points_selection * @event * @param {function} function() callback function for selection of points event * @eventData {array} array array of point IDs * @eventData {object} event event object * @example * instance.events.points_selection = ( * function(point_ids) { * alert(point_ids); * } * ); * */ "points_selection": function(point_ids){ return; }, /** * @name ChemSpace#category_legend_click * @event * @param {function} function() callback function for click on a category legend event * @eventData {object} object category object representation * @eventData {object} event event object * @example * instance.events.category_legend_click = ( * function(category_object, evt) { * alert(category_object); * } * ); * */ "category_legend_click": function(category_object, evt){ return; }, /** * @name ChemSpace#refresh * @event * @param {function} function() callback function for click on a refresh icon * @eventData {array} point ids * @eventData {object} event event object * @example * instance.events.refresh = ( * function(ids, evt) { * alert(ids.length); * } * ); * */ "refresh": function(category_object, evt){ return; }, /** * @name ChemSpace#point_tooltip * @event * @param {function} function() callback function for point tooltip customization * @eventData {object} event event object * @example * instance.events.point_tooltip = ( * function(evt) { * alert(evt); * } * ); * */ "point_tooltip": function(point_id, color, evt){ return self._get_point_tooltip(evt); },

chemspace.py
usage: chemspace_backup.py [-h] [-dh] [-dd DATA_DELIMITER] [-o OUTPUT_FILE] [-fpf FINGERPRINT_FIELD] [-cf CATEGORY_FIELD] [-cfd CATEGORY_FIELD_DELIMITER] [-lf LABEL_FIELD] [-af ACTIVITY_FIELD] [-csf COMPOUND_STRUCTURE_FIELD] [-fp FINGERPRINT] [-arr ARRANGE_BY] [-cst COMPOUND_SIMILARITY_THRESHOLD] [-drm DIMENSIONAL_REDUCTION_METHOD [DIMENSIONAL_REDUCTION_METHOD ...]] [-dws] [-min] [-html HTML_DIR] [-pcp] [-edges] [-n] [-mv MISSING_VALUES] [-k KNN] [-sm SIMILARITY_METRIC] [-rmc REMOVE_COLUMNS [REMOVE_COLUMNS ...]] data_file positional arguments: data_file csv(text) data file with delimited values or a sdf file optional arguments: -h, --help show this help message and exit -dh, --data_header whether the first row of data file is a header (default: False) -dd DATA_DELIMITER, --data_delimiter DATA_DELIMITER delimiter of values in data file (default: ,) -o OUTPUT_FILE, --output_file OUTPUT_FILE the name of output file (default: None) -fpf FINGERPRINT_FIELD, --fingerprint_field FINGERPRINT_FIELD set a fingerprint field name in case it is in the data file (default: False) -cf CATEGORY_FIELD, --category_field CATEGORY_FIELD set a category field name in case it is in the data file (default: False) -cfd CATEGORY_FIELD_DELIMITER, --category_field_delimiter CATEGORY_FIELD_DELIMITER a category field delimiter (default: False) -lf LABEL_FIELD, --label_field LABEL_FIELD set a label field name in case it is in the data file (default: False) -af ACTIVITY_FIELD, --activity_field ACTIVITY_FIELD set an activity field name in case it is in the data file (default: False) -csf COMPOUND_STRUCTURE_FIELD, --compound_structure_field COMPOUND_STRUCTURE_FIELD the name of a column with a compound structure (default: False) -fp FINGERPRINT, --fingerprint FINGERPRINT fingerprint used for a compound representation (ecfp4, ecfp6, maccs, topological, atom_pairs) (default: ecfp4) -arr ARRANGE_BY, --arrange_by ARRANGE_BY arrange data by compound structures (distance matrix) or by input data (data/fps) (default: False) -cst COMPOUND_SIMILARITY_THRESHOLD, --compound_similarity_threshold COMPOUND_SIMILARITY_THRESHOLD compound similarity threshold (default: 0.7) -drm DIMENSIONAL_REDUCTION_METHOD [DIMENSIONAL_REDUCTION_METHOD ...], --dimensional_reduction_method DIMENSIONAL_REDUCTION_METHOD [DIMENSIONAL_REDUCTION_METHOD ...] which method use for dimensional reduction (pca/isomap/csn/fa/tsne) (default: pca) -dws, --dont_write_structures dont write structures to output file (default: False) -min, --minify_output minify the JSON output format (default: False) -html HTML_DIR, --html_dir HTML_DIR the directory to store HTML page with dependencies (default: False) -pcp, --physico_chemical_properties calculate basic phyisico-chemical properties and add them ass features (default: False) -edges, --add_edges add edges based on compound similarity to the graph (default: False) -n, --normalize normalize data to [0, 1] range (default: False) -mv MISSING_VALUES, --missing_values MISSING_VALUES define the string representating missing values in the data (default: False) -k KNN, --knn KNN the number of neighbours (k) used for the construction of csn using the nn method (default: None) -sm SIMILARITY_METRIC, --similarity_metric SIMILARITY_METRIC similarity metric (default: Tanimoto) -rmc REMOVE_COLUMNS [REMOVE_COLUMNS ...], --remove_columns REMOVE_COLUMNS [REMOVE_COLUMNS ...] columns in data that should not be used (default: False)

Input format
{ "paths":[ {"label": "path_1", "color":"#929292", "points":["CHEMBL492875", "CHEMBL153765"]} ], "points": { "CHEMBL86206": { "features": [ 1.0, 0.79, 7.51, null ], "links": ["CHEMBL153062", "CHEMBL31089"] } }, "feature_names": [ "PC1", "PC2", "logP", "H-Bond Donors" ], "categories": [ { "points": [ "CHEMBL153062", "CHEMBL31089", ], "label": "bioactives", "color": "red", "shape": "circle", "radius": 4 } ], "compounds": { "CHEMBL86206": { "smiles": "CCCCCc1nnc(NC(=O)NC2c3ccccc3CC2O)s1", "color": "rgb(250, 120, 62)" }, } }