Hi all,
I'm trying to analyze a graph for which I have multiple layers and I'm finding difficulties in creating the graph. I have two graphs with the same vertex for which I define a edge property (the layer) like this:
(g_atac, dist_atac) = gt.generate_knn(A_data, k=n_neighbors)
(g_rna, dist_rna) = gt.generate_knn(R_data, k=n_neighbors)
layer_atac = g_atac.new_edge_property('int')
for e in g_atac.edges():
layer_atac[e] = 1
layer_rna = g_rna.new_edge_property('int')
for e in g_rna.edges():
layer_rna[e] = -1
g_atac.edge_properties['layer'] = layer_atac
g_rna.edge_properties['layer'] = layer_rna
I then merge the graphs by graph union, first defining a node mapping:
rna_mappings = g_rna.new_vertex_property("int")
for x in range(g_atac.num_vertices()):
rna_mappings[x] = x
and then performing the actual union:
gu = gt.graph_union(g_atac, g_rna, intersection=rna_mappings, internal_props=True)
This indeed creates the final graph, but I noticed that instead of two layers I have three:
np.unique(gu.edge_properties['layer'].a)
PropertyArray([-1, 0, 1], dtype=int32)
Looking back at the start graphs I have zeros in the edge_properties as well
np.unique(g_rna.edge_properties['layer'].a)
PropertyArray([-1, 0], dtype=int32)
np.unique(g_atac.edge_properties['layer'].a)
PropertyArray([0, 1], dtype=int32)
and, similarly, the elements in the edge property vector are much higher than the number of edges:
print((len(g_rna.ep['layer'].a), g_rna.num_edges()))
(156672, 14317)
which is different from what I can get from this:
g_rna.get_edges([g_rna.ep['layer']]).shape
(14317, 3)
I'm evidently messing with (internal) properties and I'm clueless, any advice?