Select rows of a data frame based on phenotypes or other expressions.
select_rows(csd, sel, phenotype_column = "Phenotype")
A data frame
May be a character vector, a one-sided formula or a list
containing such. A character vector is interpreted as the name(s) of one or
more phenotypes and selects any matching phenotype. A formula is
interpreted as an expression on the columns of
Optional, name of the phenotype column to use for simple selection
A logical vector of length
nrow(csd) which selects rows
select_rows implements a flexible mechanism for selecting cells (rows)
from a cell segmentation table. Cells may be selected by single or
multiple phenotype, by expression level, or combinations of both.
See the tutorial Selecting cells within a cell segmentation table for extensive documentation and examples.
csd <- sample_cell_seg_data # Select tumor cells with PDL1 expression > 3 selector <- list('CK+', ~`Entire Cell PDL1 (Opal 520) Mean`>3) pdl1_pos_tumor <- csd[select_rows(csd, selector),] range(pdl1_pos_tumor$`Entire Cell PDL1 (Opal 520) Mean`)#>  3.007 47.459# Select all T-cells. Note: Use c() to combine phenotypes, not list() selector <- c('CD8+', 'FoxP3+') tcells <- csd[select_rows(csd, selector),] table(tcells$Phenotype)#> #> CD8+ FoxP3+ #> 228 228