-
Notifications
You must be signed in to change notification settings - Fork 0
/
03_real-dends.qmd
118 lines (108 loc) · 4.08 KB
/
03_real-dends.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
---
title: "Discovering Focused Microgenre Communities: Dendrograms"
author: "Omar Lizardo"
date: "`r Sys.Date()`"
output:
html_document: default
---
# Setup
```{r setup}
knitr::opts_chunk$set(include=FALSE, echo = TRUE, warning = FALSE, message = FALSE)
require("dendextend")
require("here")
require("RColorBrewer")
```
```{r Loading link distance matrix and performing link clustering}
load(file= here("dat", "lclust-res.RData"))
```
# Dendrogram Plots from Link Clustered Data
```{r Plotting macrogenre dendrograms (1)}
k <- length(dend.macro$lower)
png(here("Plots", "Dend", "all-branches-macro.png"), height = 900, width = 1600)
d <- lclust.dend
d %>%
set("labels", c(rep("", nleaves(d)))) %>%
set("branches_k_color", value = brewer.pal(k, "Dark2"), k = k) %>%
set("branches_lwd", value = 3) %>%
plot(axes = FALSE) %>%
abline(h = 8, col="red", lty = 2, lwd = 3)
```
```{r Plotting macrogenre dendrograms (2)}
k <- length(dend.macro$lower)
png(here("Plots", "Dend", "all-branches-macro-labels.png"), height = 900, width = 1600)
d <- dend.macro$upper
d %>%
set("labels", dend.macro$lower %>% names) %>%
set("branches_k_color", value = brewer.pal(k, "Dark2")) %>%
set("branches_lwd", value = 4) %>%
set("labels_color", value = brewer.pal(k, "Dark2")) %>%
set("labels_cex", value = 2.5) %>%
plot(axes = FALSE)
abline(h = 8, col="red", lty = 2, lwd = 3)
```
```{r Plotting microgenre dendrograms (1)}
k <- length(dend.micro$lower)
png(here("Plots", "Dend", "all-branches-micro.png"), height = 900, width = 1600)
k <- length(dend.micro$lower)
d <- lclust.dend
d %>%
set("labels", c(rep("", nleaves(d)))) %>%
set("branches_k_color", value = brewer.pal(k, "Dark2"), k = k) %>%
set("branches_lwd", value = 3) %>%
plot(axes = FALSE) %>%
abline(h = 3, col="red", lty = 2, lwd = 3)
```
```{r Plotting microgenre dendrograms (2)}
k <- length(dend.micro$lower)
png(here("Plots", "Dend", "all-branches-micro-labels.png"), height = 900, width = 1600)
d <- dend.micro$upper
d %>%
set("labels", micro.g.names) %>%
set("branches_k_color", value = brewer.pal(k, "Dark2"), k = k) %>%
set("branches_lwd", value = 3) %>%
set("labels_color", value = brewer.pal(k, "Dark2")) %>%
set("labels_cex", value = 0.9) %>%
plot(axes = FALSE)
par(cex= 2.5)
title(xlab="", ylab="", main="") %>%
abline(h = 3, col="red", lty = 2, lwd = 3)
```
```{r Plotting genre-specific dendrograms (1)}
png(here("Plots", "Dend", "classic-rock-branches.png"), height = 900, width = 1600)
k <- n.micro["Classic_Rock"]
d <- dend.macro$lower$Classic_Rock
d %>%
set("labels", c(rep("", nleaves(d)))) %>%
set("branches_k_color", value = brewer.pal(k, "Dark2"), k = k) %>%
set("branches_lwd", value = 3) %>%
plot(axes = FALSE)
par(cex = 5)
title(xlab="", ylab="", main="Classic Rock") %>%
abline(h = 3, col="red", lty = 2, lwd = 3)
```
```{r Plotting genre-specific dendrograms (2)}
png(here("Plots", "Dend", "blues-branches.png"), height = 900, width = 1600)
k <- n.micro["Blues_RandB"]
d <- dend.macro$lower$Blues_RandB
d %>%
set("labels", c(rep("", nleaves(d)))) %>%
set("branches_k_color", value = brewer.pal(k, "Dark2"), k = k) %>%
set("branches_lwd", value = 3) %>%
plot(axes = FALSE)
par(cex = 5)
title(xlab="", ylab="", main="Blues/R&B") %>%
abline(h = 3, col="red", lty = 2, lwd = 3)
```
```{r Plotting genre-specific dendrograms (3)}
png(here("Plots", "Dend", "opera-branches.png"), height = 900, width = 1600)
k <- n.micro["Opera"]
d <- dend.macro$lower$Opera
d %>%
set("labels", c(rep("", nleaves(d)))) %>%
set("branches_k_color", value = brewer.pal(k, "Dark2"), k = k) %>%
set("branches_lwd", value = 3) %>%
plot(axes = FALSE)
par(cex = 5)
title(xlab="", ylab="", main="Opera") %>%
abline(h = 3, col="red", lty = 2, lwd = 3)
```