alphapepttools.io.AnnDataFactory#

class alphapepttools.io.AnnDataFactory(psm_df, intensity_column, sample_id_column, feature_id_column)#

Factory class to convert AlphaBase PSM DataFrames to AnnData format.

Methods table#

create_anndata([var_columns, obs_columns])

Create AnnData object from PSM DataFrame.

from_files(file_paths[, reader_type, level, ...])

Create AnnDataFactory from PSM files.

Methods#

AnnDataFactory.create_anndata(var_columns=None, obs_columns=None)#

Create AnnData object from PSM DataFrame.

Parameters:
  • var_columns (Union[str, List[str]], optional) – Additional columns to include in var of the AnnData object, by default None

  • obs_columns (Union[str, List[str]], optional) – Additional columns to include in obs of the AnnData object, by default None

Return type:

AnnData

Returns:

ad.AnnData AnnData object where: - obs (rows) are raw names - var (columns) are proteins - X contains intensity values

classmethod AnnDataFactory.from_files(file_paths, reader_type='maxquant', level='proteins', *, intensity_column=None, feature_id_column=None, sample_id_column=None, additional_columns=None, **reader_kwargs)#

Create AnnDataFactory from PSM files.

Parameters:
  • file_paths (Union[str, List[str]]) – Path(s) to PSM file(s)

  • reader_type (str, optional) – Type of PSM reader to use, by default “maxquant”

  • level (str, optional) – Level of quantification to read. One of “proteins”, “precursors”, or “genes”. Defaults to “proteins”.

  • intensity_column (str, optional) – Name of the column storing intensity data. Default is taken from psm_reader.yaml

  • feature_id_column (str, optional) – Name of the column storing feature ids. Default is taken from psm_reader.yaml

  • sample_id_column (str, optional) – Name of the column storing sample ids. Default is taken from psm_reader.yaml

  • additional_columns (list[str], optional) – Names of additional columns from the PSM table to retain for experiment-specific metadata. These columns can be added to the resulting AnnData object as annotations. Note that if a column has a higher cardinality than the feature_id_column (i.e., multiple values per feature), only the first value encountered will be kept.

  • **reader_kwargs – Additional arguments passed to PSM reader

Return type:

AnnDataFactory

Returns:

AnnDataFactory Initialized AnnDataFactory instance