Skip to contents

For all sequences in a cluster(s) calculate the frequency of separate words in either the sequence definitions or the reported feature name.

Usage

calc_wrdfrq(
  phylota,
  cid,
  min_frq = 0.1,
  min_nchar = 1,
  type = c("dfln", "nm"),
  ignr_pttrn = "[^a-z0-9]"
)

Arguments

phylota

Phylota object

cid

Cluster ID(s)

min_frq

Minimum frequency

min_nchar

Minimum number of characters for a word

type

Definitions (dfln) or features (nm)

ignr_pttrn

Ignore pattern, REGEX for text to ignore.

Value

list

Details

By default, anything that is not alphanumeric is ignored. 'dfln' and 'nm' match the slot names in a SeqRec, see list_seqrec_slots().

Examples

data('dragonflies')
# work out what gene region the cluster is likely representing with word freqs.
random_cids <- sample(dragonflies@cids, 10)
# most frequent words in definition line
(calc_wrdfrq(phylota = dragonflies, cid = random_cids, type = 'dfln'))
#> $`430`
#> named numeric(0)
#> 
#> $`653`
#> named numeric(0)
#> 
#> $`15`
#> named numeric(0)
#> 
#> $`478`
#> wrds
#>      rrna       and 
#> 0.1525424 0.1016949 
#> 
#> $`548`
#> wrds
#>      gene  sequence 
#> 0.1411765 0.1294118 
#> 
#> $`161`
#> named numeric(0)
#> 
#> $`498`
#> wrds
#>     gene sequence 
#>     0.15     0.15 
#> 
#> $`413`
#> named numeric(0)
#> 
#> $`222`
#> wrds
#>        h3       cds      gene   histone   partial 
#> 0.1528384 0.1135371 0.1135371 0.1135371 0.1135371 
#> 
#> $`29`
#> named numeric(0)
#> 
# most frequent words in feature name
(calc_wrdfrq(phylota = dragonflies, cid = random_cids, type = 'nm'))
#> $`430`
#> numeric(0)
#> 
#> $`653`
#> numeric(0)
#> 
#> $`15`
#> barcode 
#>       1 
#> 
#> $`478`
#> numeric(0)
#> 
#> $`548`
#> numeric(0)
#> 
#> $`161`
#> numeric(0)
#> 
#> $`498`
#> numeric(0)
#> 
#> $`413`
#> barcode 
#>       1 
#> 
#> $`222`
#> numeric(0)
#> 
#> $`29`
#> numeric(0)
#>