Skip to contents

Compute a logical matrix corresponding to the input align input with TRUE where an element matches the consensus at that position and FALSE where it does not. Columns with no consensus – see tales_consensus – are NA throughout, since there is nothing there to match.

Usage

tales_consensus_match(align, long = TRUE)

Arguments

align

A TALE alignment as a character matrix, one row per array and one column per alignment position, with NA for gaps. as.matrix() on a tales_msa returns one (see as.matrix.tales_msa), filled with RVDs or domain codes.

long

Set to TRUE (default) to return a long tibble, or FALSE to return a logical matrix with the same shape as align.

Value

A multiple Tal sequences alignment in the form of a matrix filled with logical values if long is FALSE and a long tibble representing the original alignment otherwise (default).

Examples

aln <- matrix(c("HD", "HD", "NI",
               "NG", "NI", "HD"),
             nrow = 3, dimnames = list(c("A1", "A2", "A3"), NULL))
tales_consensus_match(aln, long = FALSE)
#>     [,1] [,2]
#> A1  TRUE   NA
#> A2  TRUE   NA
#> A3 FALSE   NA
tales_consensus_match(aln)
#> # A tibble: 6 × 3
#>   array_id alignment_position tales_consensus_match
#>   <fct>    <fct>              <lgl>                
#> 1 A1       A                  TRUE                 
#> 2 A2       A                  TRUE                 
#> 3 A3       A                  FALSE                
#> 4 A1       B                  NA                   
#> 5 A2       B                  NA                   
#> 6 A3       B                  NA