在Immunarch
包中,我们可以使用repDiversity
函数计算免疫组库的多样性。它提供了多种方法去评估Repertoire的多样性,可以通过.method
参数进行设置。您可以选择以下方法之一:
-
chao1
- Chao1 estimator is a nonparameteric asymptotic estimator of species richness (number of species in a population). -
hill
- Hill numbers are a mathematically unified family of diversity indices (differing only by an exponent q). -
div
- True diversity, or the effective number of types, refers to the number of equally-abundant types needed for the average proportional abundance of the types to equal that observed in the dataset of interest where all types may not be equally abundant. -
gini.simp
- The Gini-Simpson index is the probability of interspecific encounter, i.e., probability that two entities represent different types. -
inv.simp
- Inverse Simpson index is the effective number of types that is obtained when the weighted arithmetic mean is used to quantify average proportional abundance of types in the dataset of interest. -
gini
- The Gini coefficient measures the inequality among values of a frequency distribution (for example levels of income). A Gini coefficient of zero expresses perfect equality, where all values are the same (for example, where everyone has the same income). A Gini coefficient of one (or 100 percents ) expresses maximal inequality among values (for example where only one person has all the income). -
raref
- Rarefaction is a technique to assess species richness from the results of sampling through extrapolation.
我们还可以通过.col
参数来设置要选择的序列和基因片段。例如,如果您想在核苷酸水平上估计多样性,您需要设置.col = "nt"
,在氨基酸水平则设置.col = "aa"
。如果您想估计与 V 基因片段耦合的CDR3氨基酸序列的多样性,您需要设置.col = "aa+v"
. repDiversity
函数默认情况下为.col = "aa"
。
# Load the package and test dataset
library(immunarch)
data(immdata)
# Compute statistics and visualise them
# Chao1 diversity measure
div_chao <- repDiversity(immdata$data, "chao1")
head(div_chao)
# Estimator SD Conf.95.lo Conf.95.hi
#A2-i129 48835.65 2387.115 44409.43 53778.33
#A2-i131 49895.77 2472.021 45314.90 55017.29
#A2-i133 44208.54 2126.211 40264.94 48609.73
#A2-i132 35784.39 1454.166 33070.82 38776.58
#A4-i191 34273.28 1798.918 30955.23 38017.31
#A4-i192 31138.74 1362.298 28606.09 33952.20
# Hill numbers
div_hill <- repDiversity(immdata$data, "hill")
head(div_hill)
# Sample Q Value
#1 A2-i129 1 4260.573
#2 A2-i131 1 4569.927
#3 A2-i133 1 3751.579
#4 A2-i132 1 5501.741
#5 A4-i191 1 1942.350
#6 A4-i192 1 3163.632
# D50
div_d50 <- repDiversity(immdata$data, "d50")
head(div_d50)
# Clones Percentage
#A2-i129 2225 50
#A2-i131 2251 50
#A2-i133 2028 50
#A2-i132 2393 50
#A4-i191 861 50
#A4-i192 1514 50
# Ecological diversity measure
div_div <- repDiversity(immdata$data, "div")
head(div_div)
# Sample Value
#1 A2-i129 112.96455
#2 A2-i131 200.77108
#3 A2-i133 57.25057
#4 A2-i132 739.71374
#5 A4-i191 39.13425
#6 A4-i192 118.33830
p1 <- vis(div_chao)
p2 <- vis(div_chao, .by = c("Status", "Sex"), .meta = immdata$meta)
p3 <- vis(div_hill, .by = c("Status", "Sex"), .meta = immdata$meta)
p4 <- vis(div_d50)
p5 <- vis(div_d50, .by = "Status", .meta = immdata$meta)
p6 <- vis(div_div)
p1 + p2
image.png
p3 + p6
image.png
p4 + p5
image.png
imm_raref <- repDiversity(immdata$data, "raref", .verbose = F)
head(imm_raref)
# Size Q0.025 Mean Q0.975 Sample Type
#1 0.02 0.02485373 0.02387968 0.02582681 A2-i129 interpolation
#2 0.04 0.04849410 0.04689468 0.05009084 A2-i129 interpolation
#3 0.06 0.07154025 0.06938140 0.07369409 A2-i129 interpolation
#4 0.08 0.09416917 0.09148383 0.09684658 A2-i129 interpolation
#5 0.10 0.11647440 0.11328184 0.11965546 A2-i129 interpolation
#6 0.12 0.13851377 0.13482653 0.14218529 A2-i129 interpolation
p1 <- vis(imm_raref)
p2 <- vis(imm_raref, .by = "Status", .meta = immdata$meta)
p1 + p2
image.png
repDiversity(immdata$data, "raref", .verbose = F) %>% vis(.log = TRUE)
image.png
网友评论