Skip to content

Instantly share code, notes, and snippets.

@Vessy
Vessy / D3_network_LM.R
Created October 4, 2016 18:55
Plotting networks in R - an example how to plot a network and customize its appearance from R using networkD3 library
############################################################################################
############################################################################################
# Plotting networks in R - an example how to plot a network and
# customize its appearance using networkD3 library
############################################################################################
############################################################################################
# Clear workspace
# rm(list = ls())
############################################################################################
@Vessy
Vessy / RCy3_example1.R
Last active April 8, 2018 00:13
Network visualization and R - An example how to plot a network and customize its appearance in Cytoscape directly from R using the RCy3 package
############################################################################################
############################################################################################
# Plotting networks in R - an example how to plot a network and
# customize its appearance in Cytoscape directly from R using
# the RCy3 package
############################################################################################
############################################################################################
# Clear workspace
# rm(list = ls())
############################################################################################
@Vessy
Vessy / oneForMany.R
Last active May 14, 2016 17:39
Using eval to create a function that will be able to produce a data summary (using the plyr::ddply function) based on the user specified data frame, variables (that correspond to table column names) over which the data should be split and summarized (character vector), and a two-column table (data frame) which contains the specified name of the …
# Using eval to create a function that will be able to produce a data summary (using the plyr::ddply function)
# based on the user specified data frame, variables (that correspond to table column names) over which they
# want to split and summarize the data (character vector), and a two-column table (data frame) which contains
# the user specified name of the function used for summary (first column) and the function used for summary (second column)
#
# For more info, see http://www.vesnam.com/Rblog/one-function-to-run-them-all/
#
# Data, variable, and formulas used for data summary
ex1_df <- datasets::mtcars
@Vessy
Vessy / 3D_net.R
Created November 8, 2013 14:42
3D networks with Jmol
library("igraph")
rm(list = ls())
##########################################################################
# Read data
dataSet <- read.table("lesmis.txt", header = FALSE, sep = "\t")
# Create a graph. Use simplify to ensure that there are no duplicated edges or self loops
gD <- simplify(graph.data.frame(dataSet, directed=FALSE))
# Calculate degree for all nodes
@Vessy
Vessy / exampleForModEdge2HPD_HiveR.R
Last active October 13, 2018 09:14
An example how to plot networks and customize their appearance from R using HiveR package
library("igraph")
library("plyr")
library("HiveR")
library("RColorBrewer")
############################################################################################
rm(list = ls())
dataSet <- read.table("lesmis.txt", header = FALSE, sep = "\t")
############################################################################################
@Vessy
Vessy / mod.adj2HPD.R
Created July 22, 2013 15:26
A modified version of the "adj2HPD" function from the HiveR package. This function can create HivePlotData objects from any network type (not just from the bipartite ones)
mod.adj2HPD <- function (M = NULL, axis.cols = NULL, type = "2D", desc = NULL)
{
if (is.null(M))
stop("No adjacency matrix provided")
if (is.null(dimnames(M)))
stop("Adjacency matrix must have named dimensions")
lab1 <- unlist(dimnames(M)[1])
lab1 <- as.character(lab1)
lab2 <- unlist(dimnames(M)[2])
lab2 <- as.character(lab2)
@Vessy
Vessy / plotNetworksUsingGephi.R
Last active February 24, 2022 09:03
An example how to use R and rgexf package to create a .gexf file for network visualization in Gephi
# Plotting networks in R
# An example how to use R and rgexf package to create a .gexf file for network visualization in Gephi
############################################################################################
# Clear workspace
rm(list = ls())
# Load libraries
library("igraph")
library("plyr")
@Vessy
Vessy / plotNetworksRcytoscape.R
Last active December 19, 2015 19:18
An example how to plot networks and customize their appearance in Cytoscape directly from R using RCytoscape package
# Plotting networks in R
# An example how to plot networks and customize their appearance in Cytoscape directly from R, using RCytoscape package
############################################################################################
# Clear workspace
rm(list = ls())
# Load libraries
library("igraph")
library("plyr")
@Vessy
Vessy / arrangeMusic.R
Created January 22, 2013 02:32
Read .mp3 files from a given directory, compare songs, and play them in order of similarity
#Read .mp3 files from a given directory, compare songs, and play them in order of similarity
library("plyr")
library("tuneR")
library("seewave")
library("compiler")
library("foreach")
library("doMC")
@Vessy
Vessy / transcribeMusic.R
Created January 7, 2013 02:16
Transcribe audio file into music notes using the tuneR library
library("tuneR")
transcribeMusic <- function(wavFile, widthSample = 4096, expNotes = NULL)
{
#See details about the wavFile, plot it, and/or play it
#summary(wavFile)
plot(wavFile)
#play(wavFile, "/usr/bin/mplayer")
perioWav <- periodogram(wavFile, width = widthSample)