foxreg package

Submodules

foxreg.core module

class foxreg.core.ComparisonTree(cond1, ras_data, metaData_RAS_column, rss_data, colnames, rownames, threshold_file)

Bases: object

__init__(cond1, ras_data, metaData_RAS_column, rss_data, colnames, rownames, threshold_file)

Constructor

Parameters:
  • cond1 (str) – control treatments

  • ras_data (pandas.DataFrame) – AUCell matrix and metadata

  • metaData_RAS_column (list) – cell cluster

  • rss_data (pandas.DataFrame) – RSS matrix

  • colnames (list) – clusters of interest

  • rownames (list) – rownames of each of your regulons

  • threshold_file (pandas.DataFrame) – Calculated by SCENIC

analyze_factors(cond2, percentages=False)
_summary_

Returns the components matrix

Parameters:
  • cond2 (string) – Experimental group name

  • percentages (bool, optional) – Row normalizes component per each row.

calc_global_dictonary()

_summary_ Calculates dictionary for entire tree to query all cell clusters

Returns:

Dictionary that describes spatial relationships to all different experimental groups

Return type:

dict

compareLayers(layer1, layer2, distance, font=6.5)

_summary_

Compare between two different layers

Parameters:
  • layer1 (String) – Cell Cluster 1

  • layer2 (String) – Cell Cluster 2

  • distance (float) – Distance to query

  • font (float, optional) – _description_. Defaults to 6.5.

compute_tau_and_kdtree()

_summary_ Initialize the comparisons across baseline and different experimental treatments

construct_3D_embedding(rawRSS=False)

_summary_ Unify all components (X, Y, Z) from NMF calculation from each experimental group :param rawRSS: Plot raw RSS values. Defaults to False. :type rawRSS: bool, optional

construct_tree()

_summary_ Init class to map tau and assemble KDtree

create_global_tree(leaf_size=10)

_summary_ Calculates the KDtree for all experimental conditions

Parameters:

leaf_size (int, optional) – Leaf size for Kdtree parameter. Defaults to 10.

Returns:

KDtree, dict

Return type:

tuple

initDict(label)
init_order()

_summary_ Construct the order of each layer (lowest -> highest) for 3D plane comparison

map_labels_to_tau()

_summary_ Generate a tau as a hash for embedding comparison

nmf_transform(rss_data)

_summary_ NMF implemented here, sets random state = 42 :param rss_data: _description_ :type rss_data: _type_

Returns:

W[0], W[1], W, H

Return type:

tuple

plotRSS_NMF(cond2, drawQuadrants=True, include_pvals=False, alpha=0.05, tryLabel='')

_summary_

Parameters:
  • cond2 (String) – Experimental group

  • drawQuadrants (bool, optional) – Draw quadrants to separate out regions. Defaults to True.

  • include_pvals (bool, optional) – Perform hypergeomtric testing. Defaults to False.

  • alpha (float, optional) – FDR rate. Defaults to 0.05.

  • tryLabel (str, optional) – _description_. Defaults to “”.

Returns:

P-vals of hypergeomtric output of each regulon calculated

Return type:

_type_

plot_3dEmbedding(rawRSS=False, regulonsToView=[], clustersToLabel=[])

_summary_ Plot on 3D space :param rawRSS: Raw RSS values. Defaults to False. :type rawRSS: bool, optional :param regulonsToView: Pick which regulons to see what to change. Defaults to []. :type regulonsToView: list, optional :param clustersToLabel: Pick which experimental treatments to see labeled regulons. Defaults to []. :type clustersToLabel: list, optional

return_the_tau_pval()
sort_and_print_labels()

_summary_ Show the experimental groups with their corresponding hash value

foxreg.diagnostics module

foxreg.diagnostics.calculate_metrics(r2, rss, tss, coef)

Calculate final metrics: - The correlation coefficient (r) as the square root of R², adjusted for the sign of the coefficient. - The rounded R², TSS, and RSS values for reporting.

foxreg.diagnostics.calculate_r2_and_coefficients(condx, condy)

Perform linear regression on the provided data (condx, condy), and return the R², RSS (Residual Sum of Squares), TSS (Total Sum of Squares), and the regression coefficients.

foxreg.diagnostics.check_r2_consistency(r2, rss, tss)

Check if the calculated R² is consistent with the given RSS and TSS. This should hold: R² = 1 - (RSS / TSS)

foxreg.diagnostics.process_data_for_labels(labels, NMF_embedd)

Process data for each label and calculate R², RSS, TSS, and the correlation coefficient. Returns a dictionary where the key is the label, and the value is a tuple of calculated metrics.

Module contents