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"

  1. # Load the package and test dataset
  2. library(immunarch)
  3. data(immdata)
  4. # Compute statistics and visualise them
  5. # Chao1 diversity measure
  6. div_chao <- repDiversity(immdata$data, "chao1")
  7. head(div_chao)
  8. # Estimator SD Conf.95.lo Conf.95.hi
  9. #A2-i129 48835.65 2387.115 44409.43 53778.33
  10. #A2-i131 49895.77 2472.021 45314.90 55017.29
  11. #A2-i133 44208.54 2126.211 40264.94 48609.73
  12. #A2-i132 35784.39 1454.166 33070.82 38776.58
  13. #A4-i191 34273.28 1798.918 30955.23 38017.31
  14. #A4-i192 31138.74 1362.298 28606.09 33952.20
  15. # Hill numbers
  16. div_hill <- repDiversity(immdata$data, "hill")
  17. head(div_hill)
  18. # Sample Q Value
  19. #1 A2-i129 1 4260.573
  20. #2 A2-i131 1 4569.927
  21. #3 A2-i133 1 3751.579
  22. #4 A2-i132 1 5501.741
  23. #5 A4-i191 1 1942.350
  24. #6 A4-i192 1 3163.632
  25. # D50
  26. div_d50 <- repDiversity(immdata$data, "d50")
  27. head(div_d50)
  28. # Clones Percentage
  29. #A2-i129 2225 50
  30. #A2-i131 2251 50
  31. #A2-i133 2028 50
  32. #A2-i132 2393 50
  33. #A4-i191 861 50
  34. #A4-i192 1514 50
  35. # Ecological diversity measure
  36. div_div <- repDiversity(immdata$data, "div")
  37. head(div_div)
  38. # Sample Value
  39. #1 A2-i129 112.96455
  40. #2 A2-i131 200.77108
  41. #3 A2-i133 57.25057
  42. #4 A2-i132 739.71374
  43. #5 A4-i191 39.13425
  44. #6 A4-i192 118.33830
  45. p1 <- vis(div_chao)
  46. p2 <- vis(div_chao, .by = c("Status", "Sex"), .meta = immdata$meta)
  47. p3 <- vis(div_hill, .by = c("Status", "Sex"), .meta = immdata$meta)
  48. p4 <- vis(div_d50)
  49. p5 <- vis(div_d50, .by = "Status", .meta = immdata$meta)
  50. p6 <- vis(div_div)
  51. p1 + p2

使用immunarch包进行单细胞免疫组库数据分析(七):Diversity estimation - 图1

  1. p3 + p6

使用immunarch包进行单细胞免疫组库数据分析(七):Diversity estimation - 图2

  1. p4 + p5

使用immunarch包进行单细胞免疫组库数据分析(七):Diversity estimation - 图3

  1. imm_raref <- repDiversity(immdata$data, "raref", .verbose = F)
  2. head(imm_raref)
  3. # Size Q0.025 Mean Q0.975 Sample Type
  4. #1 0.02 0.02485373 0.02387968 0.02582681 A2-i129 interpolation
  5. #2 0.04 0.04849410 0.04689468 0.05009084 A2-i129 interpolation
  6. #3 0.06 0.07154025 0.06938140 0.07369409 A2-i129 interpolation
  7. #4 0.08 0.09416917 0.09148383 0.09684658 A2-i129 interpolation
  8. #5 0.10 0.11647440 0.11328184 0.11965546 A2-i129 interpolation
  9. #6 0.12 0.13851377 0.13482653 0.14218529 A2-i129 interpolation
  10. p1 <- vis(imm_raref)
  11. p2 <- vis(imm_raref, .by = "Status", .meta = immdata$meta)
  12. p1 + p2

使用immunarch包进行单细胞免疫组库数据分析(七):Diversity estimation - 图4

  1. repDiversity(immdata$data, "raref", .verbose = F) %>% vis(.log = TRUE)

使用immunarch包进行单细胞免疫组库数据分析(七):Diversity estimation - 图5

参考来源:https://immunarch.com/articles/web_only/v6_diversity.html