Skip to contents

This function performs PhenoGraph metaclustering on a `tof_tbl` containing CyTOF data using a user-specified selection of input variables/CyTOF measurements. The number of metaclusters is automatically detected by the PhenoGraph algorithm. See tof_cluster_phenograph.

Usage

tof_metacluster_phenograph(
  tof_tibble,
  cluster_col,
  metacluster_cols = where(tof_is_numeric),
  central_tendency_function = stats::median,
  num_neighbors = 5L,
  ...
)

Arguments

tof_tibble

A `tof_tbl` or `tibble`.

cluster_col

An unquoted column name indicating which column in `tof_tibble` stores the cluster ids for the cluster to which each cell belongs. Cluster labels can be produced via any method the user chooses - including manual gating, any of the functions in the `tof_cluster_*` function family, or any other method.

metacluster_cols

Unquoted column names indicating which columns in `tof_tibble` to use in computing the metaclusters. Defaults to all numeric columns in `tof_tibble`. Supports tidyselect helpers.

central_tendency_function

The function that should be used to calculate the measurement of central tendency for each cluster before metaclustering. This function will be used to compute a summary statistic for each input cluster in `cluster_col` across all columns specified by `metacluster_cols`, and the resulting vector (one for each cluster) will be used as the input for metaclustering. Defaults to median.

num_neighbors

An integer indicating the number of neighbors to use when constructing PhenoGraph's k-nearest-neighbor graph. Smaller values emphasize local graph structure; larger values emphasize global graph structure (and will add time to the computation). Defaults to 5.

...

Optional additional method specifications to pass to tof_cluster_phenograph.

Value

A tibble with a single column (`.phenograph_metacluster`) and the same number of rows as the input `tof_tibble`. Each entry in the column indicates the metacluster label assigned to the same row in `tof_tibble`.

Examples

sim_data <-
    dplyr::tibble(
        cd45 = rnorm(n = 1000),
        cd38 = rnorm(n = 1000),
        cd34 = rnorm(n = 1000),
        cd19 = rnorm(n = 1000),
        cluster_id = sample(letters, size = 1000, replace = TRUE)
    )

tof_metacluster_phenograph(tof_tibble = sim_data, cluster_col = cluster_id)
#> # A tibble: 1,000 × 1
#>    .phenograph_metacluster
#>    <chr>                  
#>  1 3                      
#>  2 2                      
#>  3 3                      
#>  4 1                      
#>  5 1                      
#>  6 3                      
#>  7 1                      
#>  8 2                      
#>  9 1                      
#> 10 2                      
#> # ℹ 990 more rows