Creating custom pie chart with RCy3

140 views
Skip to first unread message

Pablo Porras Millan

unread,
Mar 17, 2021, 7:12:16 PM3/17/21
to cytoscape-helpdesk
Hi,

I am trying to get a custom pie chart to show on a big network I am creating using RCy3. I have defined my own style and then used 'setNodeCustomPieChart' to add a pie chart in the middle of my nodes, so I can use it to display whether the nodes belong to a set of different groups.

The problem is that I cannot get the pie chart displayed on my network. I have a large number of groups (38), even though not more than 5 or 6 are assigned to a single node at a time, so I am not sure if that could be the problem. Any common issues here that could be causing the issue?

Thanks and regards,

Pablo.

Scooter Morris

unread,
Mar 18, 2021, 9:18:38 AM3/18/21
to cytoscape-helpdesk
Hi Pablo,

Have you focused on any of the nodes the have the pie chart and zoomed in close?  With a large network, custom graphics are suppressed for performance reasons, so you either need to show details or zoom in.

-- scooter

Pablo Porras Millan

unread,
Mar 18, 2021, 9:34:01 AM3/18/21
to cytoscape-helpdesk
Hi Scooter,

Yep, I have done that, but the pie chart is simply not there. I attach some screenshots to show you how it looks and at the end of the message is the code I use to create the pie charts, in case there is something there that is not correct.

Thanks for your help!

Best,

Pablo.
Screenshot 2021-03-18 at 13.30.03.pngScreenshot 2021-03-18 at 13.30.16.pngScreenshot 2021-03-18 at 13.30.26.png

pie.columns.list <- c("Blood group","Bone marrow failure","Cancer Programme","Cardiovascular disorders","Ciliopathies","Dermatological disorders","Dysmorphic and congenital abnormality syndromes","Ehlers-Danlos syndromes","Endocrine disorders","Gastroenterological disorders","Growth disorders","Haematological disorders","Hearing and ear disorders","Hereditary haemorrhagic telangiectasia","Intrahepatic cholestasis of pregnancy","Leber hereditary optic neuropathy","letal disorders","Metabolic disorders","Multiple primary malignant tumours","Neurology and neurodevelopmental disorders","Neuropathic pain disorders","Ophthalmological disorders","Paediatric disorders","Primary immune disorders","Primary immune disorders;Stem cell and myeloid disorders - WBC","Primary membranoproliferative glomerulonephritis","Pulmonary arterial hypertension","Renal and urinary tract disorders","Respiratory disorders","Rheumatological disorders","Skeletal disorders","Small cerebral vessel disease","Stem cell and myeloid disorders - RBC","Stem cell and myeloid disorders - WBC","Stem cell and myeloid disorders - WBC: Neurology and neurodevelopmental disorders","Steroid-resistant nephrotic syndrome","Tumour syndromes","unassigned")

setNodeCustomPieChart(
  pie.columns.list,
  style.name = "variopath",
  slot = 1)

setNodeCustomPosition(
  nodeAnchor = "C",
  xOffset = 0,
  style.name = "variopath",
  slot = 1)

Scooter Morris

unread,
Mar 18, 2021, 11:59:14 AM3/18/21
to cytoscape-helpdesk
Hi Pablo,
    Can you create a Pie Chart for that particular node manually (using the Bypass)?  I'm wondering if there is a problem with one of the columns, or if, in that case, all of the values are 0?

-- scooter

Pablo Porras Millan

unread,
Mar 18, 2021, 1:30:32 PM3/18/21
to cytoscape-helpdesk
Hi,

I tried that and found something very weird. When you try on the network with my defined style applied ('variopath'), you can see the node columns available. However, if you switch to another style (see screenshots 1 to 3) the node columns dissappear. So there is something going on with these columns.

I tried renaming the columns and actually got to the point where at least the pie chart menu shows a color attributed to each one of them (screenshot 4), but it still won't show the pie charts. I suspect the column names, which are in places very long, could be one of the issues, so I will try renaming them.

I'll let you know how I get on once I try again.

Cheers,

Pablo.

Screenshot 2021-03-18 at 17.19.15.pngScreenshot 2021-03-18 at 17.20.12.pngScreenshot 2021-03-18 at 17.19.42.pngScreenshot 2021-03-18 at 17.18.55.png

Pablo Porras Millan

unread,
Mar 18, 2021, 6:48:39 PM3/18/21
to cytoscape-helpdesk
OK, I finally got it to work. It was the combination of a stupid mistake (my columns were set as strings instead of numeric variables) and the columns names, which Cytoscape didn't like. By simplifying those and setting the columns to the right data type, the charts were finally drawn.

Many thanks for the help, I hope this is useful for future reference.

Best,

Pablo.

Alex Pico

unread,
Mar 19, 2021, 3:24:50 PM3/19/21
to cytoscape-helpdesk
Excellent. And thanks for sharing the solution for future reference!
 - Alex

Pablo Porras Millan

unread,
Mar 20, 2021, 11:58:26 AM3/20/21
to cytoscape-helpdesk
One final detail: the data frame that is sent to the network needs to be sorted in a way that the columns containing numeric variables have values within the first few rows. Otherwise they get identified as strings by Cytoscape and the pie charts are not drawn.

Best,

Pablo.

Scooter Morris

unread,
Mar 25, 2021, 11:40:04 AM3/25/21
to cytoscape-helpdesk
Thanks Pablo.  There definitely should be a way to indicate the column type when you send the data frame, even if the first few rows are blank.  I'll ask Alex about it, and if it's not there, we'll talk about adding it.

-- scooter

Alex Pico

unread,
Mar 25, 2021, 3:14:40 PM3/25/21
to cytoscape-helpdesk
There is not an obvious mapping between R and Java numerics. We put in special handling for Integers (since those are the same):

But other cases rely on Cytoscape to guess and that process samples the first (or first few values). That’s why sorting your rows works. 

The only other option I can think of is to add code like the chunk above into your script to explicitly predefine the columns before you load your data. You would have to:
 1. Create the network (without any extra data)
 2. Create columns of the types you want
 3. Load your tabular data

Sorting your rows might be easier :)
 - Alex



-- 
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-helpd...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cytoscape-helpdesk/86d7c914-e26c-4343-a57c-a5885c671428n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages