GGM
glc.GGM
Container for GGM results and graph computation.
This class loads a Gaussian graphical model (GGM) adjacency matrix from a CSV file or a pandas DataFrame, constructs a NetworkX graph, extracts the largest connected component, and builds a lookup of partial correlations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ggm_source
|
str | DataFrame
|
Either a file path to a CSV containing the GGM adjacency matrix, or a pandas DataFrame containing the adjacency matrix. The DataFrame must have feature labels as its index. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
_ggm_df |
DataFrame
|
DataFrame containing the adjacency matrix. |
feat_labels |
list[str]
|
List of feature names corresponding to graph nodes. |
adj_mx |
ndarray
|
Raw adjacency matrix representing partial correlations. |
G |
Graph
|
Main connected subgraph extracted from the adjacency matrix. |
pcor_dict |
Dict[str, float]
|
Dictionary mapping " |
Source code in src/glc/load_ggm.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
__init__(ggm_source)
Initialize the GGM container.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ggm_source
|
str | DataFrame
|
Path to the GGM adjacency matrix CSV file, or a pandas DataFrame containing the adjacency matrix with feature labels as the index. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If a DataFrame is provided without an index. |
Source code in src/glc/load_ggm.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |
glc.EstGGM
A wrapper class to estimate Gaussian Graphical Models (GGM) from feature table intensities using the GeneNet package in R.
Attributes:
| Name | Type | Description |
|---|---|---|
int_array |
ndarray
|
Preprocessed intensity data as a 2D numpy array (features x samples). |
feat_labels |
List[str]
|
List of feature labels corresponding to rows in int_array. |
alpha |
float
|
Significance level for edge extraction in the GGM. |
Source code in src/glc/load_ggm.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
__init__(int_array, feat_labels, alpha=0.05)
Initialize the EstGGM class with preprocessed intensity data and feature labels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
int_array
|
ndarray
|
Preprocessed intensity data (features x samples). |
required |
feat_labels
|
List[str]
|
Feature labels corresponding to int_array rows. |
required |
alpha
|
float
|
Significance level for edge extraction in the GGM. Defaults to 0.05. |
0.05
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the number of rows in int_array does not match the length of feat_labels. |
Source code in src/glc/load_ggm.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
run_ggm()
Estimate the Gaussian Graphical Model using GeneNet in R
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: Symmetric adjacency matrix of partial correlations between features. |
Source code in src/glc/load_ggm.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |