tdm.tissue.Tissue#
- class tdm.tissue.Tissue(single_cell_df: DataFrame, cell_types: list[str], tissue_dimensions: tuple[float, float] | None = None)[source]#
A tissue represents one real-life tissue section.
- __add__(other: Tissue) Tissue [source]#
Add two Tissue objects together by creating a new Tissue object with cells from both tissues.
- __init__(single_cell_df: DataFrame, cell_types: list[str], tissue_dimensions: tuple[float, float] | None = None)[source]#
Initialize the tissue from a subset of the single_cell_df corresponding with a single img_id (see Preprocessing).
- Parameters:
single_cell_df (pd.DataFrame) – a subset of the single_cell_df corresponding with a single img_id (see: Preprocessing)
cell_types (list[str]) – list of supported cell types.
tissue_dimensions (tuple[float, float] | None, optional) – maximal x,y limits of the tissue section (assumes coordinates start at 0,0). Defaults to the maximal x,y values in the data.
- cell_df() DataFrame [source]#
Returns the subset of the single_cell_df containing information this tissue (see: Preprocessing)
- Returns:
The DataFrame containing cell information.
- Return type:
pd.DataFrame
- cell_types() list[str] [source]#
List of cell types supported by this tissue.
Note
A tissue supporting a list of cell_types might not have an instance of each one of them. The reason is that we want to be clear which cell types are included in this analysis.
- property img_id#
A unique identifier of the tissue.
- n_cells(cell_type: str | None = None, neighborhood_size: float | None = None) float [source]#
Number of cells in the tissue.
Note
Returns a float type only if result is scaled to a specific neighborhood size (i.e neighborhood_size is not None)
- Parameters:
cell_type (str | None, optional) – return only the number of this cell type. Defaults to None.
neighborhood_size (float | None, optional) – scale the number of cells to match a neighborhood with the same density. Defaults to None.
- Returns:
number of cells
- Return type:
float
- present_cell_types() list[str] [source]#
List of cell types with at least one cell in the tissue.
- Returns:
List of cell types.
- Return type:
list[str]
- property subject_id#
A unique identifier of the patient.