Can't change layout for new networks in py4cytoscape?
1
0
Entering edit mode
14 months ago
Harris • 0

Hi,

I'm using py4cytoscape to automate some figure preparation, and I've come across a problem. My script successfully turns these dataframes into networks.

However, they always have some kind of rectangular layout, and I'm unable to change it, either from py4cytoscape or even within the Cytoscape app. Instead, what happens in both cases is that the view fits to the network, or the rectangular layout may change dimensions to be two columns instead of 12, or something like that. It depends on what layout I try.

Layouts both in py4cytoscape and in the Cytoscape app work just fine for other networks, like for Cytoscape's default tutorial network with yeast. I've tried both using Mu editor as well as using a Jupyter notebook, with no differences. So I'm thinking there's something different about a network I've made myself - maybe I need to include some attribute in the node file.

My next step is to retrieve edges from String's protein query, at which point it's possible the additional information will rectify the problem...? I don't know how to do that yet though, or if it's available in py4cytoscape.

Here's my code:

Thanks in advance for any insight!

`import csv import pandas as pd import py4cytoscape as py4

load files

ourdatawb = 'HB filtered 01162023 mTOR phos round 2 summary.xlsx' wgfile = 'enrichment_results_wg_result1675954646.txt'

parameters

ourdatasheet = '4 Filtered' ourdata_idcol = 'Uniprot' wg_idcol = 'id'

turn csv into list with a dataframe for each pathway found

def unpack(filename): with open(filename) as csvfile: reader = csv.reader(csvfile,delimiter=' ') list1 = [[pd.DataFrame(data={wg_idcol:i[-1].split(';'),'pathway':i[1]},columns=['id','pathway'])] for i in reader] return list1

pathways = unpack(wgfile)[1:]

ourdf = pd.read_excel(ourdatawb, sheet_name=ourdatasheet)

import data to each pathway dataframe, and make a newtwork from each

for i in pathways: df1 = pd.merge(i[0],ourdf,left_on=wg_idcol, right_on=ourdata_idcol) py4.create_network_from_data_frames(df1, title=str(df1.loc[0,'pathway'])) py4.layout_network('attribute-circle')`

Cytoscape py4cytoscape • 434 views
ADD COMMENT
0
Entering edit mode
14 months ago
Scooter ▴ 280

The problem is that you don't have any edges. The way the layouts work is that they independently layout each connected component, but with no edges, each node becomes it's own connected component, so there is nothing to do. Once you add edges to your network, the layouts should behave as you would expect.

-- scooter

ADD COMMENT

Login before adding your answer.

Traffic: 2729 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6