Skip to content

Instantly share code, notes, and snippets.

@jyfeather
Created November 8, 2015 19:33
Show Gist options
  • Save jyfeather/fed6b22e1c67006b40ae to your computer and use it in GitHub Desktop.
Save jyfeather/fed6b22e1c67006b40ae to your computer and use it in GitHub Desktop.
connectivity plot for Dr. Huang
4d41 544c 4142 2035 2e30 204d 4154 2d66
696c 652c 2050 6c61 7466 6f72 6d3a 204d
4143 4936 342c 2043 7265 6174 6564 206f
6e3a 2053 6174 204f 6374 2032 3420 3133
3a35 323a 3434 2032 3031 3520 2020 2020
2020 2020 2020 2020 2020 2020 2020 2020
2020 2020 2020 2020 2020 2020 2020 2020
2020 2020 0000 0000 0000 0000 0001 494d
0f00 0000 ba00 0000 789c ed57 6d0a 8020
0c9d 44d1 affe 7893 eed6 1d3a 52b7 3325
210a 2c61 5f36 7a21 c31f f9b6 37dc e604
009b 0718 a21d e1b0 097d decf 79b9 f82d
d176 71ad 1e44 e004 3842 e0e7 9088 c38a
561a 1ce7 9e4e 45dd 38e8 d825 b4ba 9f74
e5c0 c552 fa9b 432b 7e3c f92a 5101 6a81
f5a5 2627 d8bc d5f8 f873 b4c5 8185 956e
6fb5 1373 4033 1f94 f1f1 f4c1 3639 ca7a
d671 60ea 95fb d444 a07b 4f29 ef96 f55a
20a1 1525 47e9 2cfc 4cfe ce91 cea7 e2d0
accd 2148 bc28 5b9a fc2d a345 9d77 6dd3
6a28
setwd("./Downloads/")
# data input
library('R.matlab')
origin <- readMat("ecoli_50_dream3_50times50.mat")
input <- abs(origin$u)
# matrix figure with d3heatmap
library(d3heatmap)
library(scales)
palette <- c("white", "black")
breaks <- c(-1, 0, 1)
colorFunc <- col_bin(palette, bins = rescale(breaks))
d3heatmap(input, scale = "column", dendrogram = "none", na.rm = T,
colors = colorFunc)
# matrix figure with ggplot2
library(reshape2)
library(ggplot2)
melted <- melt(input)
melted$value <- as.factor(melted$value)
p <- ggplot(melted, aes(Var2, Var1)) + geom_tile(aes(fill = value), colour = "black") +
scale_fill_manual(values = c("white", "black"))
p <- p + theme_bw(base_size = 12) + labs(x = "", y = "") +
scale_x_continuous(breaks = c(1, seq(5, 50, by = 5))) +
scale_y_continuous(breaks = c(1, seq(5, 50, by = 5))) +
theme(legend.position = "none",
panel.grid.major = element_blank(), panel.grid.minor = element_blank())
plot(p)
# matrix plot with corrplot
library(corrplot)
corrplot(input)
# network figure
library(networkD3)
from <- c()
to <- c()
for (i in 1:50) {
for (j in 1:50) {
if (input[i,j] == -1) {
from <- c(from, j)
to <- c(to, i)
} else if (input[i,j] == 1) {
from <- c(from, i)
to <- c(to, j)
}
}
}
networkData <- data.frame(from, to)
simpleNetwork(networkData, fontSize = 11, zoom = T, opacity = 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment