def kmeans_clustering(self, numc, X=None, npcs=<NUM_LIT:15>):
from sklearn.cluster import KMeans<EOL>if X is None:<EOL><INDENT>D_sub = self.adata.uns['<STR_LIT>']<EOL>X = (<EOL>D_sub -<EOL>D_sub.mean(<NUM_LIT:0>)).dot(<EOL>self.adata.uns['<STR_LIT>'].components_[<EOL>:npcs,<EOL>:].T)<EOL>save = True<EOL><DEDENT>else:<EOL><INDENT>save = False<EOL><DEDENT>cl = KMeans(n_clusters=numc).fit_predict(Normalizer().fit_transform(X))<EOL>if save:<EOL><INDENT>self.adata.obs['<STR_LIT>'] = pd.Categorical(cl)<EOL><DEDENT>else:<EOL><INDENT>return cl<EOL><DEDENT>
Performs k-means clustering.

        Parameters
        ----------
        numc - int
            Number of clusters

        npcs - int, optional, default 15
            Number of principal components to use as inpute for k-means
            clustering.