#!/usr/bin/env Rscript
## ---- inputs
root <- "~/projects/Uezu2016"
# load project's data
devtools::load_all(root)
data(ipsd)
## ---- imports
library(dplyr)
library(data.table)
# load mouse PPI dataset
data(musInteractome,package="getPPIs")
## ---- collect ppis (edges)
# keep interactions from mouse human and rat
os_keep <- c(9606, 10116, 10090)
# subset the data using dplyr's pipe %>% and filter
edges <- musInteractome %>%
filter(osEntrezA %in% ipsd & osEntrezB %in% ipsd) %>%
filter(Interactor_A_Taxonomy %in% os_keep) %>%
dplyr::select(osEntrezA,osEntrezB) %>% mutate(weight=1)
## ---- convert ppi_df to adjm
library(igraph)
G <- graph_from_data_frame(edges,directed=FALSE)
g <- simplify(G)
# convert to adjm with igraph's as_adjacency_matrix
A <- as_adjacency_matrix(g)
adjm <- as.matrix(A)
ggplotScaleFreeFit(apply(adjm,1,sum))
ggcorrplot(adjm)
m <- matrix(as.numeric(runif(100) > 0.9), ncol = 10)
# create random sparse matrix
library(SparseM)
hc <- hclust(as.dist(1-adjm))
idx = idy = hc$order
pdf("ipsd_matrix.pdf")
image(as.matrix.csr(adjm[idx,idy]))
dev.off()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.