pymodulon.core

Core functions for the IcaData object

Module Contents

Classes

IcaData

Class representation of all iModulon-related data

MotifInfo

class pymodulon.core.IcaData(M, A, X=None, log_tpm=None, gene_table=None, sample_table=None, imodulon_table=None, trn=None, dagostino_cutoff=None, optimize_cutoff=False, thresholds=None, threshold_method='dagostino', motif_info=None, imodulondb_table=None, gene_links=None, tf_links=None)[source]

Bases: object

Class representation of all iModulon-related data

property M(self)[source]

Get M matrix

property M_binarized(self)[source]

Get binarized version of M matrix based on current thresholds

property A(self)[source]

Get A matrix

property X(self)[source]

Get X matrix

property log_tpm(self)[source]

Get ‘log_tpm’ matrix

property imodulon_names(self)[source]

Get iModulon names

property sample_names(self)[source]

Get sample names

property gene_names(self)[source]

Get gene names

property gene_table(self)[source]

Get gene table

property sample_table(self)[source]

Get sample table

property imodulon_table(self)[source]

Get table of iModulons

property trn(self)[source]

Get table with TRN information

property motif_info(self)[source]

Get motif info

_update_imodulon_names(self, new_names)[source]

Iterates and updates iModulon names

Parameters

new_names (list) – New names to update iModulons

Returns

None

Return type

None

rename_imodulons(self, name_dict=None, column=None)[source]

Rename an iModulon.

Parameters
  • name_dict (dict) – Dictionary mapping old iModulon names to new names (e.g. {old_name:new_name}) (default: None)

  • column (str) – Uses a column from the iModulon table to rename iModulons ( default: None)

Returns

None

Return type

None

view_imodulon(self, imodulon)[source]

View genes in an iModulon and show relevant information about each gene.

Parameters

imodulon (int or str) – Name of iModulon

Returns

final_rows – Table showing iModulon gene information

Return type

DataFrame

find_single_gene_imodulons(self, save=False)[source]

A simple function that returns the names of all likely single-gene iModulons. Checks if the largest iModulon gene weight is more than twice the weight of the second highest iModulon gene weight.

Parameters

save (bool) – If true, save output to imodulon_table (default: False)

Returns

single_genes_imodulons – List of single-gene iModulons

Return type

list

_update_imodulon_table(self, enrichment)[source]

Update iModulon table given new iModulon enrichments

Parameters

enrichment (Series or DataFrame iModulon enrichment) –

Returns

None

Return type

None

compute_regulon_enrichment(self, imodulon, regulator, save=False, evidence=None)[source]

Compare an iModulon against a regulon. (Note: q-values cannot be computed for single enrichments)

Parameters
  • imodulon (int or str) – Name of ‘iModulon’

  • regulator (str) – TF name, or complex regulon, where “/” uses genes in any regulon and “+” uses genes in all regulons

  • save (bool) – If true, save enrichment score to the imodulon_table (default: True)

  • evidence (list or str) – ‘Evidence’ level of TRN interactions to include during TRN enrichment (default: None)

Returns

enrich – Table containing enrichment statistics

Return type

Series

compute_trn_enrichment(self, imodulons=None, fdr=1e-05, max_regs=1, save=False, method='both', force=False, evidence=None)[source]

Compare iModulons against all regulons in the TRN

Parameters
  • imodulons (int or str) – Name of iModulon(s). If none given, compute enrichments for all ‘iModulons’ (default: None)

  • fdr (float) – False detection rate (default: 1e-5)

  • max_regs (int) – Maximum number of regulators to include in complex regulon ( default: 1)

  • save (bool) – Save regulons with highest enrichment scores to the imodulon_table (default: False)

  • method (str) – How to combine multiple regulators (default: ‘both’). ‘or’ computes enrichment against union of regulons, ‘and’ computes enrichment against intersection of regulons, and ‘both’ performs both tests

  • force (bool) – If false, prevents computation of >2 regulators (default: False)

  • evidence (list or str) – Evidence level of TRN interactions to include during TRN enrichment

Returns

df_enriched – Table of statistically significant enrichments

Return type

DataFrame

compute_annotation_enrichment(self, annotation, column, imodulons=None, fdr=0.1)[source]

Compare iModulons against a gene annotation table

Parameters
  • annotation (DataFrame) – Table containing two columns: the gene locus tag, and its appropriate annotation

  • column (str) – Name of the column containing the annotation

  • imodulons (list or str or int) – Name of iModulon(s). If none given, compute enrichments for all iModulons (default: None)

  • fdr (float) – False detection rate (default: 0.1)

Returns

DF_enriched – Table of statistically significant enrichments

Return type

DataFrame

property dagostino_cutoff(self)[source]

Get D’agostino cutoff

property cutoff_optimized(self)[source]
property thresholds(self)[source]

Get thresholds

change_threshold(self, imodulon, value)[source]

Set threshold for an iModulon

Parameters
  • imodulon (int or str) – Name of iModulon

  • value (float) – New threshold

Returns

None

Return type

None

recompute_thresholds(self, dagostino_cutoff)[source]

Re-computes iModulon thresholds using a new D’Agostino cutoff

Parameters

dagostino_cutoff (int) – New D’agostino cutoff statistic

Returns

None

Return type

None

_update_thresholds(self, dagostino_cutoff)[source]
Parameters

dagostino_cutoff (int) –

reoptimize_thresholds(self, progress=True, plot=True)[source]

Re-optimizes the D’Agostino statistic cutoff for defining iModulon thresholds if the TRN has been updated

Parameters
  • progress (bool) – Show a progress bar (default: True)

  • plot (bool) – Show the sensitivity analysis plot (default: True)

Returns

New D’agostino cutoff

Return type

int

_optimize_dagostino_cutoff(self, progress, plot)[source]

Computes an abridged version of the TRN enrichments for the 20 highest-weighted genes in order to determine a global minimum for the D’Agostino cutoff ultimately used to threshold and define the genes “in” an iModulon

Parameters
  • progress (bool) – Show a progress bar (default: True)

  • plot (bool) – Show the sensitivity analysis plot (default: True)

Returns

New D’agostino cutoff

Return type

int

_kmeans_cluster(self, imodulon)[source]
compute_kmeans_thresholds(self)[source]

Computes iModulon thresholds using K-means clustering

Returns

None

Return type

None

copy(self)[source]

Make a deep copy of an IcaData object

Returns

IcaData – Copy of IcaData object

Return type

IcaData

imodulons_with(self, gene)[source]

Lists the iModulons containing a gene

Parameters

gene (str) – Gene name or locus tag

Returns

List of iModulons containing the gene

Return type

list

name2num(self, gene)[source]

Convert a gene name to the locus tag

Parameters

gene (list or str) – Gene name or list of gene names

Returns

final_list – Locus tag or list of locus tags

Return type

list or str

num2name(self, gene)[source]

Get the name of a gene from its locus tag

Parameters

gene (list or str) – Locus tag or list of locus tags

Returns

result – Gene name or list of gene names

Return type

list or str

property imodulondb_table(self)[source]
class pymodulon.core.MotifInfo(motifs, sites, cmd, file, matches=None)[source]
__repr__(self)[source]

Return repr(self).

property motifs(self)[source]
property sites(self)[source]
property cmd(self)[source]
property file(self)[source]
property matches(self)[source]