def correlation_matrix(adata,groupby=None ,group=None, corr_matrix=None, annotation_key=None):
    """Plot correlation matrix.

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

            Parameters
            ----------
            adata : :class:`~anndata.AnnData`
                Annotated data matrix.
            groupby : `str`, optional (default: None)
                If specified, searches data_annotation for correlation_matrix+groupby+str(group)
            group : int
                Identifier of the group (necessary if and only if groupby is also specified)
            corr_matrix : DataFrame, optional (default: None)
                Correlation matrix as a DataFrame (annotated axis) that can be transferred manually if wanted
            annotation_key: `str`, optional (default: None)
                If specified, looks in data annotation for this key.

        """

    # TODO: At the moment, noly works for int identifiers

    if corr_matrix is None:
        # This will produce an error if he annotation doesn't exist, which is okay
        if annotation_key is None:
            if groupby is None:
                corr_matrix = adata.uns['Correlation_matrix']
            else:
                corr_matrix= adata.uns['Correlation_matrix' + groupby+ str(group)]
            # Throws error if does not exist
        else:
            corr_matrix = adata.uns[annotation_key]

    # Set up mask
    mask = np.zeros_like(corr_matrix, dtype=np.bool)
    di = np.diag_indices(len(corr_matrix.axes[0]))
    mask[di] = True

    f, ax = plt.subplots(figsize=(11, 9))

    cmap = sns.diverging_palette(240, 10, as_cmap=True)

    sns.heatmap(corr_matrix, mask=mask, cmap=cmap,
                square=True, linewidths=.5, cbar_kws={"shrink": .5})
    if annotation_key is None:
        if groupby is None:
            plt.title('Correlation Matrix')
        else:
            plt.title('Correlation Matrix for Group ' + str(group) + "in " + groupby)
    else:
        plt.title('Correlation Matrix for' + annotation_key)
    plt.show()
Plot correlation matrix.

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

            Parameters
            ----------
            adata : :class:`~anndata.AnnData`
                Annotated data matrix.
            groupby : `str`, optional (default: None)
                If specified, searches data_annotation for correlation_matrix+groupby+str(group)
            group : int
                Identifier of the group (necessary if and only if groupby is also specified)
            corr_matrix : DataFrame, optional (default: None)
                Correlation matrix as a DataFrame (annotated axis) that can be transferred manually if wanted
            annotation_key: `str`, optional (default: None)
                If specified, looks in data annotation for this key.