Skip to content

Commit

Permalink
Merge pull request #9 from stemangiola/convert-to-vectorial
Browse files Browse the repository at this point in the history
Convert to vectorial
  • Loading branch information
stemangiola authored Dec 2, 2020
2 parents b3d37b2 + b6a77d4 commit 0471e36
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 50 deletions.
16 changes: 8 additions & 8 deletions R/functions_chr_int.R
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ pretty_plot_chr_int = function(.data,

# Add legend to top right, outside plot region
inset_y = 0
if (pull(.data, !!.color) %>% unique %>% is.na() %>% not()) {
if (pull(.data, !!.color) %>% unique %>% is.na() %>% not() %>% all()) {
legend(
"topleft",
inset = c(1.05, inset_y),
legend = distinct(.data_formatted,!!.color) %>% pull(!!.color),
legend = distinct(.data,!!.color) %>% pull(!!.color),
pch = 19,
col = distinct(.data_formatted,!!.color, .color) %>% pull(.color),
title = color_title,
Expand All @@ -197,7 +197,7 @@ pretty_plot_chr_int = function(.data,
)
inset_y = inset_y + distinct(.data_formatted,!!.color, .color) %>% nrow %>% magrittr::multiply_by(.1)
}
if (pull(.data, !!.size) %>% unique %>% is.na() %>% not() &&
if (pull(.data, !!.size) %>% unique %>% is.na() %>% not() %>% all() &&
(.data %>% select(!!enquo(.size)) %>% sapply(class) %in% c("numeric", "integer", "double"))) {
legend(
"topleft",
Expand All @@ -212,11 +212,11 @@ pretty_plot_chr_int = function(.data,
)
inset_y = inset_y + 0.3
}
if (pull(.data, !!.shape) %>% unique %>% is.na() %>% not()) {
if (pull(.data, !!.shape) %>% unique %>% is.na() %>% not() %>% all()) {
legend(
"topleft",
inset = c(1.05, inset_y),
legend = distinct(.data_formatted,!!.shape) %>% pull(!!.shape),
legend = distinct(.data,!!.shape) %>% pull(!!.shape),
pch = distinct(.data_formatted,!!.shape, .shape) %>% pull(.shape),
col = "black",
title = shape_title,
Expand Down Expand Up @@ -292,9 +292,9 @@ gate_interactive_chr_int <-
.as_matrix()

# Add extra space to right of plot area; change clipping to figure
if (pull(.data, !!.color) %>% unique %>% is.na() %>% not() |
pull(.data, !!.shape) %>% unique %>% is.na() %>% not() |
(pull(.data, !!.size) %>% unique %>% is.na() %>% not() &&
if (pull(.data, !!.color) %>% unique %>% is.na() %>% not() %>% all() |
pull(.data, !!.shape) %>% unique %>% is.na() %>% not() %>% all()|
(pull(.data, !!.size) %>% unique %>% is.na() %>% not() %>% all() &&
(
.data %>% select(!!.size) %>% sapply(class) %in% c("numeric", "integer", "double")
))) {
Expand Down
53 changes: 30 additions & 23 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ library(tidygate)
```

## Installation

```{r, eval=FALSE}
# From Github
devtools::install_github("stemangiola/tidygate")
# From CRAN
install.package("tidygate")
```

It interactively or programmately labels points within custom gates on two dimensions, according to tidyverse principles. The information is added to your tibble. It is based on the package `gatepoints` from Wajid Jawaid.

The main benefits are
Expand All @@ -34,32 +45,12 @@ The main benefits are
- you can save your gates and apply the programmatically.




**Input (tibble)**

element | dimension1 | dimension2 | annotations |
------------ | ------------- | ------------- | -------------
`chr` or `fctr` | `chr` or `fctr` | `numeric` | ...

**Command** `input %>% gate(element, dimension1, dimension2)`

![](inst/tidygate.gif)

**Output (tibble)**

element | dimension1 | dimension2 | annotations | Gate |
------------ | ------------- | ------------- | ------------- | -------------
`chr` or `fctr` | `chr` or `fctr` | `numeric` | ... | ...


## Installation

```{r, eval=FALSE}
dimension1 | dimension2 | annotations |
------------- | ------------- | -------------
`chr` or `fctr` | `numeric` | ...

devtools::install_github("stemangiola/tidygate")
```

## Interactive gating

Expand All @@ -76,6 +67,22 @@ tidygate_gate <-
tidygate_gate
```



![](inst/tidygate.gif)
Output tibble

```{r echo=FALSE}
tidygate_data %>%
mutate( gate = gate_chr(
Dim1, Dim2,
# Pre-defined gates
gate_list = tidygate::gate_list
))
```

Gates are saved in a temporary file for later use

```{r, echo = FALSE}
Expand Down
49 changes: 30 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ heatmaps following tidy principles -
[tidybulk](https://github.com/stemangiola/tidybulk) for tidy and modular
transcriptomics analyses

## Installation

``` r
# From Github
devtools::install_github("stemangiola/tidygate")

# From CRAN
install.package("tidygate")
```

It interactively or programmately labels points within custom gates on
two dimensions, according to tidyverse principles. The information is
added to your tibble. It is based on the package `gatepoints` from Wajid
Expand All @@ -32,25 +42,9 @@ The main benefits are

**Input (tibble)**

| element | dimension1 | dimension2 | annotations |
| --------------- | --------------- | ---------- | ----------- |
| `chr` or `fctr` | `chr` or `fctr` | `numeric` ||

**Command** `input %>% gate(element, dimension1, dimension2)`

![](inst/tidygate.gif)

**Output (tibble)**

| element | dimension1 | dimension2 | annotations | Gate |
| --------------- | --------------- | ---------- | ----------- | ---- |
| `chr` or `fctr` | `chr` or `fctr` | `numeric` |||

## Installation

``` r
devtools::install_github("stemangiola/tidygate")
```
| dimension1 | dimension2 | annotations |
| --------------- | ---------- | ----------- |
| `chr` or `fctr` | `numeric` ||

## Interactive gating

Expand All @@ -67,6 +61,23 @@ tidygate_gate <-
tidygate_gate
```

![](inst/tidygate.gif) Output tibble

## # A tibble: 2,240 x 9
## group hierarchy `ct 1` `ct 2` relation cancer_ID Dim1 Dim2 gate
## <chr> <dbl> <chr> <chr> <dbl> <chr> <dbl> <dbl> <chr>
## 1 adrenal 1 endothel… epitheli… -1 ACC -0.874 -0.239 0
## 2 adrenal 1 endothel… fibrobla… -1 ACC -0.740 0.114 1
## 3 adrenal 1 endothel… immune_c… -1 ACC -0.988 0.118 0
## 4 adrenal 1 epitheli… endothel… 1 ACC 0.851 0.261 0
## 5 adrenal 1 epitheli… fibrobla… 1 ACC 0.839 0.320 0
## 6 adrenal 1 epitheli… immune_c… 1 ACC 0.746 0.337 0
## 7 adrenal 1 fibrobla… endothel… 1 ACC 0.722 -0.0696 0
## 8 adrenal 1 fibrobla… epitheli… -1 ACC -0.849 -0.317 0
## 9 adrenal 1 fibrobla… immune_c… 0.52 ACC -0.776 -0.383 0
## 10 adrenal 1 immune_c… endothel… 1 ACC 0.980 -0.116 0
## # … with 2,230 more rows

Gates are saved in a temporary file for later use

## [[1]]
Expand Down

0 comments on commit 0471e36

Please sign in to comment.