knitr::opts_chunk$set(echo = TRUE)
suppressPackageStartupMessages({
  library(PItools)
  library(data.table)
  library(igraph)
  library(microbenchmark)
})

This article shows how to download protein interaction data using PItools, import it into igraph and calculate degree of each protein using PItools and igraph.

Download full human interactome as a data.table using PItools

human_interactome = fullInteractome(taxid = "9606", database = "IntActFTP",
                                    format = "tab27", clean = T, protein_only = TRUE)

Convert data table to igraph object

human_interactome_igraph = graph_from_data_frame(d = human_interactome$data[,
                             .(IDs_interactor_A, IDs_interactor_B,
                             Publication_Identifiers, Confidence_values)],
                             directed = F)

Calculate node degree distribution using PItools

microbenchmark function from microbenchmark R package is the most convenient and accurate way to measure how long code runs. Let's use this to find which, PItools or igraph will calculate node degree faster.

microbenchmark({edgelist2degree(human_interactome$data)})

Calculate node degree distribution using igraph

# igraph is much faster than PItools
microbenchmark({degree(human_interactome_igraph)})
# but only if you don't account for time it takes to create an igraph object
microbenchmark({
  human_interactome_igraph = graph_from_data_frame(d = human_interactome$data[,
                             .(IDs_interactor_A, IDs_interactor_B,
                             Publication_Identifiers, Confidence_values)],
                             directed = F)
  degree(human_interactome_igraph)
  })

Date and packages used

Sys.Date. = Sys.Date()
Sys.Date.
session_info. = devtools::session_info()
session_info.


vitkl/MItools documentation built on May 29, 2019, 2:55 p.m.