Hi all,
New-ish to R, so please bear with me...
I have a dataset that is a plot of x,y coordinates (currently in csv file). When I create a scatter plot, there is a distinct population of points that I want to pick out by drawing a gate around them, and then applying that gate to other datasets with similar values (essentially a dumbed down version of flow cytometry gating).
I have converted my x,y points into a tibble (as_tbl), but can't seem to get the gate functions to work. This is what the package says to do:
Arguments
.data A tibble
.element A column symbol. The column that is used to calculate distance (i.e., normally
genes)
.dim1 A column symbol. The x dimension
.dim2 A column symbol. The y dimension
.color A column symbol. Color of points
.shape A column symbol. Shape of points
.size A column symbol. Size of points
opacity A number between 0 and 1. The opacity level of the data points
how_many_gates An integer. The number of gates to label
gate_list A list of gates. It is returned by gate function as attribute "gate". If you want
to create this list yourself, each element of the list is a data frame with x and y
columns. Each row is a coordinate. The order matter.
name A character string. The name of the new column
action A character string. Whether to join the new information to the input tbl (add),
or just get the non-redundant tbl with the new information (get).
... Further parameters passed to the function gatepoints::fhs
Examples
if(interactive()){
tidygate::tidygate_data %>%
gate( .element = c(`ct 1`, `ct 2`), Dim1, Dim2 )
}
library(magrittr)
tidygate::tidygate_data %>%
gate(
.element = c(`ct 1`, `ct 2`),
Dim1, Dim2,
gate_list = tidygate::gate_list
)
(source: https://cran.r-project.org/web/packages/tidygate/tidygate.pdf)
Could someone please help walk me through how to set this up? Sample of what the data looks like:
> newdata
# A tibble: 5,046 x 3
M488 M560 Cell
<chr> <chr> <chr>
1 1381.31 301.8 Live
2 7104 266.08 Live
3 8072.78 250.8 Live
4 960.01 594.37 Live
5 813.88 425.85 Live
6 8985.28 249.68 Live
7 23917.14 292.2 Live
8 989.88 548.35 Live
9 1316.68 463.89 Live
10 7951.51 322.52 Live
# … with 5,036 more rows
I've also tried converting chr -> dbl but no such luck.
Getting a million different errors, such as these:
gate(newdata, M488, M560)
Error in is_quosure(x) : argument "x" is missing, with no default
In addition: Warning message:
In is.na(.) : is.na() applied to non-(list or vector) of type 'symbol'
> gate(newdata, .element = Cell, M488, M560)
Error: Problem with `filter()` input `..1`.
x Input `..1` must be of size 2 or 1, not size 5046.
ℹ Input `..1` is `M488 %>% is.na | M560 %>% is.na`.