Skip to contents

These helper functions allow for the selection of clones based on various criteria such as size, group comparison, and existence in specific groups.

Usage

top(n, groups = NULL, data = NULL)

select(expr, groups = NULL, data = NULL)

uniq(group1, group2, ..., groups = NULL, data = NULL)

shared(group1, group2, ..., groups = NULL, data = NULL)

larger(
  group1,
  group2,
  include_eq = FALSE,
  shared = FALSE,
  groups = NULL,
  data = NULL
)

smaller(
  group1,
  group2,
  include_eq = FALSE,
  shared = FALSE,
  groups = NULL,
  data = NULL
)

eq(group1, group2, groups = NULL, shared = FALSE, data = NULL)

Arguments

n

The number of top clones to select or the threshold size.

groups

The column names in the meta data to group the cells. By default, it is assumed facet_by and split_by to be in the parent frame.

data

The data frame containing clone information. Default is NULL. If NULL, it will get data from parent.frame. A typical data should have a column named CloneID and other columns for the groupings. Under each grouping column, the value should be the size of the clone. By default, the data is assumed to be in the parent frame.

expr

The expression (in characters) to filter the clones (e.g. "group1 > group2" to select clones where group1 is larger than group2).

group1

The first group to compare.

group2

The second group to compare.

...

More groups to compare.

include_eq

Whether to include equal-sized clones.

Value

A vector of selected clones.

Examples

data <- data.frame(
   CloneID = 1:10,
   group1 = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9),
   group2 = c(7, 3, 8, 2, 1, 5, 9, 4, 6, 0),
   groups = c("A", "A", "A", "A", "B", "B", "B", "B", "B", "B")
)
data <- data[order(data$group1 + data$group2, decreasing = TRUE), ]
scplotter:::top(3)
#> [1] 7 9 8
scplotter:::top(3, groups = "groups")
#> # A tibble: 6 × 2
#>   groups CloneID
#>   <chr>    <int>
#> 1 A            3
#> 2 A            1
#> 3 A            4
#> 4 B            7
#> 5 B            9
#> 6 B            8
scplotter:::select(group1 == 0 | group2 == 0)
#> [1] 10  1
scplotter:::uniq(group1, group2)
#> [1] 10
scplotter:::shared(group1, group2)
#> [1] 7 9 8 3 6 4 5 2
scplotter:::larger(group1, group2)
#> [1]  9  8 10  4  5
scplotter:::smaller(group1, group2)
#> [1] 7 3 1 2
scplotter:::smaller(group1, group2, include_eq = TRUE)
#> [1] 7 3 6 1 2
scplotter:::smaller(group1, group2, shared = TRUE)
#> [1] 7 3 2
scplotter:::eq(group1, group2)
#> [1] 6