Deep Layer Scatter
The Deep Layer Scatter Plot is still in prototype phase but really good for seeing where the package is going in terms of lexical network graphs. We implement the Parallel Coordinates from Plotly:
Imports
from global_chem import GlobalChem
from global_chem_extensions import GlobalChemExtensions
gc = GlobalChem()
cheminformatics = GlobalChemExtensions().cheminformatics()
Scatter your Graph
gc = GlobalChem()
gc.initiate_deep_layer_network()
gc.add_deep_layer(
[
'emerging_perfluoroalkyls',
'montmorillonite_adsorption',
'common_monomer_repeating_units',
'vitamins',
'schedule_two',
]
)
gc.add_deep_layer(
[
'common_warheads_covalent_inhibitors',
'privileged_scaffolds',
'iupac_blue_book',
'schedule_four',
'schedule_one',
]
)
gc.print_deep_network()e_file=True)
Algorithm
Here we want to visualize deep layer networks and add colour, weights of lines etc for a more sophisticated data visualization.
In the algorithm we first determine the max depth of the network object. While keep tracking of how many nodes are in each deep layer. For example, the Network Graph
we have 3 layers
layer = 1
node_counts = []
for node_key, node_value in self.deep_layer_network.items():
if int(node_value['layer']) > layer:
layer = int(node_value['layer'])
for i in range(1, layer + 1):
counts = 0
for node_key, node_value in self.deep_layer_network.items():
if int(node_value['layer']) == i:
counts += 1
node_counts.append(counts)
Now we have to convert our GlobalChem Network object into a Plotly Style to get it ready for Parcats
plotting.
Algorithm:
1.) Establish the First Layer as Root & Establish Second Layer Concomitantly.
2.) Determine Lexical Symmetry or Anti-Symmetry & Add Continued Layers
3.) Prepare Plotly Python Data Structure
In the third step, the dimensions refers to the a list that will house the list of dictionary objects. Each category
is a layer, where it's values correspond to a combination of lexical keys. For example let's say we create a three node graph with 3 layers:
Layer 1: ['global_chem']
Layer 2: ['global_chem - emerging_perfluroalkyls' ]
Layer 3: ['global_chem - emerging_perfluroalkyls - schedule_one' ]
if i == 1:
first_layer = [ nodes[0]['name'] ] * reduce((lambda x, y: x * y), self.node_counts)
layer_object.append(first_layer)
values = nodes[0]['children']
for value in values:
second_layer += [ value ] * self.node_counts[1]
layer_object.append(second_layer)
With our dimensions we then pass into Parcats
fig = go.Figure(go.Parcats(
dimensions=dimensions,
arrangement='freeform',
line = dict(
color = colors,
),
hoveron='color',
hoverinfo='count+probability',
labelfont={'size': 20, 'family': 'Times'},
tickfont={'size': 15, 'family': 'Times'},
))
fig.update_layout(
title_text="Deep Layer Scatter",
title_font=dict(size=12, family='Arial'),
template='simple_white',
xaxis_tickformat = 'i',
bargap=0.4, # gap between bars of adjacent location coordinates,
height=800,
width=1700
)
Last updated