a b/R/PPI.R
1
#' @title Defining protein-protein interactions (PPI) over a list of genes,
2
#' @description This function uses STRING-api. The outcome of STRING analysis
3
#'   will be stored in comma-separated values files.
4
#' @export
5
#' @param data A gene list.
6
#' @param FileName A string vector showing the name to be used to save the
7
#'   resulted table. If null, no file will be exported
8
#' @param species The taxonomy name/id. Default is "9606" for Homo sapiens.
9
#' @importFrom httr content
10
#' @importFrom utils read.table write.table
11
#' @return Either CSV files stored in the user's file system and its
12
#' corresponding `data.frame` object in R or and R object containing that
13
#' information.
14
PPI <- function(data, FileName = NULL, species = "9606") {
15
  repos <- retrieveURL(data, species, "tsv")
16
  # Process API request content
17
  repo_content <- content(repos)
18
  results <- data.frame(repo_content[, , 1])
19
  if (!is.null(FileName)) {
20
    write.csv(results, file = paste0("PPI-", FileName, ".csv"))
21
  }
22
  return(results)
23
}