@@ -116,12 +116,14 @@ peak_tbl <- tibble(dt = bw_400hz$dt[peaks[, 2]],
116
116
prominence = proms,
117
117
is_beat = dist_max <= dist_thr)
118
118
119
- regionsample <- filter(bw_400hz, region_id == 6)
119
+ regionsample <- filter(bw_400hz, region_id == 6) %>%
120
+ mutate(secs = as.numeric(dt - min(dt), unit = "secs"))
120
121
peaksample <- filter(peak_tbl, between(dt,
121
122
first(regionsample$dt),
122
123
last(regionsample$dt))) %>%
123
124
arrange(dt) %>%
124
- mutate(peak_lbl = seq(n()))
125
+ mutate(peak_lbl = seq(n()),
126
+ secs = as.numeric(dt - min(regionsample$dt)))
125
127
126
128
max_height <- max(peaks[, 1])
127
129
thr_curve <- tibble(
@@ -131,17 +133,16 @@ thr_curve <- tibble(
131
133
) %>%
132
134
filter(height <= max_height, prominence <= max_height)
133
135
134
- pA <- ggplot(regionsample, aes(dt , jerk_smooth)) +
136
+ pA <- ggplot(regionsample, aes(secs , jerk_smooth)) +
135
137
geom_line() +
136
138
geom_point(aes(y = height, color = is_beat), data = peaksample) +
137
139
geom_text(aes(y = height, label = peak_lbl),
138
140
data = peaksample,
139
141
vjust = -0.3) +
140
142
scale_color_manual(values = c("red", "blue")) +
141
- labs(x = "", y = "Y") +
143
+ labs(x = "Seconds ", y = "Y") +
142
144
theme_classic(base_size = 10) +
143
- theme(axis.title.x = element_blank(),
144
- legend.position = "FALSE")
145
+ theme(legend.position = "FALSE")
145
146
146
147
pB <- ggplot(peaksample, aes(height, prominence, color = is_beat)) +
147
148
geom_point() +
@@ -171,5 +172,10 @@ pD <- ggplot(peak_tbl, aes(height, prominence)) +
171
172
theme_classic(base_size = 10) +
172
173
theme(legend.position = "FALSE")
173
174
174
- cowplot::plot_grid(pA, pB, pC, pD, ncol = 2, labels = "AUTO")
175
+ # Figure S1 requires manual adjustments. Save to .svg, edit in Inkscape, then
176
+ # export back to PNG and insert here.
177
+ S1 <- cowplot::plot_grid(pA, pB, pC, pD, ncol = 2, labels = "AUTO")
178
+ ggsave(here::here("analysis/figures/S1.svg"), S1)
179
+ cowplot::ggdraw() +
180
+ cowplot::draw_image(here::here("analysis/figures/S1_edited.svg"))
175
181
```
0 commit comments