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
Input (tibble)
element | dimension1 | dimension2 | annotations |
---|---|---|---|
chr or fctr |
chr or fctr |
numeric |
… |
Command input %>% gate(element, dimension1, dimension2)
Output (tibble)
element | dimension1 | dimension2 | annotations | Gate |
---|---|---|---|---|
chr or fctr |
chr or fctr |
numeric |
… | … |
The standard way to gate points in a two-dimensional plot is to
tidygate_gate <-
tidygate_data %>%
mutate( gate = gate_chr( Dim1, Dim2 ) )
tidygate_gate
Gates are saved in a temporary file for later use
## [[1]]
## x y
## 1 -0.9380459 0.2784375
## 2 -0.9555544 -0.1695209
## 3 -0.3310857 0.2116150
##
## [[2]]
## x y
## 1 0.01324749 0.2165648
## 2 -0.31065917 -0.1026984
## 3 -0.11514794 -0.2982161
## 4 0.48013998 0.1225183
We can use previously drawn gates to programmately add the gate column
tidygate_data %>%
mutate( gate = gate_chr(
Dim1, Dim2,
# Pre-defined gates
gate_list = my_gates
))
## # A tibble: 2,240 × 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 endothelial epithe… -1 ACC -0.874 -0.239 0
## 2 adrenal 1 endothelial fibrob… -1 ACC -0.740 0.114 1
## 3 adrenal 1 endothelial immune… -1 ACC -0.988 0.118 0
## 4 adrenal 1 epithelial endoth… 1 ACC 0.851 0.261 0
## 5 adrenal 1 epithelial fibrob… 1 ACC 0.839 0.320 0
## 6 adrenal 1 epithelial immune… 1 ACC 0.746 0.337 0
## 7 adrenal 1 fibroblast endoth… 1 ACC 0.722 -0.0696 0
## 8 adrenal 1 fibroblast epithe… -1 ACC -0.849 -0.317 0
## 9 adrenal 1 fibroblast immune… 0.52 ACC -0.776 -0.383 0
## 10 adrenal 1 immune_cell endoth… 1 ACC 0.980 -0.116 0
## # … with 2,230 more rows