def calculate_regression_PCs(self, genes=None, npcs=None, plot=False):
from sklearn.decomposition import PCA<EOL>if npcs is None:<EOL><INDENT>npcs = self.adata.X.shape[<NUM_LIT:0>]<EOL><DEDENT>pca = PCA(n_components=npcs)<EOL>pc = pca.fit_transform(self.adata.X.toarray())<EOL>self.regression_pca = pca<EOL>self.regression_pcs = pc<EOL>gene_names = np.array(list(self.adata.var_names))<EOL>if(genes is not None):<EOL><INDENT>idx = np.where(np.in1d(gene_names, genes))[<NUM_LIT:0>]<EOL>sx = pca.components_[:, idx]<EOL>x = np.abs(sx).mean(<NUM_LIT:1>)<EOL>if plot:<EOL><INDENT>plt.figure()<EOL>plt.plot(x)<EOL><DEDENT>return x<EOL><DEDENT>else:<EOL><INDENT>return<EOL><DEDENT>
Computes the contribution of the gene IDs in 'genes' to each
        principal component (PC) of the filtered expression data as the mean of
        the absolute value of the corresponding gene loadings. High values
        correspond to PCs that are highly correlated with the features in
        'genes'. These PCs can then be regressed out of the data using
        'regress_genes'.


        Parameters
        ----------
        genes - numpy.array or list
            Genes for which contribution to each PC will be calculated.

        npcs - int, optional, default None
            How many PCs to calculate when computing PCA of the filtered and
            log-transformed expression data. If None, calculate all PCs.

        plot - bool, optional, default False
            If True, plot the scores reflecting how correlated each PC is with
            genes of interest. Otherwise, do not plot anything.

        Returns:
        -------
        x - numpy.array
            Scores reflecting how correlated each PC is with the genes of
            interest (ordered by decreasing eigenvalues).