original_docstring:  Extracts observation embeddings from model (i.e. OTUs).
  
      The observation embeddings are all represented in CLR coordinates.
  
      Parameters
      ----------
      vae_model : MultVAE
          Pretrained Multinomial VAE
      tree : skbio.TreeNode
          The tree used to train the VAE
      return_type : str
          Options include 'tensor', 'array', 'dataframe' (default='dataframe')
      
docstring: Extracts observation embeddings from model .
  The observation embeddings are all represented in CLR coordinates.
  
  Parameters
  
  
docstring_tokens: Extracts observation embeddings from model . The observation embeddings are all represented in CLR coordinates . Parameters
code: def extract_observation_embeddings(vae_model, tree, return_type='dataframe'):
      """ Extracts observation embeddings from model (i.e. OTUs).
  
      The observation embeddings are all represented in CLR coordinates.
  
      Parameters
      ----------
      vae_model : MultVAE
          Pretrained Multinomial VAE
      tree : skbio.TreeNode
          The tree used to train the VAE
      return_type : str
          Options include 'tensor', 'array', 'dataframe' (default='dataframe')
      """
      # ILR representation of the VAE decoder loadings
      W = vae_model.vae.decoder.weight
      Psi, _ = sparse_balance_basis(tree)
      if return_type == 'torch':
          indices = np.vstack((Psi.row, Psi.col))
          Psi = torch.sparse_coo_tensor(
              indices.copy(), Psi.data.astype(np.float32).copy(),
              requires_grad=False).coalesce()
          return Psi.T @ W
      if return_type == 'array':
          return Psi.T @ W.detach().numpy()
      if return_type == 'dataframe':
          names = [n.name for n in tree.tips()]
          return pd.DataFrame(Psi.T @ W.detach().numpy(), index=names)
      else:
          ValueError(f'return type {return_type} is not supported.')
code_tokens: def extract_observation_embeddings ( vae_model , tree , return_type = 'dataframe' ) : W = vae_model . vae . decoder . weight Psi , _ = sparse_balance_basis ( tree ) if return_type == 'torch' : indices = np . vstack ( ( Psi . row , Psi . col ) ) Psi = torch . sparse_coo_tensor ( indices . copy ( ) , Psi . data . astype ( np . float32 ) . copy ( ) , requires_grad = False ) . coalesce ( ) return Psi . T @ W if return_type == 'array' : return Psi . T @ W . detach ( ) . numpy ( ) if return_type == 'dataframe' : names = [ n . name for n in tree . tips ( ) ] return pd . DataFrame ( Psi . T @ W . detach ( ) . numpy ( ) , index = names ) else : ValueError ( f'return type {return_type} is not supported.' )
short_docstring: Extracts observation embeddings from model (i.e.
short_docstring_tokens: Extracts observation embeddings from model ( i . e .
comment: """ Extracts observation embeddings from model (i.e. OTUs).
  
      The observation embeddings are all represented in CLR coordinates.
  
      Parameters
      ----------
      vae_model : MultVAE
          Pretrained Multinomial VAE
      tree : skbio.TreeNode
          The tree used to train the VAE
      return_type : str
          Options include 'tensor', 'array', 'dataframe' (default='dataframe')
      """$SEP$# ILR representation of the VAE decoder loadings