Skip to content

Instantly share code, notes, and snippets.

View cannin's full-sized avatar

Augustin Luna cannin

View GitHub Profile
@cannin
cannin / RunColorExistingCytoscapeNetworkExample.R
Last active August 29, 2015 14:02
An example of programmatically coloring nodes/edges of an existing Cytoscape network with R
# An example of programmatically coloring nodes/edges of an existing Cytoscape network with R
library(RCytoscape)
library(RColorBrewer)
# Generate demo Cytoscape network
cy <- CytoscapeConnection()
cw <- new.CytoscapeWindow("demo", graph=makeSimpleGraph(), overwriteWindow=TRUE)
displayGraph(cw)
layoutNetwork(cw)
@cannin
cannin / installPackages.R
Last active February 29, 2024 19:02
Install/update necessary packages from CRAN, Bioconductor, GitHub, or local source given a vector of strings with names of packages or DCF-based parameter file
#' Install/update necessary packages from CRAN, Bioconductor, GitHub, or local sources
#'
#' @param file a file with packages; overrides packages parameter
#' @param packages a vector of strings with names of packages from CRAN, Bioconductor, GitHub
#' @param updatePackages whether to update existing packages (Default: FALSE)
#' @param dryRun whether to test for missing packages (Default: FALSE)
#'
#' @example
#' \dontrun {
#' source("https://gist.githubusercontent.com/cannin/6b8c68e7db19c4902459/raw/installPackages.R")
@cannin
cannin / convertVectorCallToString.R
Last active August 29, 2015 14:03
Convert R vector into a call object and then convert the "call" object to a character string; this was useful for converting a vector back into code when generating knitr reports using brew
# Convert R vector into a call object and then convert the "call" object to a character string
# This was useful for converting a vector back into code when generating knitr reports using brew
tmp <- c("A", "B", "C")
deparse(do.call(call, as.list(c("c", tmp))))
# [1] "c(\"A\", \"B\", \"C\")"
@cannin
cannin / checkTestCoverage.R
Created November 2, 2014 16:17
Check the test coverage for R scripts
#' Extract calls to functions
#'
#' Extracts function and file names for functions from a set of files
#'
#' @param path a directory path to files to be examined
#' @param regexp a regular expression to find function calls
#' @param fileRegexp a regular expression for files to be examined (e.g. '.R$')
#' @param verbose a boolean whether to print debugging information
#'
#' @return a data.frame with two columns: 'function', the name of the function and
@cannin
cannin / jenkins_build.R
Last active September 18, 2016 19:32
Generate testthat TAP results compatible with the Jenkins continuous integration TAP plugin
setRepositories(ind=1:6)
options(repos="http://cran.rstudio.com/")
if(!require(devtools)) install.packages("devtools")
if(!require(testthat)) install.packages("testthat")
if(Sys.getenv("TEST_DIR") != "") {
testDir <- Sys.getenv("TEST_DIR")
} else {
testDir <- "inst/tests"
@cannin
cannin / deployAppWithData.R
Last active August 29, 2015 14:11
Deploys a R Shiny app, but first copies the RData from the data folder
if (!require("devtools")) install.packages("devtools")
library(devtools)
if (!require("shinyapps")) devtools::install_github("rstudio/shinyapps")
library(shinyapps)
# Set working directory to root directory of package
#setwd(TOP_LEVEL_PACKAGE_DIRECTORY)
# Copy data from data folder
@cannin
cannin / jenkins_build_install.R
Last active January 6, 2017 18:44
Generate testthat TAP results compatible with the Jenkins continuous integration TAP plugin
# PARAMETERS
#cfg <- '{"url":"https://devbotcc:devbotcc@bitbucket.org/mil2041/netboxr.git", "quick":true, "dependencies":true}'
#pkg <- "netboxr"
#url <- Sys.getenv("URL")
pkg <- Sys.getenv("PKG")
cfg <- Sys.getenv("CFG")
# FUNCTIONS
processTap <- function(inputFile) {
library(devtools)
install(".")
@cannin
cannin / basicTraversal_3.groovy
Last active May 10, 2021 12:53
BioPAX Tutorial; Examples from the Paxtools User's Guide. (PubMed ID: 24068901 Link: https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1003194)
//BASIC TRAVERSAL
// Get names for all elements in a BioPAX OWL file and then for just Proteins
import org.biopax.paxtools.io.BioPAXIOHandler;
import org.biopax.paxtools.io.SimpleIOHandler;
import org.biopax.paxtools.model.Model;
import org.biopax.paxtools.model.BioPAXElement;
import org.biopax.paxtools.model.level3.Protein;
// Load a sample test BioPAX File via Simple IO Handler
InputStream f = new FileInputStream(new File("data/biopax3-short-metabolic-pathway.owl"));
@cannin
cannin / pcviz.properties
Last active September 3, 2015 12:49 — forked from armish/pcviz.properties
pcviz.properties
# Pathway commons
pathwaycommons.url=http://www.pathwaycommons.org/pc2/
# BioGene
biogene.url=http://cbio.mskcc.org/biogene/
biogene.format=json
# iHop
ihop.url=http://www.ihop-net.org/UniPub/iHOP/