-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
77 lines (56 loc) · 2.42 KB
/
README.Rmd
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
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# clap <img src="man/figures/logo.png" align="right" width = 150 />
<!-- badges: start -->
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/clap)](https://cran.r-project.org/package=clap)
[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-stable-green.svg)](https://lifecycle.r-lib.org/articles/stages.html)
<!-- badges: end -->
## clap: Detecting Class Overlapping Regions in Multidimensional Data
The issue of overlapping regions in multidimensional data arises when different classes or clusters share similar feature representations, making it challenging to delineate distinct boundaries between them accurately. This package provides methods for detecting and visualizing these overlapping regions using partitional clustering techniques based on nearest neighbor distances.
## Installation
You can install the development version of clap from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("pridiltal/clap")
```
## Installation
You can install the development version of clap from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("pridiltal/clap")
```
## Example
```{r}
library(clap)
class1 <- matrix(rnorm(100, mean = 0, sd = 1), ncol = 2) + matrix(rep(c(1, 1), each = 50), ncol = 2)
class2 <- matrix(rnorm(100, mean = 0, sd = 1), ncol = 2) + matrix(rep(c(-1, -1), each = 50), ncol = 2)
datanew <- rbind(class1, class2)
training <- data.frame(datanew,
class = factor(c(rep(1, 50), rep(2, 50))))
# Plot the dummy data to visualize overlaps
p <- ggplot2::ggplot(training, ggplot2::aes(x = X1, y = X2, color = class)) +
ggplot2::geom_point() +
ggplot2::labs(title = "Dummy Data with Overlapping Classes")
print(p)
# Perform clustering
cluster_result <- perform_clustering(training, class_column = class)
# Compute cluster composition
composition <- compute_cluster_composition(cluster_result)
# Extract IDs to numeric vector
ids_vector <- extract_ids_vector(composition)
# Subset data based on extracted IDs
overlapdata <- training[ids_vector, ]
# Plot overlapping data points
p2 <- p + ggplot2::geom_point(data = overlapdata, ggplot2::aes(X1, X2), colour = "black")
(p2)
```