gefslim.GEF#

class gefslim.GEF(result_dir)#

A class that provides methods for interacting with .gef files.

result_dir#

The directory where the .gef files are located.

Type

str

data#

A dictionary that stores the loaded data from the .gef files.

Type

dict

Methods table#

get_area_per_cell(name)

Retrieve the size in pixels of each cell from a cellcut file.

get_cell_borders(name[, transformed])

Extract the spatial information per cell from a cellcut file.

get_counts_per_cell(name)

Retrieve the number of probes per cell from a cellcut file.

get_gene_stats(name)

Retrieve gene statistics from a HDF5 file and return it as a sorted DataFrame.

get_genecounts_per_cell(name)

Retrieve the counts per gene per cell.

get_genecounts_per_spot(name[, binsize])

Calculate gene counts per specified bin size around a spot (x/y).

read_cellcut(name)

Read a cellcut file and return an AnnData object.

Methods#

GEF.get_area_per_cell(name)#

Retrieve the size in pixels of each cell from a cellcut file.

Parameters

name (str) – The name of the cellcut file.

Return type

DataFrame

Returns

pd.DataFrame A DataFrame containing the ‘cell_id’ and ‘area’ for each cell.

GEF.get_cell_borders(name, transformed=True)#

Extract the spatial information per cell from a cellcut file.

Parameters
  • name (str) – The name of the cellcut file.

  • transformed (bool, optional) – Whether or not to transform the cell’s border data. If True, each point in the border data will have the cell’s x and y values added to it. Default is True.

Return type

DataFrame

Returns

pd.DataFrame A DataFrame containing the cell’s ID and its border data. If ‘transformed’ is False, the cell’s x and y values are also included.

GEF.get_counts_per_cell(name)#

Retrieve the number of probes per cell from a cellcut file.

Parameters

name (str) – The name of the cellcut file.

Return type

DataFrame

Returns

pd.DataFrame A DataFrame with ‘cell_id’ and ‘counts’ columns, where ‘counts’ represents the number of probes per cell. Returns an empty DataFrame if an error occurs during the read operation.

GEF.get_gene_stats(name)#

Retrieve gene statistics from a HDF5 file and return it as a sorted DataFrame.

Parameters

name (str) – Name of the gene file.

Return type

DataFrame

Returns

pd.DataFrame DataFrame containing gene statistics. Columns include ‘gene’, ‘MIDcount’, and ‘E10’. The DataFrame is sorted in descending order by ‘MIDcount’ column and the index is reset.

GEF.get_genecounts_per_cell(name)#

Retrieve the counts per gene per cell.

Parameters

name (str) – The name of the .gef file.

Return type

DataFrame

Returns

pd.DataFrame A DataFrame sorted by ‘cell_id’ and ‘gene’, containing genes, cell IDs and corresponding gene counts. Columns are ‘gene’, ‘cell_id’ and ‘counts’.

GEF.get_genecounts_per_spot(name, binsize=100)#

Calculate gene counts per specified bin size around a spot (x/y).

Parameters
  • name (str) – The name of the gene expression file.

  • binsize (int, optional) – The size of the bin for which the gene counts are calculated. Defaults to 100.

Return type

DataFrame

Returns

pd.DataFrame DataFrame containing x, y coordinates, gene, and corresponding counts, sorted by x, y and gene.

GEF.read_cellcut(name)#

Read a cellcut file and return an AnnData object.

Parameters

name (str) – The name of the cellcut file.

Return type

AnnData

Returns

anndata.AnnData An AnnData object containing cellcut data. The .obs_names attribute is set to the ‘id’ field from the cellcut data, and the .var_names attribute is set to the names of the cellcut data fields.