## R version 3.5 or later if (!requireNamespace("BiocManager", quietly = TRUE)) install.packages("BiocManager") if("biomaRt" %in% rownames(installed.packages()) == FALSE) { BiocManager::install('biomaRt') } if("jsonlite" %in% rownames(installed.packages()) == FALSE) { BiocManager::install('jsonlite') } if("httr" %in% rownames(installed.packages()) == FALSE) { BiocManager::install('httr') } library(biomaRt) library(jsonlite) library(httr) # PAGERCOV_ANALYSIS is a function connected to PAGER api to perform hypergeometric test and retrieve enriched PAGs associated to a list of genes # The input parameters are: # 1.dir: the directory of output file. # 2.filename: the name of the output file. # 3.markers: a list of gene symbols. # 4.type: a list of PAG types consisting of 'P', 'A' or 'G' # 5.minSize: the allowed minimum size of PAG genes # 6.maxSize: the allowed maximum size of PAG genes # 7.similarity: the similarity score cutoff # 8.overlap: the allowed minimum overlap genes # 9.nCoCo: the minimum nCoCo score # 10.pValue: p-value cutoff # 11.FDR: false discovery rate # 12.source: a list of sources refered to 'http://discovery.informatics.uab.edu/PAGER-COV/index.php/pages/help' PAGERCOV_ANALYSIS = function(dir = './', fileName = 'test.txt', markers = c('BRCA1','BRCA2'), type = c("P","A","G"), minSize = 2, maxSize = 5000, similarity = 0.05, overlap = 1, nCoCo = 0, pValue = 0.05, FDR = 0.05, Species = 'All', source = c('PubChem','PAGER-MSigDB','PAGER-GOA','PAGER-GOA_AGG', 'PAGER-GAD','PAGER-Pfam','PAGER-GeneSigDB','PAGER-Protein Lounge', 'PAGER-Spike','PAGER-PheWAS','PAGER-PharmGKB','PAGER-Reactome', 'PAGER-BioCarta','PAGER-GWAS Catalog','PAGER-KEGG','PAGER-NGS Catalog', 'PAGER-DSigDB','PAGER-GTEx','PAGER-NCI-Nature Curated','PAGER-WikiPathway', 'Am J Respir Crit Care Med','Microbiology and Molecular Biology Reviews', 'Zenodo','Mouse Genome Informatics Database','Nature Cell Discovery', 'GenBank/UniProt','Cell','The Annual Review of Cell and Developmental Biology', 'Nature','Drugbank','Nature Medicine','Cell Host and Microbe','bioRxiv' )){ url = "http://discovery.informatics.uab.edu/PAGER-COV/index.php/geneset/pagerapi" marker_str = NULL marker_str = paste0(as.matrix(markers),collapse = "%20") source_str = NULL source_str = paste0(as.matrix(source),collapse = "%20") contnt <- list( genes = marker_str, type = type, ge = minSize, le = maxSize, sim = similarity, olap = overlap, cohesion = nCoCo, pvalue = pValue, FDR = FDR, organism=Species, source=source_str ) req <- httr::POST(url, body=contnt ); json <- httr::content(req, as = "text") result = fromJSON(json) write.table(result,paste0(dir,fileName), row.names = F, quote =F,col.names = T,sep="\t") return(result) }