code: def write_hdf5_cells(E, filename):
      '''SPRING standard: filename = main_spring_dir + "counts_norm_sparse_cells.hdf5" '''
  
      E = E.tocsr()
  
      hf = h5py.File(filename, 'w')
      counts_group = hf.create_group('counts')
      gix_group = hf.create_group('gene_ix')
  
      hf.attrs['ncells'] = E.shape[0]
      hf.attrs['ngenes'] = E.shape[1]
  
      for iC in range(E.shape[0]):
          counts = E[iC,:].A.squeeze()
          gene_ix = np.nonzero(counts)[0]
          counts = counts[gene_ix]
          counts_group.create_dataset(str(iC), data = counts)
          gix_group.create_dataset(str(iC), data = gene_ix)
  
      hf.close(f write_hdf5_cells(E, filename):
      '''SPRING standard: filename = main_spring_dir + "counts_norm_sparse_cells.hdf5" '''
  
      E = E.tocsr()
  
      hf = h5py.File(filename, 'w')
      counts_group = hf.create_group('counts')
      gix_group = hf.create_group('gene_ix')
  
      hf.attrs['ncells'] = E.shape[0]
      hf.attrs['ngenes'] = E.shape[1]
  
      for iC in range(E.shape[0]):
          counts = E[iC,:].A.squeeze()
          gene_ix = np.nonzero(counts)[0]
          counts = counts[gene_ix]
          counts_group.create_dataset(str(iC), data = counts)
          gix_group.create_dataset(str(iC), data = gene_ix)
  
      hf.close()
docs: SPRING standard: filename = main_spring_dir + "counts_norm_sparse_cells.hdf5"