def from_scanpy(adata, cell_type_identifier, covariate_key):
    """
    Converts a single scRNA-seq data set from scanpy to a row of a cell count matrix.

    It is assumed that a column of adata.obs contains the cell type assignment, while covariates (control/disease group, ...) are stored as a subdict in adata.uns

    Usage: cell_counts, covs = from_scanpy(adata, cell_type_identifier="Louvain", covariate_key="covariates")

    Parameters
    ----------
    adata -- anndata object
        single-cell data object from scanpy
    cell_type_identifier -- str
        column name in adata.obs that specifies the cell types
    covariate_key -- str
        key for adata.uns, where the covariate values are stored

    Returns
    -------
    cell_counts -- Numpy array
        cell count vector
    covs -- list
        covariate vector
    """

    # Calculate cell counts for the sample
    cell_counts = adata.obs[cell_type_identifier].value_counts()

    # extracting covariates from uns
    covs = adata.uns[covariate_key]

    return cell_counts, covs