code: def calculate_regression_PCs(self, genes=None, npcs=None, plot=False):
          
          from sklearn.decomposition import PCA
  
          if npcs is None:
              npcs = self.adata.X.shape[0]
  
          pca = PCA(n_components=npcs)
          pc = pca.fit_transform(self.adata.X.toarray())
  
          self.regression_pca = pca
          self.regression_pcs = pc
  
          gene_names = np.array(list(self.adata.var_names))
          if(genes is not None):
              idx = np.where(np.in1d(gene_names, genes))[0]
              sx = pca.components_[:, idx]
              x = np.abs(sx).mean(1)
  
              if plot:
                  plt.figure()
                  plt.plot(x)
  
              return x
          else:
              return
docs: 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).