Skip to contents

Subsets rows and columns like an ordinary tibble, but the class travels only while the result still satisfies the tales contract.

Usage

# S3 method for class 'tales'
x[...]

Arguments

x

A tales object.

...

Passed on to the tibble/data frame method.

Value

The subset: still a tales (or tales_msa) if the contract holds, otherwise a plain tibble.

Details

Row subsetting never breaks anything: every invariant a tales checks still holds on any subset of rows, so filtering to one array, or to its repeats only, is still a valid tales. Column subsetting is where it degrades: dropping array_id, or both residue columns (rvd, dom_code) at once, leaves something that can no longer be described as a tales, and the result is a plain tibble, without an error. Dropping an optional column (seqnames, aa_seq, ...) has no such consequence. A tales_msa degrades one step at a time: losing alignment_position alone steps it back to a plain tales.

Attributes travel with a valid subset. dom_code_namespace describes the run the codes came from, so cutting an object down with [ keeps its namespace unchanged.

Examples

x <- tales(data.frame(
  array_id = c("A1", "A1"), position_in_array = c(1L, 2L),
  rvd = c("NTERM", "HD")
))
is_tales(x[1, ]) # row subsetting never breaks the contract
#> [1] TRUE
class(x[, -1])   # dropping array_id: the class steps out of the way
#> [1] "tbl_df"     "tbl"        "data.frame"