Create network from csv file

Draft

Start Cytoscape — click here to review how to install and or start Cytoscape.

Example — create a network of Steven Spielberg crew for films Jaws, Close Encounters of the Third Kind, 1941, and Raiders of the Lost Ark.

Data source: Steven Spielberg movies, IMDB

I just Copy/paste then edited the data as needed. Three columns: Crew, Film, Department.

Note. This is a crude example of web scraping. It’s possible to automate much of the scraping from IMDB via the R package rvest. See Web scraping from a static webpage (rvest package) at Mike’s Workbook for Biostatistics for suggestions. Almost certainly, scraping from IMDB via rvest violates their Conditions of use policies. A package called imdbapi, which accesses tools in their public API would be better choice.

Build a simple spreadsheet file (Fig 1), then export to csv file. The entire data set contained 1062 rows.

Screenshot portion of spreadsheet containing network list

Figure 1. Screenshot portion of spreadsheet containing network list.

Note: I use LibreOffice Calc as my spreadsheet app. To export to csv, select the worksheet — spielberg_crew in this example — then from the menu File > Save As… enter file name, select Text CSV (*.csv) from the Save as type drop down list. Options:

  • Field delimiter: ,
  • String delimiter: I delete the “

Google Sheets: File > Download > Comma Separated Values (.csv)

As always, save files to your project working folder.

Import csv file into Cytoscape

For the example I used a different file. The file simply contained a list of my co-authored publications along with the names of the authors.

Note: This is the very same task that SocialNetwork app was designed to do.

Even though we are starting from a text file (.csv), Cytoscape calls these Network files. We begin by importing the file. We can drag the file to the start page, or File > Import > Network from File… (Fig 2).

New network file

Figure 2. Screenshot of Cytoscape Import menu.

Navigate to your csv data file, select OK to load the file. You should see a popup like Figure 3.

network file

Figure 3. Screenshot of data table preview.

Need to tell Cytoscape which column is a source node, which is a target node.

Set node

Figure 4. For Authors, source note (green circle icon).

set target node

Figure 5. Publication title Target node (red target icon).

After setting the column information, click the OK button

First network

Figure 6. First network.