library(igraph)
## Warning: package 'igraph' was built under R version 4.3.3
##
## Attaching package: 'igraph'
## The following objects are masked from 'package:stats':
##
## decompose, spectrum
## The following object is masked from 'package:base':
##
## union
library(circlize)
## Warning: package 'circlize' was built under R version 4.3.3
## ========================================
## circlize version 0.4.16
## CRAN page: https://cran.r-project.org/package=circlize
## Github page: https://github.com/jokergoo/circlize
## Documentation: https://jokergoo.github.io/circlize_book/book/
##
## If you use it in published research, please cite:
## Gu, Z. circlize implements and enhances circular visualization
## in R. Bioinformatics 2014.
##
## This message can be suppressed by:
## suppressPackageStartupMessages(library(circlize))
## ========================================
##
## Attaching package: 'circlize'
## The following object is masked from 'package:igraph':
##
## degree
library(GGally)
## Warning: package 'GGally' was built under R version 4.3.3
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 4.3.3
## Registered S3 method overwritten by 'GGally':
## method from
## +.gg ggplot2
library(networkD3)
## Warning: package 'networkD3' was built under R version 4.3.3
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:igraph':
##
## as_data_frame, groups, union
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(circlize)
library(edgebundleR)
## Warning: package 'edgebundleR' was built under R version 4.3.3
library(ggraph)
## Warning: package 'ggraph' was built under R version 4.3.3
library(ggplot2)
library(packcircles)
## Warning: package 'packcircles' was built under R version 4.3.3
chordDiagram(as.matrix(mtcars), transparency = 0.5)
title("Chord Diagram - 21MIC0065")

set.seed(1)
data <- matrix(sample(0:1, 100, replace=TRUE, prob=c(0.8,0.2)), nc=10)
network <- graph_from_adjacency_matrix(data , mode='undirected', diag=F )
## Warning: The `adjmatrix` argument of `graph_from_adjacency_matrix()` must be symmetric
## with mode = "undirected" as of igraph 1.6.0.
## ℹ Use mode = "max" to achieve the original behavior.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
par(mar=c(0,0,0,0))
plot(network, main="Network - 21MIC0065")

links <- data.frame(
source=c("group_A","group_A", "group_B", "group_C", "group_C", "group_E"),
target=c("group_C","group_D", "group_E", "group_F", "group_G", "group_H"),
value=c(2,3, 2, 3, 1, 3)
)
nodes <- data.frame(
name=c(as.character(links$source),
as.character(links$target)) %>% unique()
)
links$IDsource <- match(links$source, nodes$name)-1
links$IDtarget <- match(links$target, nodes$name)-1
p <- sankeyNetwork(Links = links, Nodes = nodes,
Source = "IDsource", Target = "IDtarget",
Value = "value", NodeID = "name",
sinksRight=FALSE)
p # we can't give title to sankey diagram
d1 <- data.frame(from="root", to=paste("category", seq(1,5), sep=""))
d2 <- data.frame(from=rep(d1$to, each=3), to=paste("subcategory", seq(1,15), sep="_"))
hierarchy <- rbind(d1, d2)
vertices <- data.frame(name = unique(c(as.character(hierarchy$from), as.character(hierarchy$to))))
mygraph <- graph_from_data_frame(hierarchy, vertices=vertices)
plot(mygraph, vertex.label="", edge.arrow.size=0, vertex.size=2, main = "Edge bundling graph - 21MIC0065")

mygraph <- graph_from_data_frame(links)
arc <- ggraph(mygraph, layout="linear") +
geom_edge_arc(edge_colour="black", edge_alpha=0.3, edge_width=0.2) +
geom_node_point( color="#69b3a2", size=5) +
geom_node_text( aes(label=name), repel = FALSE, size=8, color="#69b3a2", nudge_y=-0.1) +
theme_void() +
theme(
legend.position="none",
plot.margin=unit(rep(2,4), "cm")
) +
ggtitle("Arc Diagram - 21MIC0065")
arc

ggparcoord(iris, columns = 1:4, groupColumn = 5, title = "Parallel Coordinates Plot - 21MIC0065")

data <- data.frame(group=paste("Group", letters[1:20]), value=sample(seq(1,100),20))
packing <- circleProgressiveLayout(data$value, sizetype='area')
data <- cbind(data, packing)
dat.gg <- circleLayoutVertices(packing, npoints=50)
ggplot() +
geom_polygon(data = dat.gg, aes(x, y, group = id, fill=as.factor(id)), colour = "black", alpha = 0.6) +
geom_text(data = data, aes(x, y, size=value, label = group)) +
scale_size_continuous(range = c(1,4)) +
theme_void() +
theme(legend.position="none") +
coord_equal() +
ggtitle("Circle Packing - 21MIC0065")

dend <- as.dendrogram(hclust(dist(mtcars)))
plot(dend, main = "Dendrogram - 21MIC0065")
