API Reference
Main Classes
ScipyKernel
On-the-fly heat diffusion kernel using scipy matrix exponentiation.
Source code in tiedie/kernel_scipy.py
7 8 9 10 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 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 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | |
Functions
__init__(network_file)
Input:
network_file - a tab-delimited file in .sif network format:
<source> <interaction> <target>
Returns:
| Type | Description |
|---|---|
|
Kernel object. |
Source code in tiedie/kernel_scipy.py
diffuse(vector, reverse=False)
Diffuse input heats over the set of kernels, add to this object
Input
{'gene1': float(heat1) 'gene2' : float(heat2) ... }
Returns:
| Type | Description |
|---|---|
|
Diffused heat vector |
Source code in tiedie/kernel_scipy.py
get_labels()
Return the set of all node/gene labels used by this kernel object
kernel_multiply_one(vector)
Multiply the specified kernel by the supplied input heat vector.
Input
vector: A hash mapping gene labels to floating point values kernel: a single index for a specific kernel
Returns:
| Type | Description |
|---|---|
|
A hash of diffused heats, indexed by the same names as the |
|
|
input vector |
Source code in tiedie/kernel_scipy.py
parse_net(network)
Parse .sif network, using just the first and third columns to build an undirected graph. Store the node out-degrees in an index while we're at it.
Source code in tiedie/kernel_scipy.py
Kernel
Pre-computed heat diffusion kernel for network analysis.
Source code in tiedie/kernel.py
4 5 6 7 8 9 10 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 115 116 117 118 | |
Functions
__init__(kernel_files)
Input:
kernel_file - a tab-delimited matrix file with both a header
and first-row labels, in the same order.
Returns:
| Type | Description |
|---|---|
|
Kernel object. |
Source code in tiedie/kernel.py
add_vectors(vector_list)
Sum vectors: Add hash / float-valued vectors
diffuse(vector, reverse=False)
Diffuse input heats over the set of kernels, add to this object
Input
{'gene1': float(heat1) 'gene2' : float(heat2) ... }
Returns:
| Type | Description |
|---|---|
|
Diffused heat vector |
Source code in tiedie/kernel.py
get_labels()
Return the set of all node/gene labels used by this kernel object
kernel_multiply_one(kernel, vector)
Multiply the specified kernel by the supplied input heat vector.
Input
vector: A hash mapping gene labels to floating point values kernel: a single index for a specific kernel
Returns:
| Type | Description |
|---|---|
|
A hash of diffused heats, indexed by the same names as the |
|
|
input vector |
Source code in tiedie/kernel.py
PprDiffuser
Personalized PageRank diffusion for network analysis.
Source code in tiedie/ppr.py
Functions
__init__(network)
PprDiffuser: object to perform the Personalized PageRank Algorithm This method creates the diffuser object from an networkx DiGraph() object, which can then be used to diffuse vectors over this
Input
- network : a network hash object
Source code in tiedie/ppr.py
diffuse(p_vector, reverse=False)
Diffuse: perform generalized diffusion from the supplied input vector
Input
- p_vector: A hash-map of input values for a selection (or all) nodes (if supplied nodes aren't in the graph, they will be ignored)
Output
- A vector of diffused heats in hash-map (key,value) format
Source code in tiedie/ppr.py
personal_page_rank(p_vector, reverse=False)
Personal_Page_Rank: Get the personal pagerank of the supplied input vector
Input
- p_vector: A hash-map of input values for a selection (or all) nodes (if supplied nodes aren't in the graph, they will be ignored)
Output
- A vector of diffused heats in hash-map (key,value) format
Source code in tiedie/ppr.py
NetBalancedPermuter
Encapsulates the permutation logic for an input heat set. Permutes Node scores with other nodes of similar network degree by sorting all nodes by degree, and binning them into blocks of a set size. Permutations are done only within blocks, so that the degree distribution of input nodes is preserved.
Source code in tiedie/permute.py
5 6 7 8 9 10 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 | |
Functions
__init__(network, up_set)
Input: network: net[source] = [(i, t)] up_set: up_set[node] = score
Source code in tiedie/permute.py
permute(iterations)
Generate an array of random permutations of node scores.
Input
iteration: the number of permutations to generate
Returns:
| Type | Description |
|---|---|
|
an array of hashes: each hash indexes the nodes to permuted scores |
Source code in tiedie/permute.py
permute_block(block)
Take a block of nodes and randomly shuffle using python's random.shuffle method.
Input:
An array of node labels
Returns:
| Type | Description |
|---|---|
|
A hash mapping the original nodes to the nodes to swap with each. |
Source code in tiedie/permute.py
permute_one()
Generate one permutation of scores for all nodes, and return a hash of { node : score } for each.
Source code in tiedie/permute.py
Utility Functions
Parse input heats file in form
Returns:
| Type | Description |
|---|---|
|
Source code in tiedie/util.py
Build a directed network from a .sif file.
Inputs
A network in .sif format, tab-separated (
Returns:
| Name | Type | Description |
|---|---|---|
|
A network in hash key format, i.e. convert two lines of a file:
|
||
To |
{'source': set( (interaction, target1), (interaction, target2) ) |
Source code in tiedie/util.py
Normalize absolute value sum of data hash to 1000
Source code in tiedie/util.py
Use the min(diffused1, diffused2) function to return a list of genes that fall above that cutoff. Input: diffused heats for each set, and the numeric cutoff value
Returns:
| Type | Description |
|---|---|
|
a list of genes above the cutoff, a hash of minimum heat values |
Source code in tiedie/util.py
Find a heat threshold that yields a linker set of the given size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_set
|
Set of source node names. |
required | |
target_set
|
Set of target node names. |
required | |
up_heat_diffused
|
Dict mapping nodes to upstream diffused heat values. |
required | |
down_heat_diffused
|
Dict mapping nodes to downstream diffused heat values. |
required | |
size
|
Relative size of the linker set (compared to input set size). |
required |
Returns:
| Type | Description |
|---|---|
|
Tuple of (cutoff_threshold, relevance_score). |
Example
Source code in tiedie/util.py
Extract edges where both endpoints are in the given node subset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
network
|
Dict mapping source nodes to sets of (interaction, target) tuples. |
required | |
subnet_nodes
|
Set of nodes to use for edge selection. |
required |
Returns:
| Type | Description |
|---|---|
|
Set of (source, target) edge tuples where both nodes are in subnet_nodes. |
Example
Source code in tiedie/util.py
Map undirected edges to the network to form a subnetwork in the hash-key directed network format
Input
edge_list: edges in (s,t) format network: network in {source:set( (int, target), ... )
Returns:
| Type | Description |
|---|---|
|
Subnetwork in the data structure format of network input |