anndata_fcs#

Attributes#

Functions#

anndata_to_fcs(adata)

Create fcs object from anndata.

fcs_to_anndata(fdata[, include_metadata])

Converts FlowData instance to AnnData object.

fcs_to_dataframe(fdata)

Converts FlowData instance to pandas DataFrame.

gate_polygon(fdata, x, y, polygon)

Gate channel x and y of FlowData instance with polygon.

gate_polygon_subset(fdata, x, y, polygon)

Gating polygon on flow data object and returning subset.

scatter(data, x, y[, xscale, yscale, density, gates, ...])

Plot scatter from FCS data.

Package Contents#

anndata_fcs.__version__: str = '0.1.0'#
anndata_fcs.anndata_to_fcs(adata)#

Create fcs object from anndata.

Parameters:

adata (anndata.AnnData) – AnnData object to convert.

Returns:

FlowData instance.

Return type:

flowio.FlowData

Raises:

AssertionError – If array conversion fails.

anndata_fcs.fcs_to_anndata(fdata, include_metadata=True)#

Converts FlowData instance to AnnData object.

Parameters:
  • fdata (flowio.FlowData) – FlowData instance to convert.

  • include_metadata (bool, optional) – If True is adds to FCS file meta data and .uns of the AnnData object.

Returns:

AnnData object.

Return type:

anndata.AnnData

anndata_fcs.fcs_to_dataframe(fdata)#

Converts FlowData instance to pandas DataFrame.

Parameters:

fdata (flowio.FlowData) – FlowData instance to convert.

Returns:

Pandas dataframe.

Return type:

pandas.DataFrame

anndata_fcs.gate_polygon(fdata, x, y, polygon)#

Gate channel x and y of FlowData instance with polygon.

Parameters:
Returns:

List of boolean with length of events per channel, where True indicated that point is inside the polygon.

Return type:

collections.abc.Sequence[bool]

anndata_fcs.gate_polygon_subset(fdata, x, y, polygon)#

Gating polygon on flow data object and returning subset.

Parameters:
Returns:

Subset on fdata object, only containing events inside of polygon.

Return type:

flowio.FlowData

anndata_fcs.scatter(data, x, y, xscale='log', yscale='log', density=False, gates=None, gate_color='black', highlight=None, highlight_color='red', color='black', ax=None, figsize=(5, 5))#

Plot scatter from FCS data.

Parameters:
  • data (Union[pandas.DataFrame, flowio.FlowData, anndata.AnnData]) – Event data. Argument can be DataFrame, AnnData or FlowData instance.

  • x (str) – Channel name for x coordinate.

  • y (str) – Channel name for y coordinate.

  • xscale (Literal["linear", "log", "symlog", "logit"], optional) – Scale of x axis. Defaults to log.

  • yscale (Literal["linear", "log", "symlog", "logit"], optional) – Scale of y axis. Defaults to log.

  • density (bool, optional) – Show denity as color. Defaults to False. scipy is required for this option.

  • gates (Optional[Dict[str, collections.abc[collections.abc[Union[int, float]]]]], optional) – Dict of gates, where the key indicated to name of the gate and the value describes to polygon. Defaults to None.

  • gate_color (str, optional) – Color of gate. Defaults to "black".

  • highlight (Optional[List[bool]], optional) – List of events to highlight. Defaults to None.

  • highlight_color (str, optional) – Color of events. Defaults to "red",

  • color (str) – Color of default event. Defaults to "black".

  • ax (Optional[matplotlib.axes.Axes], optional) – Matplotlib axes. Default to None.

  • figsize (Tuple[int, int], optional) – Figure size. Defaults to (5, 5).

Returns:

Axes instance.

Return type:

matplotlib.axes.Axes

Raises:
  • NotImplementedError – If data if other type than DataFrame, AnnData oder FlowData.

  • ImportError – If denity=True and scipy is not installed.

  • AssertionError – If length of highlight does not match with length of data.

  • AssertionError – If x and y gate boundaries could not be calculated.