##' Compare viral and human protein degree distribution, filter by interaction detection method or PMIDs
##' @name humanViralDegree
##' @author Vitalii Kleshchevnikov
##' @description subset molecular interaction data (cleaned MITAB format in a data.table object) with a list of interactors
##' @param data a list contatining PPI data as generated by \code{\link[PItools]{loadHumanViralPPI}}, if NULL, data will be downloaded internally
##' @param directory where to find / keep PPI data (arg for \code{\link[PItools]{fullInteractome}}, \code{\link[PItools]{interSpeciesInteractome}})) and MI ontology (arg for \code{\link[PItools]{subsetMITABbyMethod}})
##' @param Interaction_detection_methods arg for \code{\link[PItools]{subsetMITABbyMethod}}
##' @param Identification_method arg for \code{\link[PItools]{subsetMITABbyMethod}}
##' @param PMIDs arg for \code{\link[PItools]{subsetMITABbyPMIDs}}
##' @param inverse_filter logical, inverse filtering criteria
##' @param data_name to be displayed on plot
##' @return data.table to be ggplotted to compare viral and human protein degree distributions
##' @import data.table
##' @export humanViralDegree
##' @examples
##' {
##' # Load data. This can be done internally by humanViralDegree(),
##' # however, it takes time (minutes) so it's recommended to load data separately
##' # if it will be used multiple times
##' HumanViralPPI = loadHumanViralPPI(directory = "./data_files/")
##'
##' # prepare all data for the degree distribution analysis
##' degree_distributions = humanViralDegree(data = HumanViralPPI,
##' directory = "./data_files/", data_name = "Full IntAct")
##'
##' # prepare two-hybrid data for the degree distribution analysis
##' degree_distributions = humanViralDegree(data = HumanViralPPI,
##' directory = "./data_files/", Interaction_detection_methods = "MI:0018",
##' data_name = "two-hybrid data")
##'
##' # prepare AP-MS data for the degree distribution analysis
##' degree_distributions = humanViralDegree(data = HumanViralPPI,
##' directory = "./data_files/", Interaction_detection_methods = "MI:0004",
##' Identification_method = "MI:0433", PMIDs = NULL, inverse_filter = F,
##' data_name = "AP-MS data")
##'
##' # to see if viral-interacting human proteins are special in the human network,
##' # look at the Vidal published and unpublished datasets (only human-human network
##' # is modified (data for the top 2 plots))
##' degree_distributions = humanViralDegree(data = HumanViralPPI,
##' directory = "./data_files/", PMIDs = c("25416956", "unassigned1304"),
##' data_name = "Vidal published and unpublished")
##' # to see if viral-interacting human proteins are special in the human network,
##' # do the same for Matthias Mann 2015 paper dataset
##' degree_distributions = humanViralDegree(data = HumanViralPPI,
##' directory = "./data_files/", PMIDs = "26496610",
##' data_name = "Matthias Mann 2015 paper")
##' }
humanViralDegree = function(data = NULL, directory = "./data_files/", Interaction_detection_methods = NULL, Identification_method = NULL, PMIDs = NULL, inverse_filter = F, data_name = ""){
if(is.null(data)){
HumanViralPPI = loadHumanViralPPI(directory = directory)
} else {
HumanViralPPI = data
}
all_human_interaction = HumanViralPPI$human_human
all_viral_interaction = HumanViralPPI$human_viral
all_within_viral_interaction = HumanViralPPI$viral_viral
# filter by method
all_human_interaction = subsetMITABbyMethod(all_human_interaction,
Interaction_detection_methods = Interaction_detection_methods,
Identification_method = Identification_method, ontology_directory = directory,
inverse_filter = inverse_filter)
all_viral_interaction = subsetMITABbyMethod(all_viral_interaction,
Interaction_detection_methods = Interaction_detection_methods,
Identification_method = Identification_method, ontology_directory = directory,
inverse_filter = inverse_filter)
all_within_viral_interaction = subsetMITABbyMethod(all_within_viral_interaction,
Interaction_detection_methods = Interaction_detection_methods,
Identification_method = Identification_method, ontology_directory = directory,
inverse_filter = inverse_filter)
# filter all_human_interaction by PMIDs
if(!is.null(PMIDs)){
all_human_interaction = subsetMITABbyPMIDs(MITABdata = all_human_interaction,
PMIDs = PMIDs,
inverse_filter = inverse_filter)
}
human_viral_proteins = extractInteractors(all_viral_interaction, taxid = 9606, inverse_filter = F)
human_human_proteins = extractInteractors(all_human_interaction)
viral_proteins = extractInteractors(all_viral_interaction, taxid = 9606, inverse_filter = T)
human_human_degree = edgelist2degree(all_human_interaction$data)
human_human_degree_legend = paste0("full human-human: \n", uniqueNinteractions(all_human_interaction)," interacting pairs, \n", uniqueNinteractors(all_human_interaction)," human proteins")
human_human_degree[, legend := human_human_degree_legend]
inViral_human_interaction = subsetMITABbyID(MITABdata = all_human_interaction,
ID_seed = human_viral_proteins, within_seed = T)
inViral_human_human_degree = edgelist2degree(inViral_human_interaction$data)[ID %in% human_viral_proteins]
inViral_human_human_degree_legend = paste0("viral-interacting proteins, human-human: \n",
uniqueNinteractions(inViral_human_interaction),
" interacting pairs, \n",
uniqueNinteractors(inViral_human_interaction)," human proteins")
inViral_human_human_degree[, legend := inViral_human_human_degree_legend]
inViral_human_viral_degree = edgelist2degree(all_viral_interaction$data)[ID %in% human_viral_proteins]
inViral_human_viral_degree_legend = paste0("human-viral: \n", uniqueNinteractions(all_viral_interaction)," interacting pairs, \n", uniqueNinteractors(all_viral_interaction, taxid = 9606, inverse_filter = F)," human proteins")
inViral_human_viral_degree[, legend := inViral_human_viral_degree_legend]
inViral_viral_human_degree = edgelist2degree(all_viral_interaction$data)[ID %in% viral_proteins]
inViral_viral_human_degree_legend = paste0("viral-human: \n", uniqueNinteractions(all_viral_interaction)," interacting pairs, \n", uniqueNinteractors(all_viral_interaction, taxid = 9606, inverse_filter = T)," viral proteins")
inViral_viral_human_degree[, legend := inViral_viral_human_degree_legend]
inViral_viral_viral_degree = edgelist2degree(all_within_viral_interaction$data)[ID %in% viral_proteins]
inViral_viral_viral_degree_legend = paste0("viral-viral (human host): \n", uniqueNinteractions(all_within_viral_interaction)," interacting pairs, \n", uniqueNinteractors(all_within_viral_interaction)," viral proteins")
inViral_viral_viral_degree[, legend := inViral_viral_viral_degree_legend]
degree_distributions = rbind(human_human_degree, inViral_human_human_degree, inViral_human_viral_degree, inViral_viral_human_degree, inViral_viral_viral_degree)
degree_distributions[, legend := factor(legend,
levels = c(human_human_degree_legend,
inViral_viral_human_degree_legend, inViral_human_viral_degree_legend,
inViral_human_human_degree_legend, inViral_viral_viral_degree_legend))]
degree_distributions[, medianN := as.integer(median(N)), by = legend]
degree_distributions[, medianN_lab := paste0("median: \n ",signif(medianN,1), " interacting partners")]
degree_distributions[, data_name := data_name]
return(degree_distributions)
}
##' load human-human, human-viral and viral-viral PPI data from IntActFTP
##' @name loadHumanViralPPI
##' @author Vitalii Kleshchevnikov
##' @description use \code{\link[PItools]{interSpeciesInteractome}} and \code{\link[PItools]{fullInteractome}} to retrieve and load human-human, human-viral and viral-viral PPI data from IntActFTP
##' @description to be used with \code{\link[PItools]{humanViralDegree}}
##' @param directory to find / keep PPI data (arg for \code{\link[PItools]{fullInteractome}}, \code{\link[PItools]{interSpeciesInteractome}}))
##' @param loadIntActFTP_dir where to find specific release (arg for \code{\link[PItools]{loadIntActFTP}})
##' @param release release date
##' @import data.table
##' @export loadHumanViralPPI
loadHumanViralPPI = function(directory = "./data_files/",
loadIntActFTP_dir = "./data_files/IntActRelease_2017Nov13/",
release = "2017Nov13"){
# load ppi data
IntAct = loadIntActFTP(dir = loadIntActFTP_dir,
release = release)
# human-human
all_human_interaction = fullInteractome(taxid = 9606, database = "IntActFTP", format = "tab27",
clean = TRUE, protein_only = TRUE,
MITABdata = IntAct, directory = directory,
releaseORdate = release)
# human-viral
all_viral_interaction = interSpeciesInteractome(taxid1 = 9606, taxid2 = 10239, database = "IntActFTP", format = "tab27",
clean = TRUE, protein_only = TRUE,
MITABdata = IntAct, directory = directory,
releaseORdate = release)
# viral-viral
all_within_viral_interaction = fullInteractome(taxid = 10239, database = "IntActFTP", format = "tab27",
clean = TRUE, protein_only = TRUE,
MITABdata = IntAct, directory = directory,
releaseORdate = release)
HumanViralPPI = list(human_human = all_human_interaction, human_viral = all_viral_interaction, viral_viral = all_within_viral_interaction)
return(HumanViralPPI)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.