Verified Commit 63be95ca authored by Laurent Modolo's avatar Laurent Modolo
Browse files

clustering : move r code into plot.R

parent 11d93c7c
Pipeline #346 failed with stage
in 1 minute and 33 seconds
pages:
stage: deploy
image: rocker/verse
image: rocker/r-rmd
script:
- mkdir -p public/img
- make
......
......@@ -154,31 +154,6 @@ weighted by $P$
## Cell to cell correlations
### Pearson $0.7992528$
```{r cor_pearson, include=F, echo=F, warning=F, message=F, cache = T}
library(tidyverse)
install.packages("copula")
library(copula)
cop <- normalCopula(param = 0.8, dim = 2)
x <- rMvdc(
1000,
mvdc(
cop,
margins = c("norm", "gamma"),
paramMargins = list(c(0, 1), c(3, 5))
)) %>%
tibble(
x1 = .[, 1],
x2 = .[, 2],
)
x %>%
ggplot(aes(x = x1, y = x2)) +
geom_point(alpha = 0) +
geom_density2d_filled() +
geom_smooth(method = "lm", se = F) +
theme_bw() +
theme(legend.position = "none")
ggsave("img/cor_pearson.pdf", width = 4, height = 4)
```
\begin{columns}
\column{0.5\textwidth}
......@@ -201,20 +176,6 @@ where:
### Spearman $0.8169925$
```{r cor_spearman, include=F, echo=F, warning=F, message=F, cache = T}
x %>%
mutate(
r1 = rank(x1),
r2 = rank(x2)
) %>%
ggplot(aes(x = r1, y = r2)) +
geom_point(alpha = 0) +
geom_density2d_filled() +
geom_smooth(method = "lm", se = F) +
theme_bw() +
theme(legend.position = "none")
ggsave("img/cor_spearman.pdf", width = 4, height = 4)
```
\begin{columns}
\column{0.5\textwidth}
......@@ -242,24 +203,6 @@ where:
## Cell to cell correlations
### Kendall $0.6231151$
```{r cor_kendall, include=F, echo=F, warning=F, message=F, cache = T}
x %>%
ggplot(aes(x = x1, y = x2)) +
geom_point(alpha = 0) +
geom_density2d_filled() +
theme_bw() +
geom_rect(aes(xmin = 0, ymin = 5, xmax = max(x1), ymax = max(x2)), color = "red", fill = NA) +
geom_rect(aes(xmax = 0, ymax = 5, xmin = min(x1), ymin = min(x2)), color = "red", fill = NA) +
geom_point(aes(x = 0, y = 5), size = 2) +
geom_label(aes(x = mean(c(0, max(x1))), y = mean(c(5, max(x2))), label = "concordant pairs"), color = "red") +
geom_label(aes(x = mean(c(0, min(x1))), y = mean(c(5, min(x2))), label = "concordant pairs"), color = "red") +
geom_label(aes(x = mean(c(0, min(x1))), y = mean(c(5, max(x2))), label = "discordant pairs")) +
geom_label(aes(x = mean(c(0, max(x1))), y = mean(c(5, min(x2))), label = "discordant pairs")) +
theme(legend.position = "none")
ggsave("img/cor_kendall.pdf", width = 4, height = 4)
```
\begin{columns}
\column{0.5\textwidth}
......
......@@ -112,3 +112,56 @@ KLMatrix <- KL(Prob)
# plot a heatmap of the corresponding KL matrix
heatmap(KLMatrix)
library(tidyverse)
install.packages("copula")
library(copula)
cop <- normalCopula(param = 0.8, dim = 2)
x <- rMvdc(
1000,
mvdc(
cop,
margins = c("norm", "gamma"),
paramMargins = list(c(0, 1), c(3, 5))
)) %>%
tibble(
x1 = .[, 1],
x2 = .[, 2],
)
x %>%
ggplot(aes(x = x1, y = x2)) +
geom_point(alpha = 0) +
geom_density2d_filled() +
geom_smooth(method = "lm", se = F) +
theme_bw() +
theme(legend.position = "none")
ggsave("img/cor_pearson.pdf", width = 4, height = 4)
x %>%
mutate(
r1 = rank(x1),
r2 = rank(x2)
) %>%
ggplot(aes(x = r1, y = r2)) +
geom_point(alpha = 0) +
geom_density2d_filled() +
geom_smooth(method = "lm", se = F) +
theme_bw() +
theme(legend.position = "none")
ggsave("img/cor_spearman.pdf", width = 4, height = 4)
x %>%
ggplot(aes(x = x1, y = x2)) +
geom_point(alpha = 0) +
geom_density2d_filled() +
theme_bw() +
geom_rect(aes(xmin = 0, ymin = 5, xmax = max(x1), ymax = max(x2)), color = "red", fill = NA) +
geom_rect(aes(xmax = 0, ymax = 5, xmin = min(x1), ymin = min(x2)), color = "red", fill = NA) +
geom_point(aes(x = 0, y = 5), size = 2) +
geom_label(aes(x = mean(c(0, max(x1))), y = mean(c(5, max(x2))), label = "concordant pairs"), color = "red") +
geom_label(aes(x = mean(c(0, min(x1))), y = mean(c(5, min(x2))), label = "concordant pairs"), color = "red") +
geom_label(aes(x = mean(c(0, min(x1))), y = mean(c(5, max(x2))), label = "discordant pairs")) +
geom_label(aes(x = mean(c(0, max(x1))), y = mean(c(5, min(x2))), label = "discordant pairs")) +
theme(legend.position = "none")
ggsave("img/cor_kendall.pdf", width = 4, height = 4)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment