PItools_vs_igraph.Rmd
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.
human_interactome = fullInteractome(taxid = "9606", database = "IntActFTP",
format = "tab27", clean = T, protein_only = TRUE)
## ... looking for the date of the latest IntAct release ...
## ... looking for the date of the latest IntAct release ...
## ... loading local copy ...
## Warning in fread(file_name, header = T, stringsAsFactors = F): Found
## and resolved improper quoting out-of-sample. First healed line 25383:
## <<uniprotkb:P16054 uniprotkb:Q05769 intact:EBI-298451 intact:EBI-298933|
## uniprotkb:Q543K3 psi-mi:kpce_mouse(display_long)|uniprotkb:Prkce(gene
## name)|psi-mi:Prkce(display_short)|uniprotkb:Pkce(gene name synonym)|
## uniprotkb:Pkcea(gene name synonym)|uniprotkb:nPKC-epsilon(gene name
## synonym) psi-mi:pgh2_mouse(display_long)|uniprotkb:Ptgs2(gene name)|
## psi-mi:Ptgs2(display_short)|uniprotkb:Cox-2(gene name synonym)|
## uniprotkb:Cox2(gene name synonym)|uniprotkb:Pghs-b(gene name synonym)|
## uniprotkb:Tis10(gene na>>. If the fields are not quoted (e.g. field
## separator does not appear within any field), try quote="" to avoid this
## warning.
human_interactome_igraph = graph_from_data_frame(d = human_interactome$data[,
.(IDs_interactor_A, IDs_interactor_B,
Publication_Identifiers, Confidence_values)],
directed = F)
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)})
## Unit: milliseconds
## expr min lq
## { edgelist2degree(human_interactome$data) } 61.28673 67.14363
## mean median uq max neval
## 76.24125 69.63505 73.94154 259.0869 100
# igraph is much faster than PItools
microbenchmark({degree(human_interactome_igraph)})
## Unit: milliseconds
## expr min lq mean
## { degree(human_interactome_igraph) } 2.002679 2.054321 2.210758
## median uq max neval
## 2.110583 2.200914 5.471241 100
# 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)
})
## Unit: milliseconds
## expr
## { 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) }
## min lq mean median uq max neval
## 128.6042 136.3452 169.6594 138.6284 213.9711 546.6082 100
Sys.Date. = Sys.Date()
Sys.Date.
## [1] "2019-04-11"
session_info. = devtools::session_info()
session_info.
## ─ Session info ──────────────────────────────────────────────────────────
## setting value
## version R version 3.5.1 (2018-07-02)
## os macOS High Sierra 10.13.6
## system x86_64, darwin15.6.0
## ui X11
## language (EN)
## collate en_GB.UTF-8
## ctype en_GB.UTF-8
## tz Europe/London
## date 2019-04-11
##
## ─ Packages ──────────────────────────────────────────────────────────────
## package * version date lib source
## AnnotationDbi 1.44.0 2018-10-30 [1] Bioconductor
## assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.5.1)
## backports 1.1.3 2018-12-14 [1] CRAN (R 3.5.0)
## Biobase 2.42.0 2018-10-30 [1] Bioconductor
## BiocGenerics * 0.28.0 2018-10-30 [1] Bioconductor
## biomaRt * 2.38.0 2018-10-30 [1] Bioconductor
## Biostrings 2.50.2 2019-01-03 [1] Bioconductor
## bit 1.1-14 2018-05-29 [1] CRAN (R 3.5.0)
## bit64 0.9-7 2017-05-08 [1] CRAN (R 3.5.0)
## bitops 1.0-6 2013-08-17 [1] CRAN (R 3.5.0)
## blob 1.1.1 2018-03-25 [1] CRAN (R 3.5.0)
## callr 3.2.0 2019-03-15 [1] CRAN (R 3.5.2)
## cli 1.1.0 2019-03-19 [1] CRAN (R 3.5.2)
## commonmark 1.7 2018-12-01 [1] CRAN (R 3.5.0)
## crayon 1.3.4 2017-09-16 [1] CRAN (R 3.5.0)
## curl 3.3 2019-01-10 [1] CRAN (R 3.5.2)
## data.table * 1.12.0 2019-01-13 [1] CRAN (R 3.5.2)
## DBI 1.0.0 2018-05-02 [1] CRAN (R 3.5.0)
## desc 1.2.0 2018-05-01 [1] CRAN (R 3.5.0)
## devtools 2.0.1 2018-10-26 [1] CRAN (R 3.5.1)
## digest 0.6.18 2018-10-10 [1] CRAN (R 3.5.0)
## downloader * 0.4 2015-07-09 [1] CRAN (R 3.5.0)
## evaluate 0.13 2019-02-12 [1] CRAN (R 3.5.2)
## fs 1.2.7 2019-03-19 [1] CRAN (R 3.5.2)
## glue 1.3.1 2019-03-12 [1] CRAN (R 3.5.2)
## gsubfn * 0.7 2018-03-16 [1] CRAN (R 3.5.0)
## hms 0.4.2 2018-03-10 [1] CRAN (R 3.5.0)
## htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.5.0)
## httr * 1.4.0 2018-12-11 [1] CRAN (R 3.5.0)
## igraph * 1.2.4 2019-02-13 [1] CRAN (R 3.5.2)
## IRanges * 2.16.0 2018-10-30 [1] Bioconductor
## jsonlite * 1.6 2018-12-07 [1] CRAN (R 3.5.0)
## knitr 1.22 2019-03-08 [1] CRAN (R 3.5.1)
## magrittr 1.5 2014-11-22 [1] CRAN (R 3.5.0)
## MASS 7.3-50 2018-04-30 [2] CRAN (R 3.5.1)
## memoise 1.1.0 2017-04-21 [1] CRAN (R 3.5.0)
## microbenchmark * 1.4-6 2018-10-18 [1] CRAN (R 3.5.0)
## ontologyIndex * 2.5 2019-01-08 [1] CRAN (R 3.5.2)
## PItools * 0.1.41 2019-04-11 [1] local
## pkgbuild 1.0.3 2019-03-20 [1] CRAN (R 3.5.1)
## pkgconfig 2.0.2 2018-08-16 [1] CRAN (R 3.5.0)
## pkgdown 1.3.0 2018-12-07 [1] CRAN (R 3.5.0)
## pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.5.0)
## plyr * 1.8.4 2016-06-08 [1] CRAN (R 3.5.0)
## prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.5.0)
## processx 3.3.0 2019-03-10 [1] CRAN (R 3.5.2)
## progress 1.2.0 2018-06-14 [1] CRAN (R 3.5.0)
## proto * 1.0.0 2016-10-29 [1] CRAN (R 3.5.0)
## ps 1.3.0 2018-12-21 [1] CRAN (R 3.5.0)
## PSICQUIC * 1.20.0 2018-10-30 [1] Bioconductor
## R.methodsS3 * 1.7.1 2016-02-16 [1] CRAN (R 3.5.0)
## R.oo * 1.22.0 2018-04-22 [1] CRAN (R 3.5.0)
## R.utils * 2.8.0 2019-02-14 [1] CRAN (R 3.5.2)
## R6 2.4.0 2019-02-14 [1] CRAN (R 3.5.2)
## Rcpp 1.0.1 2019-03-17 [1] CRAN (R 3.5.2)
## RCurl 1.95-4.12 2019-03-04 [1] CRAN (R 3.5.2)
## remotes 2.0.2 2018-10-30 [1] CRAN (R 3.5.0)
## rlang 0.3.1 2019-01-08 [1] CRAN (R 3.5.2)
## rmarkdown 1.12 2019-03-14 [1] CRAN (R 3.5.2)
## roxygen2 6.1.1 2018-11-07 [1] CRAN (R 3.5.0)
## rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.5.0)
## RSQLite 2.1.1 2018-05-06 [1] CRAN (R 3.5.0)
## rstudioapi 0.10 2019-03-19 [1] CRAN (R 3.5.2)
## S4Vectors * 0.20.1 2018-11-09 [1] Bioconductor
## sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.5.0)
## stringi 1.4.3 2019-03-12 [1] CRAN (R 3.5.2)
## stringr 1.4.0 2019-02-10 [1] CRAN (R 3.5.2)
## testthat 2.0.1 2018-10-13 [1] CRAN (R 3.5.1)
## usethis 1.5.0 2019-04-07 [1] CRAN (R 3.5.1)
## withr 2.1.2 2018-03-15 [1] CRAN (R 3.5.0)
## xfun 0.6 2019-04-02 [1] CRAN (R 3.5.1)
## XML 3.98-1.19 2019-03-06 [1] CRAN (R 3.5.2)
## xml2 1.2.0 2018-01-24 [1] CRAN (R 3.5.0)
## XVector 0.22.0 2018-10-30 [1] Bioconductor
## yaml 2.2.0 2018-07-25 [1] CRAN (R 3.5.0)
## zlibbioc 1.28.0 2018-10-30 [1] Bioconductor
##
## [1] /Users/vk7/Library/R/3.5/library
## [2] /Library/Frameworks/R.framework/Versions/3.5/Resources/library