SIGnature.SIGnature#

class SIGnature.SIGnature.SIGnature(gene_order, attribution_tiledb_uri=None)[source]#

Bases: object

A class for working with single cell gene attributions.

Parameters:
  • gene_order (list) – The gene order for the model.

  • attributions_tiledb_uri (str) – The URI to the attributions tiledb.

  • attribution_tiledb_uri (str | None)

Examples

>>> sig = SIGnature(gene_order=gene_order)
check_genes(gene_list, print_missing=True)[source]#

Checks genes and returns ones usable by query.

Parameters:
  • gene_list (list) – A list of genes of interest.

  • print_missing (bool) – Print the genes not in the model’s gene order.

Returns:

A list of usable genes.

Return type:

list

Examples

>>> gene_list = sig.check_genes(gene_list)
create_tiledb(npz_path, batch_size=25000, attribution_tiledb_uri=None, overwrite=False, attr_name='vals', xdim_name='x', ydim_name='y')[source]#

Create a sparse TileDB array from attribution matrix.

Parameters:
  • npz_path (str) – Filename for the stored attribution matrix.

  • batch_size (int, default: 10000) – Batch size for the tiles.

  • attributions_tiledb_uri (str) – The URI to the attributions tiledb.

  • overwrite (bool, default: False) – Overwrite the existing TileDB.

  • attr_name (str, default: "vals") – Name of the tiledb matrix value attribute.

  • xdim_name (str, default: "x") – Name of the tiledb matrix x dimensions.

  • ydim_name (str, default: "y") – Name of the tiledb matrix y dimensions.

  • attribution_tiledb_uri (str | None)

Examples

>>> sig.create_tiledb(npz_path="/opt/npz_attribution_matrices/data.npz")
query_attributions(gene_list, cell_indices=None, attribution_tiledb_uri=None, return_aggregate=True, aggregate_type='mean', weights=None, attr_name='vals', xdim_name='x', ydim_name='y')[source]#

Get attributions from sparse TileDB array.

Parameters:
  • gene_list (List[str]) – List of gene symbols.

  • cell_indices (Optional[List[int]], default: None) – List of cell indices.

  • attributions_tiledb_uri (str, optional) – The URI to the attributions tiledb.

  • return_aggregate (bool, default: True) – Return an aggregate of attributions for each cell.

  • aggregate_type (str, default: "mean") – Type of aggregation {“mean”, “sum”}.

  • weights (Optional[List[float]], default: None) – Weights for each gene when calculating weighted averages or sums. Must have the same length as gene_list.

  • attr_name (str, default: "vals") – Name of the tiledb matrix value attribute.

  • xdim_name (str, default: "x") – Name of the tiledb matrix x dimensions.

  • ydim_name (str, default: "y") – Name of the tiledb matrix y dimensions.

  • attribution_tiledb_uri (str | None)

Examples

>>> cleaned_genes = sig.check_genes(genes)
>>> sig.query_attributions(gene_list=cleaned_genes, attributions_tiledb_uri=tiledb_path)