CCAN modules detection

circe.ccan_module.add_ccans(atac, peak1_col='Peak1', peak2_col='Peak2', score_col='score', coaccess_cutoff_override=None, tolerance_digits=2, verbose=False, seed=42, ccan_col='CCAN')

Extract co-accessible networks (CCANs) from an AnnData object and add them to the var slot.

Parameters:
  • atac (anndata.AnnData) – The AnnData object containing the data and the connections in the var slot.

  • peak1_col (str) – Name of the column for the first peak.

  • peak2_col (str) – Name of the column for the second peak.

  • score_col (str) – Name of the column for the score.

  • coaccess_cutoff_override (float or None) – Optional cutoff for coaccessibility. Must be between 0 and 1.

  • tolerance_digits (int) – The number of decimal places to consider for determining the cutoff.

  • verbose (bool) – If True, prints additional information during the process.

Returns:

The modified AnnData object with CCANs added to var.

Return type:

anndata.AnnData

circe.ccan_module.find_ccan_cutoff(connection_df, tolerance_digits=2, seed=42)

Find the optimal cutoff value for coaccess based on specified tolerance.

This function iteratively searches for a cutoff value that results in a significant change in the number of co-accessible networks (CCANs).

Parameters:
  • connection_df (pandas.DataFrame) – A DataFrame containing the connections, must include a ‘score’ column.

  • tolerance_digits (int) – The number of decimal places to consider for determining the cutoff.

Returns:

The optimal cutoff value rounded to the specified number of decimal places.

Return type:

float

circe.ccan_module.find_ccans(connections_df, peak1_col='Peak1', peak2_col='Peak2', score_col='score', coaccess_cutoff_override=None, tolerance_digits=2, verbose=True, seed=42)

Generate co-accessible networks (CCANs) from connection data.

Parameters:
  • connections_df (pandas.DataFrame) – A DataFrame containing specified columns for peaks and scores.

  • peak1_col (str) – Name of the column for the first peak.

  • peak2_col (str) – Name of the column for the second peak.

  • score_col (str) – Name of the column for the score.

  • coaccess_cutoff_override (float or None) – Optional cutoff for coaccessibility. Must be between 0 and 1.

  • tolerance_digits (int) – The number of decimal places to consider for determining the cutoff.

Returns:

A DataFrame with Peaks and their corresponding CCANs.

Return type:

pandas.DataFrame

circe.ccan_module.make_ccan_graph(connections_df, coaccess_cutoff, peak1_col='Peak1', peak2_col='Peak2', score_col='score')

Create an undirected graph from a DataFrame of connections.

This function generates an undirected graph based on the provided edge list, using specified columns for source, target, and edge weights. It filters connections based on a specified coaccess cutoff.

Parameters:
  • connections_df (pandas.DataFrame or dict) – A DataFrame or dictionary containing the edge list with connections. Must include columns for the source, target, and edge weights.

  • coaccess_cutoff (float) – The threshold value for filtering edges based on coaccess. Only connections with coaccess greater than this value will be included in the graph.

  • source_col (str, optional) – The name of the column in the DataFrame representing the source nodes (default is “Peak1”).

  • target_col (str, optional) – The name of the column in the DataFrame representing the target nodes (default is “Peak2”).

  • weight_col (str, optional) – The name of the column in the DataFrame representing the edge weights (default is “score”).

Returns:

The resulting undirected graph object.

Return type:

networkx.Graph

Raises:

ValueError – If no connections meet the coaccess cutoff criteria.

circe.ccan_module.number_of_ccans(connections_df, coaccess_cutoff, seed=42)

Count the number of co-accessible networks (CCANs) based on the Louvain method.

This function creates a graph from the given connections and applies the Louvain method to identify communities, then counts the number of communities with more than two members.

Parameters:
  • connections_df (pandas.DataFrame) – A DataFrame containing the connections, must include a ‘coaccess’ column.

  • coaccess_cutoff (float) – The cutoff value for coaccess used in graph construction.

Returns:

The number of co-accessible networks (CCANs) with more than two members.

Return type:

int