select_rows: Flexibly select rows of a data frame.

Description Usage Arguments Details Value See Also Examples

View source: R/select_rows.R

Description

Select rows of a data frame based on phenotypes or other expressions.

Usage

1
select_rows(csd, sel)

Arguments

csd

A data frame

sel

May be a character vector, a one-sided formula, a list containing such or NA. 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 csd. Multiple list items are joined with AND. NA is interpreted as "select all". It is convienent for lists of selection criteria.

Details

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.

Value

A logical vector of length nrow(csd) which selects rows according to sel.

See Also

parse_phenotypes for a convenient way to create selectors for most common phenotypes.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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`)

# 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)

PerkinElmer/phenoptr documentation built on May 30, 2019, 8:01 a.m.