Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • master
  • v1.0.0
2 results

Target

Select target project
  • general/dsml/dialogue-term-extraction-using-transfer-learning-and-topological-data-analysis-public
1 result
Select Git revision
  • master
  • v1.0.0
2 results
Show changes
Commits on Source (4)
Showing
with 36319 additions and 0 deletions
File added
This diff is collapsed.
File added
This diff is collapsed.
File added
File added
File added
This diff is collapsed.
File added
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
geom_point()
# Save plot as pdf
point_cloud_file_name = str_glue('point_cloud_{round(prox, 2)}.pdf')
ggsave(point_cloud_file_name)
# fix a proximity for a Vietoris complex
prox <- c(0.5, 1.0, 1.5)
# visualize disks of fixed radii
# Use option theme_void() to get rid of all axis labels
# https://stackoverflow.com/questions/35090883/remove-all-of-x-axis-labels-in-ggplot
p_d <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
geom_point()
# Save plot as pdf
# point_cloud_file_name = str_glue('point_cloud_{round(prox, 2)}.pdf')
# ggsave(point_cloud_file_name)
# visualize the Vietoris complex for this proximity
p_sc <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
# simplicial_complex_file_name = str_glue('simplicial_complex_{round(prox, 2)}.pdf')
# ggsave(simplicial_complex_file_name)
p_overlay <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
# overlay_file_name = str_glue('overlay_{round(prox, 2)}.pdf')
# ggsave(overlay_file_name)
# combine the plots
gridExtra::grid.arrange(
p_d, p_overlay,
layout_matrix = matrix(c(1, 2), nrow = 1)
)
# fix a proximity for a Vietoris complex
prox <- 0.1
# visualize disks of fixed radii
# Use option theme_void() to get rid of all axis labels
# https://stackoverflow.com/questions/35090883/remove-all-of-x-axis-labels-in-ggplot
p_d <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
geom_point()
# Save plot as pdf
point_cloud_file_name = str_glue('point_cloud_{round(prox, 2)}.pdf')
ggsave(point_cloud_file_name)
# visualize the Vietoris complex for this proximity
p_sc <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
simplicial_complex_file_name = str_glue('simplicial_complex_{round(prox, 2)}.pdf')
ggsave(simplicial_complex_file_name)
p_overlay <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
overlay_file_name = str_glue('overlay_{round(prox, 2)}.pdf')
ggsave(overlay_file_name)
# combine the plots
gridExtra::grid.arrange(
p_d, p_overlay,
layout_matrix = matrix(c(1, 2), nrow = 1)
)
# fix a proximity for a Vietoris complex
prox <- 0.5
# visualize disks of fixed radii
# Use option theme_void() to get rid of all axis labels
# https://stackoverflow.com/questions/35090883/remove-all-of-x-axis-labels-in-ggplot
p_d <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
geom_point()
# Save plot as pdf
point_cloud_file_name = str_glue('point_cloud_{round(prox, 2)}.pdf')
ggsave(point_cloud_file_name)
# visualize the Vietoris complex for this proximity
p_sc <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
simplicial_complex_file_name = str_glue('simplicial_complex_{round(prox, 2)}.pdf')
ggsave(simplicial_complex_file_name)
p_overlay <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
overlay_file_name = str_glue('overlay_{round(prox, 2)}.pdf')
ggsave(overlay_file_name)
# combine the plots
gridExtra::grid.arrange(
p_d, p_overlay,
layout_matrix = matrix(c(1, 2), nrow = 1)
)
# fix a proximity for a Vietoris complex
prox <- 1.0
# visualize disks of fixed radii
# Use option theme_void() to get rid of all axis labels
# https://stackoverflow.com/questions/35090883/remove-all-of-x-axis-labels-in-ggplot
p_d <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
geom_point()
# Save plot as pdf
point_cloud_file_name = str_glue('point_cloud_{round(prox, 2)}.pdf')
ggsave(point_cloud_file_name)
# visualize the Vietoris complex for this proximity
p_sc <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
simplicial_complex_file_name = str_glue('simplicial_complex_{round(prox, 2)}.pdf')
ggsave(simplicial_complex_file_name)
p_overlay <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
overlay_file_name = str_glue('overlay_{round(prox, 2)}.pdf')
ggsave(overlay_file_name)
# combine the plots
gridExtra::grid.arrange(
p_d, p_overlay,
layout_matrix = matrix(c(1, 2), nrow = 1)
)
# fix a proximity for a Vietoris complex
prox <- 1.5
# visualize disks of fixed radii
# Use option theme_void() to get rid of all axis labels
# https://stackoverflow.com/questions/35090883/remove-all-of-x-axis-labels-in-ggplot
p_d <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
geom_point()
# Save plot as pdf
point_cloud_file_name = str_glue('point_cloud_{round(prox, 2)}.pdf')
ggsave(point_cloud_file_name)
# visualize the Vietoris complex for this proximity
p_sc <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
simplicial_complex_file_name = str_glue('simplicial_complex_{round(prox, 2)}.pdf')
ggsave(simplicial_complex_file_name)
p_overlay <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
overlay_file_name = str_glue('overlay_{round(prox, 2)}.pdf')
ggsave(overlay_file_name)
# combine the plots
gridExtra::grid.arrange(
p_d, p_overlay,
layout_matrix = matrix(c(1, 2), nrow = 1)
)
# fix a proximity for a Vietoris complex
prox <- 1.9
# visualize disks of fixed radii
# Use option theme_void() to get rid of all axis labels
# https://stackoverflow.com/questions/35090883/remove-all-of-x-axis-labels-in-ggplot
p_d <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
geom_point()
# Save plot as pdf
point_cloud_file_name = str_glue('point_cloud_{round(prox, 2)}.pdf')
ggsave(point_cloud_file_name)
# visualize the Vietoris complex for this proximity
p_sc <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
simplicial_complex_file_name = str_glue('simplicial_complex_{round(prox, 2)}.pdf')
ggsave(simplicial_complex_file_name)
p_overlay <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
overlay_file_name = str_glue('overlay_{round(prox, 2)}.pdf')
ggsave(overlay_file_name)
# combine the plots
gridExtra::grid.arrange(
p_d, p_overlay,
layout_matrix = matrix(c(1, 2), nrow = 1)
)
# fix a proximity for a Vietoris complex
prox <- 2.0
# visualize disks of fixed radii
# Use option theme_void() to get rid of all axis labels
# https://stackoverflow.com/questions/35090883/remove-all-of-x-axis-labels-in-ggplot
p_d <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
geom_point()
# Save plot as pdf
point_cloud_file_name = str_glue('point_cloud_{round(prox, 2)}.pdf')
ggsave(point_cloud_file_name)
# visualize the Vietoris complex for this proximity
p_sc <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
simplicial_complex_file_name = str_glue('simplicial_complex_{round(prox, 2)}.pdf')
ggsave(simplicial_complex_file_name)
p_overlay <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
overlay_file_name = str_glue('overlay_{round(prox, 2)}.pdf')
ggsave(overlay_file_name)
# combine the plots
gridExtra::grid.arrange(
p_d, p_overlay,
layout_matrix = matrix(c(1, 2), nrow = 1)
)
# fix a proximity for a Vietoris complex
prox <- 1.7
# visualize disks of fixed radii
# Use option theme_void() to get rid of all axis labels
# https://stackoverflow.com/questions/35090883/remove-all-of-x-axis-labels-in-ggplot
p_d <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
geom_point()
# Save plot as pdf
point_cloud_file_name = str_glue('point_cloud_{round(prox, 2)}.pdf')
ggsave(point_cloud_file_name)
# visualize the Vietoris complex for this proximity
p_sc <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
simplicial_complex_file_name = str_glue('simplicial_complex_{round(prox, 2)}.pdf')
ggsave(simplicial_complex_file_name)
p_overlay <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
overlay_file_name = str_glue('overlay_{round(prox, 2)}.pdf')
ggsave(overlay_file_name)
# combine the plots
gridExtra::grid.arrange(
p_d, p_overlay,
layout_matrix = matrix(c(1, 2), nrow = 1)
)
# fix a proximity for a Vietoris complex
prox <- 1.6
# visualize disks of fixed radii
# Use option theme_void() to get rid of all axis labels
# https://stackoverflow.com/questions/35090883/remove-all-of-x-axis-labels-in-ggplot
p_d <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
geom_point()
# Save plot as pdf
point_cloud_file_name = str_glue('point_cloud_{round(prox, 2)}.pdf')
ggsave(point_cloud_file_name)
# visualize the Vietoris complex for this proximity
p_sc <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
simplicial_complex_file_name = str_glue('simplicial_complex_{round(prox, 2)}.pdf')
ggsave(simplicial_complex_file_name)
p_overlay <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
overlay_file_name = str_glue('overlay_{round(prox, 2)}.pdf')
ggsave(overlay_file_name)
# combine the plots
gridExtra::grid.arrange(
p_d, p_overlay,
layout_matrix = matrix(c(1, 2), nrow = 1)
)
File added
---
title: "R Notebook"
output: html_notebook
---
This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Cmd+Shift+Enter*.
Add a new chunk by clicking the *Insert Chunk* button on the toolbar or by pressing *Cmd+Option+I*.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the *Preview* button or press *Cmd+Shift+K* to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike *Knit*, *Preview* does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.
```{r}
library(ggplot2)
# attach *ggtda*
library(ggtda)
```
```{r}
# generate the point cloud data
n <- 36; sd <- .2
set.seed(0)
first_column <- c(1.0, 2.0, 1.0, 2.0)
second_column <- c(1.0, 1.0, 2.0, 2.0)
d <- data.frame(
first_column,
second_column
)
# compute the persistent homology
ph <- as.data.frame(ripserr::vietoris_rips(as.matrix(d), dim = 1))
print(head(ph, n = 12))
ph <- transform(ph, dim = as.factor(dimension))
```
```{r}
# fix a proximity for a Vietoris complex
prox <- 1.5
# visualize disks of fixed radii
# Use option theme_void() to get rid of all axis labels
# https://stackoverflow.com/questions/35090883/remove-all-of-x-axis-labels-in-ggplot
p_d <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
geom_point()
# Save plot as pdf
ggsave("diamonds3.pdf")
# visualize the Vietoris complex for this proximity
p_sc <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
coord_fixed() +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# combine the plots
gridExtra::grid.arrange(
p_d, p_sc,
layout_matrix = matrix(c(1, 2), nrow = 1)
)
```
```{r}
# visualize the persistence data, indicating cutoffs at this proximity
p_bc <- ggplot(ph,
aes(start = birth, end = death, colour = dim)) +
theme_barcode() +
geom_barcode() +
labs(x = "Diameter", y = "Homological features") +
geom_vline(xintercept = prox, color = "darkgoldenrod", linetype = "dashed")
p_pd <- ggplot(ph) +
theme_persist() +
coord_fixed() +
stat_persistence(aes(start = birth, end = death, colour = dim, shape = dim)) +
geom_abline(intercept = 0, slope = 1, color = "darkgray") +
labs(x = "Birth", y = "Death") +
lims(x = c(0, 0.8), y = c(0, NA)) +
geom_point(data = data.frame(x = prox), aes(x, x),
colour = "darkgoldenrod", shape = "diamond", size = 4)
# combine the plots
gridExtra::grid.arrange(
p_bc, p_pd,
layout_matrix = matrix(c(1, 2), nrow = 1)
)
```
---
title: "R Notebook"
output: html_notebook
---
This is an [R Markdown](http://rmarkdown.rstudio.com) Notebook. When you execute code within the notebook, the results appear beneath the code.
Try executing this chunk by clicking the *Run* button within the chunk or by placing your cursor inside it and pressing *Cmd+Shift+Enter*.
Add a new chunk by clicking the *Insert Chunk* button on the toolbar or by pressing *Cmd+Option+I*.
When you save the notebook, an HTML file containing the code and output will be saved alongside it (click the *Preview* button or press *Cmd+Shift+K* to preview the HTML file).
The preview shows you a rendered HTML copy of the contents of the editor. Consequently, unlike *Knit*, *Preview* does not run any R code chunks. Instead, the output of the chunk when it was last run in the editor is displayed.
```{r}
library(ggplot2)
# attach *ggtda*
library(ggtda)
library(stringr)
```
```{r}
# generate the point cloud data
# noisy circle
n <- 36; sd <- .2
set.seed(0)
t <- stats::runif(n = n, min = 0, max = 2*pi)
d <- data.frame(
first_column = cos(t) + stats::rnorm(n = n, mean = 0, sd = sd),
second_column = sin(t) + stats::rnorm(n = n, mean = 0, sd = sd)
)
# compute the persistent homology
ph <- as.data.frame(ripserr::vietoris_rips(as.matrix(d), dim = 1))
print(head(ph, n = 12))
ph <- transform(ph, dim = as.factor(dimension))
```
```{r}
# fix a proximity for a Vietoris complex
prox <- 1.6
# visualize disks of fixed radii
# Use option theme_void() to get rid of all axis labels
# https://stackoverflow.com/questions/35090883/remove-all-of-x-axis-labels-in-ggplot
p_d <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
geom_point()
# Save plot as pdf
point_cloud_file_name = str_glue('point_cloud_{round(prox, 2)}.pdf')
ggsave(point_cloud_file_name)
# visualize the Vietoris complex for this proximity
p_sc <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
simplicial_complex_file_name = str_glue('simplicial_complex_{round(prox, 2)}.pdf')
ggsave(simplicial_complex_file_name)
p_overlay <- ggplot(d, aes(x = first_column, y = second_column)) +
theme_bw() +
theme(axis.title.x=element_blank(),
axis.text.x=element_blank(),
axis.ticks.x=element_blank()) +
theme(axis.title.y=element_blank(),
axis.text.y=element_blank(),
axis.ticks.y=element_blank()) +
coord_fixed() +
stat_disk(radius = prox/2, fill = "aquamarine3") +
stat_vietoris2(diameter = prox, fill = "darkgoldenrod") +
stat_vietoris1(diameter = prox, alpha = .25) +
stat_vietoris0()
# Save plot as pdf
overlay_file_name = str_glue('overlay_{round(prox, 2)}.pdf')
ggsave(overlay_file_name)
# combine the plots
gridExtra::grid.arrange(
p_d, p_overlay,
layout_matrix = matrix(c(1, 2), nrow = 1)
)
```
```{r}
# visualize the persistence data, indicating cutoffs at this proximity
p_bc <- ggplot(ph,
aes(start = birth, end = death, colour = dim)) +
theme_barcode() +
geom_barcode() +
labs(x = "Diameter", y = "Homological features") +
geom_vline(xintercept = prox, color = "darkgoldenrod", linetype = "dashed")
p_pd <- ggplot(ph) +
theme_persist() +
coord_fixed() +
stat_persistence(aes(start = birth, end = death, colour = dim, shape = dim)) +
geom_abline(intercept = 0, slope = 1, color = "darkgray") +
labs(x = "Birth", y = "Death") +
lims(x = c(0, 0.8), y = c(0, NA)) +
geom_point(data = data.frame(x = prox), aes(x, x),
colour = "darkgoldenrod", shape = "diamond", size = 4)
# combine the plots
gridExtra::grid.arrange(
p_bc, p_pd,
layout_matrix = matrix(c(1, 2), nrow = 1)
)
```
This diff is collapsed.
File added
File added