ladder.data.real_data.AnndataConverter#

class ladder.data.real_data.AnndataConverter(metadata_df)#

Class used to convert tensor datasets into an AnnData object.

This class allows for arbitrary subsets of tensors to be mapped back into an object that looks like the subset of the original object. Inherits MetadataConverter.

Parameters:

metadata_df (DataFrame) – The dataframe object that includes the metadata, which is obs for most cases.

Methods table#

map_to_anndat(val_tup)

Function to actually do the mapping to AnnData.

map_to_df(met_val_string)

The function that actually does the metadata mapping.

Methods#

AnndataConverter.map_to_anndat(val_tup)#

Function to actually do the mapping to AnnData.

Parameters:

val_tup (tuple) – Size 3 tuple of Tensor. The first index is used for counts. The second index provides labels, which are not used here as they are redundant but required for training. The third index provides the numerically encoded metadata.

Return type:

AnnData

Returns:

anndat : AnnData The anndata equivalent of the numerical Tensor objects.

AnndataConverter.map_to_df(met_val_string)#

The function that actually does the metadata mapping.

Parameters:

met_val_string (Tensor) – Tensor shaped like TensorDataset.

Return type:

ndarray

Returns:

metadata_mapping : ndarray Numerical tensor converted back to categorical equivalent.