cytoscape / py4cytoscape

Python library for calling Cytoscape Automation via CyREST
https://Py4Cytoscape.readthedocs.io
Other
69 stars 15 forks source link

load_table_data changes the table #100

Open carissableker opened 1 year ago

carissableker commented 1 year ago

Using p4c.load_table_data changes the input table (adding a row.names column. This is unexpected. If the column needs to be added, maybe that should be done on a copy?

df = pd.DataFrame([
            ("AT1G02980", 10), 
            ("AT1G02980", 3), 
            ("AT1G02980", 1)], 
    columns=["name", "value"]).set_index("name")
df
         value
name            
AT1G02980     10
AT1G02907      3
AT1G02380      1

p4c.load_table_data(df)
'Success: Data loaded in defaultnode table'

df
           value  row.names
name                       
AT1G02980     10  AT1G02980
AT1G02980      3  AT1G02980
AT1G02980      1  AT1G02980
bdemchak commented 1 year ago

Hi, Carissa --

This is a fair criticism, and I'm sorry for the confusion. (Thanks for using py4cytoscape!)

The structure and control flow for py4cytoscape was taken from RCy3 in large part. Having done that, it's quite possible that RCy3 has the same issue ... or not. I can see that the lines 304 & 308 of RCy3's Tables.R assign the 'data' dataframe an edited value in the same way as py4cytoscape's tables.py line 455.

I'm not sure how R works ... I'll find out whether those RCy3 assignments end up creating a local copy of the dataframe. If so, I can follow suit, too.

@AlexanderPico @yihangx ... can you take a look at this behavior in RCy3 and let me know??

Thanks!