filter: Subset rows using a single column value

filterR Documentation

Subset rows using a single column value

Description

These ⁠filter_*()⁠ functions are used to subset a data frame. Each function subsets rows based on the value of one column. For numeric columns, a row will be kept if the value is greater than or equal to the value specified. For categorical columns, a row will be kept if the value is equal to the value specified. Note that when a condition evaluates to NA the row will be dropped, unlike base subsetting with [.

Usage

filter_aa_change(.data, .value, .preserve = FALSE)

filter_alt_umi_count(.data, .value, .preserve = FALSE)

filter_coverage(.data, .value, .preserve = FALSE)

filter_gene(.data, .value, .preserve = FALSE)

filter_mutation_name(.data, .value, .preserve = FALSE)

filter_ref_umi_count(.data, .value, .preserve = FALSE)

filter_targeted(.data, .value, .preserve = FALSE)

Arguments

.data

A data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr).

.value

Filtering value. If a number, data greater than or equal to the value will be kept. If a string, data equal to the value will be kept.

.preserve

Relevant when the .data input is grouped. If .preserve = FALSE (the default), the grouping structure is recalculated based on the resulting data, otherwise the grouping is kept as is.

Value

An object of the same type as .data. The output has the following properties:

  • Rows are a subset of the input, but appear in the same order.

  • Columns are not modified.

  • The number of groups may be reduced (if .preserve is not TRUE).

  • Data frame attributes are preserved.

See Also

dplyr::filter() for more complex filtering operations.

Examples

data <- tibble::tribble(
  ~sample, ~gene, ~coverage,
  "S1", "atp6", 10,
  "S2", "crt", 20,
)
filter_gene(data, "atp6")
filter_coverage(data, 15)

bailey-lab/miplicorn documentation built on March 19, 2023, 7:40 p.m.