def embeddings2ranks(embeddings):
    """ Converts embeddings to ranks"""
    microbes = embeddings.loc[embeddings.embed_type == 'microbe']
    metabolites = embeddings.loc[embeddings.embed_type == 'metabolite']
    U = microbes.pivot(index='feature_id', columns='axis', values='values')
    V = metabolites.pivot(index='feature_id', columns='axis', values='values')
    pc_ids = sorted(list(set(U.columns) - {'bias'}))
    U['ones'] = 1
    V['ones'] = 1
    ranks = U[pc_ids + ['ones', 'bias']] @ V[pc_ids + ['bias', 'ones']].T
    ranks = ranks - ranks.mean(axis=1).values.reshape(-1, 1)
    return ranks
