def ROC_AUC_analysis(adata,groupby,group=None, n_genes=100):
    """Calculate correlation matrix.

            Calculate a correlation matrix for genes strored in sample annotation using rank_genes_groups.py

            Parameters
            ----------
            adata : :class:`~anndata.AnnData`
                Annotated data matrix.
            groupby : `str`
                The key of the sample grouping to consider.
            group : `str`, int, optional (default: None)
                Group name or index for which the correlation matrix for top_ranked genes should be calculated.
                If no parameter is passed, ROC/AUC is calculated for all groups
            n_genes : `int`, optional (default: 100)
                For how many genes to calculate ROC and AUC. If no parameter is passed, calculation is done for
                all stored top ranked genes.

        """
    if group is None:
        pass
        # TODO: Loop over all groups instead of just taking one.

    # Assume group takes an int value for one group for the moment.
    name_list = list()
    for j, k in enumerate(adata.uns['rank_genes_groups_gene_names']):
        if j >= n_genes:
            break
        name_list.append(adata.uns['rank_genes_groups_gene_names'][j][group])


    # TODO: For the moment, see that everything works for comparison against the rest. Resolve issues later.
    groups = 'all'
    groups_order, groups_masks = utils.select_groups(
        adata, groups, groupby)

    # Use usual convention, better for looping later.
    imask = group
    mask = groups_masks[group]

    # TODO: Allow for sample weighting requires better mask access... later

    # We store calculated data in dict, access it via dict to dict. Check if this is the best way.
    fpr={}
    tpr={}
    thresholds={}
    roc_auc={}
    y_true=mask
    for i, j in enumerate(name_list):
        vec=adata[:,[j]].X
        if issparse(vec):
            y_score = vec.todense()
        else:
            y_score = vec

        fpr[name_list[i]], tpr[name_list[i]], thresholds[name_list[i]] = metrics.roc_curve(y_true, y_score, pos_label=None, sample_weight=None, drop_intermediate=False)
        roc_auc[name_list[i]]=metrics.auc(fpr[name_list[i]],tpr[name_list[i]])
    adata.uns['ROCfpr' +groupby+ str(group)] = fpr
    adata.uns['ROCtpr' +groupby+ str(group)] = tpr
    adata.uns['ROCthresholds' +groupby+ str(group)] = thresholds
    adata.uns['ROC_AUC' + groupby + str(group)] = roc_auc
Calculate correlation matrix.

            Calculate a correlation matrix for genes strored in sample annotation using rank_genes_groups.py

            Parameters
            ----------
            adata : :class:`~anndata.AnnData`
                Annotated data matrix.
            groupby : `str`
                The key of the sample grouping to consider.
            group : `str`, int, optional (default: None)
                Group name or index for which the correlation matrix for top_ranked genes should be calculated.
                If no parameter is passed, ROC/AUC is calculated for all groups
            n_genes : `int`, optional (default: 100)
                For how many genes to calculate ROC and AUC. If no parameter is passed, calculation is done for
                all stored top ranked genes.