code: def calculate_cpm(x, axis=1):
      """Calculate counts-per-million on data where the rows are genes.
  
      Parameters
      ----------
      x : array_like
      axis : int
          Axis accross which to compute CPM. 0 for genes being in rows and 1 for
          genes in columns.
  
      """
      normalization = np.sum(x, axis=axis)
      # On sparse matrices, the sum will be 2d. We want a 1d array
      normalization = np.squeeze(np.asarray(normalization))
      # Straight up division is not an option since this will form a full dense
      # matrix if `x` is sparse. Divison can be expressed as the dot product with
      # a reciprocal diagonal matrix
      normalization = sp.diags(1 / normalization, offsets=0)
      if axis == 0:
          cpm_counts = np.dot(x, normalization)
      elif axis == 1:
          cpm_counts = np.dot(normalization, x)
      return cpm_counts * 1e6
  
file_path: openTSNE/examples/utils.py
imports: from os.path import abspath, dirname, join
  import numpy
  import scipy.sparse
label_desc: Use image node_id 1 for calling a global function with example usage: calculate_cpm(x, axis) and returns: unknown