Documentation for utils
module
grnndata.utils
Functions:
Name | Description |
---|---|
compute_cluster |
compute_cluster uses the igraph library to perform clustering on the GRN. |
compute_connectivities |
This function computes the connectivities of a given Gene Regulatory Network (GRN). |
enrichment |
This function performs enrichment analysis on a given gene regulatory network (grn). |
fileToList |
loads an input file with a\n b\n.. into a list [a,b,..] |
get_centrality |
get_centrality uses the networkx library to calculate the centrality of each node in the GRN. |
metrics |
metrics This function computes the following metrics for a given Gene Regulatory Network (GRN): |
plot_cluster |
This function plots the clusters of a given Gene Regulatory Network (GRN). |
Attributes: |
|
---|
TF = fileToList(file_dir + '/TF.txt')
module-attribute
List of transcription factors (TF) loaded from the file 'TF.txt'. Each line in the file represents a transcription factor.
mTF = fileToList(file_dir + '/mTF.txt')
module-attribute
List of modified transcription factors (mTF) loaded from the file 'mTF.txt'. Each line in the file represents a modified transcription factor.
compute_cluster
compute_cluster uses the igraph library to perform clustering on the GRN.
Parameters: |
|
---|
Raises: |
|
---|
Returns: |
|
---|
Source code in grnndata/utils.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 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 |
|
compute_connectivities
This function computes the connectivities of a given Gene Regulatory Network (GRN).
It uses the NetworkX library to convert the GRN into a graph and then computes the spanner of the graph. The spanner of a graph is a subgraph that approximates the original graph in terms of distances between nodes. The stretch parameter determines the maximum distance between nodes in the spanner compared to the original graph. The computed connectivities are then stored in the GRN object.
Parameters: |
|
---|
Returns: grn : The Gene Regulatory Network with the computed connectivities.
Source code in grnndata/utils.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
enrichment
This function performs enrichment analysis on a given gene regulatory network (grn).
Parameters: |
|
---|
Returns: |
|
---|
Source code in grnndata/utils.py
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 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
|
fileToList
loads an input file with a\n b\n.. into a list [a,b,..]
Source code in grnndata/utils.py
24 25 26 27 28 29 |
|
get_centrality
get_centrality uses the networkx library to calculate the centrality of each node in the GRN.
The centrality is added to the grn object as a new column in the var dataframe. also prints the top K most central nodes in the GRN.
Parameters: |
|
---|
Returns: |
|
---|
Source code in grnndata/utils.py
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 |
|
metrics
metrics This function computes the following metrics for a given Gene Regulatory Network (GRN):
small worldness
A small-world network is a type of mathematical graph in which most nodes are not neighbors of one another, but most nodes can be reached from every other by a small number of hops or steps. the sigma metric is a measure of small-worldness. if sigma > 1, the network is a small-world network.
scale freeness
A scale-free network is a network whose degree distribution follows a power law, at least asymptotically. The s metric is a measure of scale-freeness, defined as ( S(G)={frac {s(G)}{s_{max }}} ), where ( s_{max } ) is the maximum value of s(H) for H in the set of all graphs with degree distribution. A graph with small S(G) is "scale-rich," and a graph with S(G) close to 1 is "scale-free"
Therefore, a graph is more scale-free when its S(G) value is closer to 1. The range of the s metric is between 0 and 1, where 0 indicates "scale-rich" and 1 indicates "scale-free"
Parameters: |
|
---|
Returns: |
|
---|
Source code in grnndata/utils.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 |
|
plot_cluster
This function plots the clusters of a given Gene Regulatory Network (GRN).
It first computes the connectivities of the GRN and then performs Louvain clustering on the transpose of the GRN. The clusters are then visualized using UMAP.
Parameters: |
|
---|
Source code in grnndata/utils.py
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
|