Skip to contents

This function computes the Renyi values at any repertoire level for all the samples in the RepSeqExperiment object.

The alpha values for which the Renyi is to be estimated can be personalized, thus allowing to focus on certain indices such as the Shannon index for alpha=1 or the Simpson index for alpha=2.

Usage

generalizedDiversity(
  x,
  alpha = c(0, 0.25, 0.5, 1, 2, 4, 8, 16, 32, 64, Inf),
  level = c("aaClone", "ntClone", "V", "J", "VJ", "ntCDR3", "aaCDR3"),
  Hill = FALSE
)

Arguments

x

an object of class RepSeqExperiment

alpha

a numerical vector specifying the alpha values to compute. If not specified, the following values are estimated: c(0, 0.25, 0.5, 1, 2, 4, 8, 16, 32, 64, Inf).

level

a character specifying the level of the repertoire to be taken into account when calculate VJ usages. Should be one of "aaClone","ntClone", "V", "J", "VJ", "ntCDR3" or "aaCDR3".

Hill,

boolean indicating whether to plot the Renyi or the Hill Index

Value

a table with Renyi values calculated for all alpha in each sample.

Details

Hill diversity uses a parameter q to adjust how species are count. If q=0, it just counts the number of species (species richness). If q=1, it gives equal weight to all species, balancing rare and common ones. If q=2, it focuses more on the most common species. Rényi diversity is a generalization of the Shannon index. It uses a parameter alpha that works similarly. When alpha is small, it gives more weight to rare species. When alpha is large, it focuses more on the dominant species. Alpha =1 is an approximation of the Shannon index; alpha = 2 corresponds to the Simpson index and alpha=Inf corresponds to the Berger-Parker index. The main difference is that Hill diversity is designed to give “effective species numbers” i.e. how many equally abundant species would give the same diversity, while Rényi diversity is based on entropy and doesn't directly translate to species counts. Both are useful for exploring how diversity changes depending on whether you care more about rare or common species.

Examples


data(RepSeqData)

generalizedDiversity(RepSeqData, level = "V", alpha = 1)
#> Key: <variable>
#>    variable tripod-30-813 tripod-30-815 tripod-31-846 tripod-31-848
#>      <fctr>         <num>         <num>         <num>         <num>
#> 1:        1          4.04          4.03          4.06          4.02
#>    tripod-35-970 tripod-35-972 tripod-36-1003 tripod-36-1005
#>            <num>         <num>          <num>          <num>
#> 1:          4.04             4           4.07           4.06