cosifer.combiners package

Submodules

cosifer.combiners.cit module

Combiner for interaction tables.

class cosifer.combiners.cit.CombineInteractionTables(combine_tables=<function mean_table>, interaction_symbol='<->', name='cit', **kwargs)

Bases: cosifer.combiners.network_combiner.NetworkCombiner

Combine interaction tables representing networks using a function.

name

name of the combiner.

Type

str

combine_tables

function to combine interaction tables.

Type

function

interaction_symbol

symbol used to indicate interactions in the index of the dataframe.

Type

str

graph

combined graph.

Type

cosifer.collections.Graph

cosifer.combiners.cit.combine_tables(table_list, interaction_symbol='<->', processing_concatenated_intensities_fn=<function <lambda>>, reduce_fn=<function <lambda>>, **kwargs)

Compute the combined intensities from a list of interaction tables.

Parameters
  • table_list (list) – a list of interaction tables.

  • interaction_symbol (str, optional) – symbol used to indicate interactions in the index of the dataframe. Defaults to ‘<->’.

  • processing_concatenated_intensities_fn (function, optional) – function to apply on the concatenated intensities. Defaults to identity.

  • reduce_fn (function, optional) – function to reduce intensities over dataframe rows. Defaults to mean.

Returns

the combined interaction table.

Return type

InteractionTable

cosifer.combiners.cit.get_scaled_ranks(dataframe)

Scaled ranks from an intensity dataframe.

Parameters

dataframe (pd.DataFrame) – intensity dataframe.

Returns

scaled ranks dataframe

Return type

pd.DataFrame

cosifer.combiners.cit.hard_mean_scaled_ranks_table(table_list, interaction_symbol='<->', **kwargs)

Compute the mean on the scaled ranks without considering interaction existence.

Parameters
  • table_list (list) – a list of interaction tables.

  • interaction_symbol (str, optional) – symbol used to indicate interactions in the index of the dataframe. Defaults to ‘<->’.

Returns

the combined interaction table.

Return type

InteractionTable

cosifer.combiners.cit.hard_mean_table(table_list, interaction_symbol='<->', **kwargs)

Compute the mean on the intensities without considering interaction existence.

Parameters
  • table_list (list) – a list of interaction tables.

  • interaction_symbol (str, optional) – symbol used to indicate interactions in the index of the dataframe. Defaults to ‘<->’.

Returns

the combined interaction table.

Return type

InteractionTable

cosifer.combiners.cit.max_scaled_ranks_table(table_list, interaction_symbol='<->', **kwargs)

Compute the maximum on the scaled ranks.

Parameters
  • table_list (list) – a list of interaction tables.

  • interaction_symbol (str, optional) – symbol used to indicate interactions in the index of the dataframe. Defaults to ‘<->’.

Returns

the combined interaction table.

Return type

InteractionTable

cosifer.combiners.cit.max_table(table_list, interaction_symbol='<->', **kwargs)

Compute the maximum on the intensities.

Parameters
  • table_list (list) – a list of interaction tables.

  • interaction_symbol (str, optional) – symbol used to indicate interactions in the index of the dataframe. Defaults to ‘<->’.

Returns

the combined interaction table.

Return type

InteractionTable

cosifer.combiners.cit.mean_scaled_ranks_table(table_list, interaction_symbol='<->', **kwargs)

Compute the mean on the scaled ranks.

Parameters
  • table_list (list) – a list of interaction tables.

  • interaction_symbol (str, optional) – symbol used to indicate interactions in the index of the dataframe. Defaults to ‘<->’.

Returns

the combined interaction table.

Return type

InteractionTable

cosifer.combiners.cit.mean_table(table_list, interaction_symbol='<->', **kwargs)

Compute the mean on the intensities.

Parameters
  • table_list (list) – a list of interaction tables.

  • interaction_symbol (str, optional) – symbol used to indicate interactions in the index of the dataframe. Defaults to ‘<->’.

Returns

the combined interaction table.

Return type

InteractionTable

cosifer.combiners.cit.median_scaled_ranks_table(table_list, interaction_symbol='<->', **kwargs)

Compute the median on the scaled ranks.

Parameters
  • table_list (list) – a list of interaction tables.

  • interaction_symbol (str, optional) – symbol used to indicate interactions in the index of the dataframe. Defaults to ‘<->’.

Returns

the combined interaction table.

Return type

InteractionTable

cosifer.combiners.cit.median_table(table_list, interaction_symbol='<->', **kwargs)

Compute the median on the intensities.

Parameters
  • table_list (list) – a list of interaction tables.

  • interaction_symbol (str, optional) – symbol used to indicate interactions in the index of the dataframe. Defaults to ‘<->’.

Returns

the combined interaction table.

Return type

InteractionTable

cosifer.combiners.cit.min_scaled_ranks_table(table_list, interaction_symbol='<->', **kwargs)

Compute the minimum on the scaled ranks.

Parameters
  • table_list (list) – a list of interaction tables.

  • interaction_symbol (str, optional) – symbol used to indicate interactions in the index of the dataframe. Defaults to ‘<->’.

Returns

the combined interaction table.

Return type

InteractionTable

cosifer.combiners.cit.min_table(table_list, interaction_symbol='<->', **kwargs)

Compute the minimum on the intensities.

Parameters
  • table_list (list) – a list of interaction tables.

  • interaction_symbol (str, optional) – symbol used to indicate interactions in the index of the dataframe. Defaults to ‘<->’.

Returns

the combined interaction table.

Return type

InteractionTable

cosifer.combiners.core module

Core combiner utilities.

cosifer.combiners.core.combined_df_to_interaction_table(combined, table_list, interaction_symbol='<->')

Transform combined intensities dataframe into an InteractionTable.

Parameters
  • combined (pd.DataFrame) – combined intensities dataframe.

  • table_list (list) – a list of InteractionTable objects.

  • interaction_symbol (str, optional) – symbol used to indicate interactions in the index of the dataframe. Defaults to ‘<->’.

Returns

an InteractionTable representing the combined

intensities.

Return type

InteractionTable

cosifer.combiners.core.concatenate_intensities(table_list, threshold_rate=None)

Concatenate intensities from a list of InteractionTable objects.

Parameters
  • table_list (list) – a list of InteractionTable objects.

  • threshold_rate (float, optional) – threshold rate for the NAs. Defaults to None, a.k.a no threshold applied.

Returns

an InteractionTable representing the combined

intensities.

Return type

InteractionTable

cosifer.combiners.network_combiner module

Interface for a network combiner.

class cosifer.combiners.network_combiner.NetworkCombiner(filepath=None, **kwargs)

Bases: cosifer.handlers.network_handler.NetworkHandler

Abstract interface for a network combiner.

trained

flag to indicate whether the combiner is already trained.

Type

bool

combine(results_list)

Apply the combination method. Checking whehter the combiner has been already trained.

Parameters

results_list (list) – a list of InteractionTable objects.

cosifer.combiners.snf module

SNF combiner.

class cosifer.combiners.snf.SNF(interaction_symbol='<->', name='snf', **kwargs)

Bases: cosifer.combiners.network_combiner.NetworkCombiner

Combine interaction tables representing networks using SNF.

interaction_symbol

symbol used to indicate interactions in the index of the dataframe.

Type

str

name

name of the combiner.

Type

str

cosifer.combiners.snf.compute_snf(results_list, labels, K=20, T=10, snf=rpy2.robjects.packages.Package as a <module 'SNFtool'>)

Compute combination via SNF.

Parameters
  • results_list (list) – a list of InteractionTable objects.

  • labels (list) – labels to consider.

  • K (int, optional) – number of nearest neighbors. Defaults to 20.

  • T (int, optional) – number of steps in the diffusion process. Defaults to 10.

  • snf (object, optional) – SNF rpy2 object. Defaults to importr(‘SNFtool’).

Returns

the combined graph.

Return type

Graph

cosifer.combiners.summa module

Combiner using SUMMA.

class cosifer.combiners.summa.Summa(interaction_symbol='<->', name='summa', **kwargs)

Bases: cosifer.combiners.network_combiner.NetworkCombiner

SUMMA algorithm for combining results.

interaction_symbol

symbol used to indicate interactions in the index of the dataframe.

Type

str

name

name of the combiner.

Type

str

summa_object

SUMMA object.

Type

pySUMMA.Summa

summa_object = None
cosifer.combiners.summa.fill_na_ranks(a_series)

Fill NA ranks in a pd.Series.

Parameters

a_series (pd.Series) – series to fill.

Returns

the filled series.

Return type

pd.Series

cosifer.combiners.summa.summa_scores_table(table_list, interaction_symbol='<->', **kwargs)

Apply SUMMA as a method on list of interaction tables.

Parameters
  • table_list (list) – a list of InteractionTable objects.

  • interaction_symbol (str, optional) – symbol used to indicate interactions in the index of the dataframe. Defaults to ‘<->’.

Returns

interaction table with SUMMA scores.

Return type

InteractionTable

Module contents

Combiner module.