CyREST : Instability of the link between a graph and its style defined with CyREST

49 views
Skip to first unread message

Pascal KREZEL

unread,
Jun 15, 2017, 1:16:56 PM6/15/17
to cytoscape-helpdesk
Hi,

I remarked that there is a bug with the link between a graph and the style defined with CyREST. The style is weel-affected at the beginning but suddenly with no reason the graph can't be connected with this style anymore. So I must rebuild it.
More precisely, , I can have in a same Cytoscape file  some graphs disconnected from this style and some not.
Is it a bug recognized ?

Pascal

Pascal KREZEL

unread,
Jun 16, 2017, 11:04:36 AM6/16/17
to cytoscape-helpdesk
Hi,

I problem may come from the duplication of my style with the creation of a new network by GLay. That's why  now I avoid that . I will confirm this.

Pascal

David Otasek

unread,
Jun 16, 2017, 12:01:42 PM6/16/17
to cytoscape...@googlegroups.com
Hi Pascal,

If you can, please confirm the behaviour and let me know. I will look into this.

Thanks,

David Otasek

--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape-helpdesk@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.
To view this discussion on the web visit https://groups.google.com/d/msgid/cytoscape-helpdesk/b2c97a60-693f-4f65-b2cc-73997396fc78%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Pascal KREZEL

unread,
Jun 27, 2017, 1:13:14 PM6/27/17
to cytoscape-helpdesk
Hi David,

I confirm this behaviour that happens after a reload of my .cys file. It seems that only the edges are concerned : color and transparency can't be changed anymore.

Pascal


Le vendredi 16 juin 2017 18:01:42 UTC+2, David Otasek a écrit :
Hi Pascal,

If you can, please confirm the behaviour and let me know. I will look into this.

Thanks,

David Otasek
On Fri, Jun 16, 2017 at 11:04 AM, Pascal KREZEL <pascal...@gmail.com> wrote:
Hi,

I problem may come from the duplication of my style with the creation of a new network by GLay. That's why  now I avoid that . I will confirm this.

Pascal

Le jeudi 15 juin 2017 19:16:56 UTC+2, Pascal KREZEL a écrit :
Hi,

I remarked that there is a bug with the link between a graph and the style defined with CyREST. The style is weel-affected at the beginning but suddenly with no reason the graph can't be connected with this style anymore. So I must rebuild it.
More precisely, , I can have in a same Cytoscape file  some graphs disconnected from this style and some not.
Is it a bug recognized ?

Pascal

--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.

David Otasek

unread,
Jun 29, 2017, 10:07:15 AM6/29/17
to cytoscape...@googlegroups.com
Hi Pascal,

This may be related to the way Visual Properties are set, but I need to confirm a few things to narrow this down.

As I understand it, you are using CyREST to create a graph and generate some visual properties, and then after saving, or at some other point, they are 'disconnected'.

What are the methods by which you are setting your visual properties? (the URL or py2cytoscape/RCy3 function is good for describing this)

By disconnected, I assume this means that the color/shape/size property you set no longer appears, and another appears in its place. Is this correct?

Thanks,

David Otasek

On Tue, Jun 27, 2017 at 1:13 PM, Pascal KREZEL <pascal...@gmail.com> wrote:
Hi David,

I confirm this behaviour that happens after a reload of my .cys file. It seems that only the edges are concerned : color and transparency can't be changed anymore.

Pascal

Le vendredi 16 juin 2017 18:01:42 UTC+2, David Otasek a écrit :
Hi Pascal,

If you can, please confirm the behaviour and let me know. I will look into this.

Thanks,

David Otasek
On Fri, Jun 16, 2017 at 11:04 AM, Pascal KREZEL <pascal...@gmail.com> wrote:
Hi,

I problem may come from the duplication of my style with the creation of a new network by GLay. That's why  now I avoid that . I will confirm this.

Pascal

Le jeudi 15 juin 2017 19:16:56 UTC+2, Pascal KREZEL a écrit :
Hi,

I remarked that there is a bug with the link between a graph and the style defined with CyREST. The style is weel-affected at the beginning but suddenly with no reason the graph can't be connected with this style anymore. So I must rebuild it.
More precisely, , I can have in a same Cytoscape file  some graphs disconnected from this style and some not.
Is it a bug recognized ?

Pascal

--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsubscribe@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.

--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape-helpdesk@googlegroups.com.

Pascal KREZEL

unread,
Jul 3, 2017, 5:10:35 AM7/3/17
to cytoscape-helpdesk
Hi David,

By disconnected, I mean that the characteristics of the edges can't be modify anymore and they stay in black without transparency. I think it happens only after a reload of mys .cys file but I am not sure.

To modify the characteristics of the edges, I use two methods 

The first method uses the definition of a style as follow:
# Create a new style
mbx_style = cy.style.create('MBx_style')

# Prepare key-value pair for Style defaults

new_defaults = {
    
#     # Edge defaults
#     'EDGE_WIDTH': 3,
#     'EDGE_STROKE_UNSELECTED_PAINT': '#aaaaaa',
#     'EDGE_LINE_TYPE': 'SOLID',
#     'EDGE_TRANSPARENCY': 120,
    
#     # Network defaults
#     'NETWORK_BACKGROUND_PAINT': 'white'
}

# Update
mbx_style.update_defaults(new_defaults)

mbx_style.create_passthrough_mapping(column='node_shape', col_type='String', vp='NODE_SHAPE')

mbx_style.create_passthrough_mapping(column='node_color', col_type='String', vp='NODE_FILL_COLOR')

mbx_style.create_passthrough_mapping(column='node_trans', col_type='String', vp='NODE_TRANSPARENCY')

mbx_style.create_passthrough_mapping(column='node_size', col_type='String', vp='NODE_HEIGHT')

mbx_style.create_passthrough_mapping(column='node_size', col_type='String', vp='NODE_WIDTH')

mbx_style.create_passthrough_mapping(column='node_label', col_type='String', vp='NODE_LABEL')

mbx_style.create_passthrough_mapping(column='node_lsize', col_type='String', vp='NODE_LABEL_FONT_SIZE')

mbx_style.create_passthrough_mapping(column='node_bwidth', col_type='String', vp='NODE_BORDER_WIDTH')

mbx_style.create_passthrough_mapping(column='node_btrans', col_type='String', vp='NODE_BORDER_TRANSPARENCY')

mbx_style.create_passthrough_mapping(column='edge_color', col_type='String', vp='EDGE_STROKE_UNSELECTED_PAINT')

mbx_style.create_passthrough_mapping(column='edge_trans', col_type='String', vp='EDGE_TRANSPARENCY')

mbx_style.create_passthrough_mapping(column='edge_width', col_type='String', vp='EDGE_WIDTH')

then I use a function edge_update_table that I rewrite myself from py2cytoscape because I had some problems with the original one :

def edge_update_table(net, df, network_key_col='name', data_key_col=None):
    """
    Function to update the edge_table in Cytoscape
    """

    is_index_col = False

    if data_key_col is None:
        # Use index
        data_key = network_key_col
        is_index_col = True
    else:
        data_key = data_key_col

    table = {
        'key': network_key_col,
        'dataKey': data_key
    }

    if is_index_col:
        # Use DataFrame's index as the mapping key
        df2 = pd.DataFrame(df)
        df2[network_key_col] = df.index
        data = df2.to_json(orient='records')
        del df2
    else:
        data = df.to_json(orient='records')

    table['data'] = json.loads(data)
    SUID=net.get_id()
    net.session.put(url, json=table)

Then I defined some functions like:

def add_edges_color(Gc,color=None):
    """
    Affectation de couleur aux arêtes en fonction de :
    -df: dataframe contenant les informations entre id et subsystem
    -MetaboColor: dictionnaire donnant le couleur par subsystems
    """
    df_e=Gc.get_edge_table()
    df_e2=df_e[["SUID"]]

    if color is None:
        L=[]
        for x,y in zip(df_e["source"],df_e["target"]):
            if x[:2]=="R_":
                L.append(MetaboColor[Dic_Sub_s2[x]])
            else:
                L.append(MetaboColor[Dic_Sub_s2[y]])
        df_e2["edge_color"]=L
    else:
        df_e2["edge_color"]=color
    
    edge_update_table(Gc,df_e2,network_key_col='SUID',data_key_col='SUID')


The second method uses the following functions from py2cytoscape :
view_id_list = Gc.get_views()
view1 = Gc.get_view(view_id_list[0], format='view')
view1.update_node_views(visual_property='NODE_FILL_COLOR', values=val)

for example:

def view_nodes_color(Gc):

    df_n=Gc.get_node_table()
    LesMol=df_n["id"]
    name_map = util.name2suid(Gc)
    LesSUID=[name_map[x] for x in LesMol]
      
    Lc=Lnodes_color(LesMol)
   
    val={n:c for n,c in zip(LesSUID,Lc)}
    view_id_list = Gc.get_views()
    view1 = Gc.get_view(view_id_list[0], format='view')
    view1.update_node_views(visual_property='NODE_FILL_COLOR', values=val)
 

Ask me more questions if you need.

Pascal
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.

--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.

Pascal KREZEL

unread,
Jul 25, 2017, 4:49:13 AM7/25/17
to cytoscape-helpdesk
Hi David,

Did you read my answer about the ways I affect the properties to my graphs with CyREST ?

One more time, after having recorded my graphs and restarted Cytoscape, I lost again the properties of my edges and I can't reapply them.

Do you have a solution ?

Pascal
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.

--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.

David Otasek

unread,
Jul 25, 2017, 6:17:19 PM7/25/17
to cytoscape...@googlegroups.com
Apologies for the delayed reply.

I'm putting together a test to try to replicate this behaviour. So far, I'm trying to follow your way of constructing a network and applying a passthrough mapping.

I haven't been able to replicate your error, but maybe you can take a look at my test and see if it follows your process accurately enough. I've included the file with this message.



To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsubscribe@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.

--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsubscribe@googlegroups.com.

To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.

--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape-helpdesk@googlegroups.com.
passthrough_test.py

Pascal KREZEL

unread,
Jul 26, 2017, 4:16:21 AM7/26/17
to cytoscape-helpdesk
Hi David,

Thank you for your answer.

I did your test and I transformed it in the MBx_Test_CyREST.ipynb : it works.

I developed my own functions to use CyREST which are in MBx.py that I joined to this email. Tell me what you think about it !

In fact, I am presently working with a file .cys of 50 MB and it takes about 1 min 30 s to open it. May be my problem comes from there ?

Pascal






To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.

--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.

--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.
MBx.py
MBx_Test_CyREST.ipynb

David Otasek

unread,
Jul 26, 2017, 11:53:32 AM7/26/17
to cytoscape...@googlegroups.com
MBx is definitely a complex piece of code; tracing something like this to find the point at which it has the side-effect you're reporting is not going to be easy, particularly if the code itself doesn't throw any errors.

It might be helpful if I can see the produced cys file. Maybe it can give some hints as to what happened and refine the kind of code we're searching for.

To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsubscribe@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.

--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsubscribe@googlegroups.com.

To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.

--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsubscribe@googlegroups.com.

To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.

--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape-helpdesk@googlegroups.com.

Pascal KREZEL

unread,
Jul 27, 2017, 3:52:35 AM7/27/17
to cytoscape-helpdesk
Hi David,

Thank you for your answer. 
In fact I found an error in MBx.py.  Now it works.
So it seems that the problem comes from me.

For information, I needed to rewrite the functions node_update_table and edge_update_table that didn't work with py2cytoscape but the problem I resolved doesn't come from there.

Thank you again for your help.

Pascal


To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.

--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.

--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.

--
You received this message because you are subscribed to the Google Groups "cytoscape-helpdesk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cytoscape-helpdesk+unsub...@googlegroups.com.
To post to this group, send email to cytoscape...@googlegroups.com.
Visit this group at https://groups.google.com/group/cytoscape-helpdesk.

David Otasek

unread,
Jul 31, 2017, 7:27:18 PM7/31/17
to cytoscape-helpdesk
Hi Pascal,

I'm glad you got your script working. May I ask what specifically was wrong, perhaps with a snippet of code to demonstrate? It may help diagnosing other problems in the future.

Thanks,

David
Reply all
Reply to author
Forward
0 new messages