code: def beta_diversity(self, metric="braycurtis", rank="auto"):
          
          if metric not in ("jaccard", "braycurtis", "cityblock"):
              raise OneCodexException(
                  "For beta diversity, metric must be one of: jaccard, braycurtis, cityblock"
              )
  
          # needs read counts, not relative abundances
          if self._guess_normalized():
              raise OneCodexException("Beta diversity requires unnormalized read counts.")
  
          df = self.to_df(rank=rank, normalize=False)
  
          counts = []
          for c_id in df.index:
              counts.append(df.loc[c_id].tolist())
  
          return skbio.diversity.beta_diversity(metric, counts, df.index.tolist())
docs: Calculate the diversity between two communities.
  
          Parameters
          ----------
          metric : {'jaccard', 'braycurtis', 'cityblock'}
              The distance metric to calculate.
          rank : {'auto', 'kingdom', 'phylum', 'class', 'order', 'family', 'genus', 'species'}, optional
              Analysis will be restricted to abundances of taxa at the specified level.
  
          Returns
          -------
          skbio.stats.distance.DistanceMatrix, a distance matrix.