Network Analysis

Handout

R Exercises

## Your current working directoy
getwd()
## Go to the MDA directory
setwd("MDA")
## Create a new directory and go there 
dir.create("Network"); setwd("Network")

A - Exercise Graph Playground

A few simple lines of R code to get you started with the R package ìgraph

## Download the R script for the exercises
nw1.url <- "https://www.gdc-docs.ethz.ch/MDA/scripts/Network_Graphs_Playground_V200124.R"
utils::download.file(nw1.url, destfile = "NW_Graph.R")
file.edit("NW_Graph.R")

B - Exercise Food

For the second, a more applied exercise, we use the food dataset.

## Download the R script for the exercises
nw2.url <- "https://www.gdc-docs.ethz.ch/MDA/scripts/Network_Food_V200119.R"
utils::download.file(nw2.url, destfile = "NW_Food.R")
file.edit("NW_Food.R")
# Food data
food.url <- "https://www.gdc-docs.ethz.ch/MDA/data/food.Rdata"
utils::download.file(food.url, destfile = "food.Rdata")
load("food.Rdata")

There also some R functions available. It is up to you to download them and play around.

## Functions we need (or like to explore)
function1.url <- "https://www.gdc-docs.ethz.ch/MDA/scripts/CorrelationNetwork.R"
utils::download.file(function1.url, destfile = "CorrelationNetwork.R")
source("CorrelationNetwork.R")

#function2.url <- "https://www.gdc-docs.ethz.ch/MDA/scripts/cclasso.R"
#utils::download.file(function2.url, destfile = "cclasso.R")
#source("cclasso.R")

#function3.url <- "https://www.gdc-docs.ethz.ch/MDA/scripts/REBACCA_main.R"
#utils::download.file(function3.url, destfile = "REBACCA_main.R")
#source("REBACCA_main.R")

#function4.url <- "https://www.gdc-docs.ethz.ch/MDA/scripts/SparCC.R"
#utils::download.file(function4.url, destfile = "SparCC.R")
#source("SparCC.R")

Applied Exercises (Klaus Schlaeppi)

## Download the R script for the exercises
ks.url <- "https://www.gdc-docs.ethz.ch/MDA/handouts/GDCWorkshop_NetworkAnalysis_KS.zip"
utils::download.file(ks.url, destfile = "MDA20_Network_KS.zip")
unzip("MDA20_Network_KS.zip")

Script with solutions:

## Script with solutions (RMarkdown file)
ks_solution.url <- "https://www.gdc-docs.ethz.ch/MDA/scripts/GDCWorkshop_NetworkAnalysis_KS_with_TASKs.Rmd"
utils::download.file(ks_solution.url, destfile = "GDCWorkshop_NetworkAnalysis_KS_with_TASKs.Rmd")