sfa package¶
Subpackages¶
- sfa.algorithms package
- sfa.analysis package
- sfa.control package
- sfa.data package
- Subpackages
- sfa.data.borisov_2009 package
- sfa.data.cho_2016 package
- sfa.data.flobak_2015 package
- sfa.data.fumia_2013 package
- sfa.data.korkut_2015a package
- sfa.data.molinelli_2013 package
- sfa.data.nelander_2008 package
- sfa.data.pezze_2012 package
- sfa.data.schliemann_2011 package
- sfa.data.steinway_2015 package
- sfa.data.turei_2016 package
- sfa.data.zanudo_2015a package
- sfa.data.zanudo_2017 package
- Module contents
- Subpackages
- sfa.plot package
- sfa.vis package
Submodules¶
Module contents¶
-
class
sfa.
Algorithm
(abbr)[source]¶ Bases:
sfa.base.ContainerItem
The base class of Algorithm classes.
Examples
>>> class AnAlgorithm(sfa.base.Algorithm): # Definition of algorithm ... ...
>>> alg = AnAlgorithm() >>> alg.params = params_obj # Parameters of the algorithm >>> alg.data = data_obj # Data to be analyzed by the algorithm >>> alg.initialize() >>> res = alg.compute()
- Attributes
Methods
compute
(self, b)Process the assigned data
compute_batch
(self)Process the assigned data that contains a batch data.
Initialize the basal activity, \(b\).
initialize_network
(self)Initialize the data structures related to network.
copy
initialize
-
compute
(self, b)[source]¶ - Process the assigned data
with the given basal activity, \(b\).
- Parameters
- bnumpy.ndarray
1D array of basal activity.
- Returns
- xnumpy.ndarray
1D-array object of activity at steady-state.
-
compute_batch
(self)[source]¶ Process the assigned data that contains a batch data. The result is stored in
result
member.
-
data
¶ The object of
sfa.base.Data
. Data to be processed based on the algorithm can accessed through this member.
-
params
¶ The object of
sfa.base.ParameterSet
. Parameters of the algorithm can accessed through this member.
-
result
¶ The object of
sfa.base.Result
. The result of computing the batch.
-
class
sfa.
Data
[source]¶ Bases:
sfa.base.ContainerItem
- Attributes
- A
abbr
Abbreviation or symbol representing this item.
- df_conds
- df_exp
- df_ptb
- dg
- has_link_perturb
- i2n
- iadj_to_idf
- inputs
- n2i
name
Full name or description of this item.
- names_ptb
- vals_ptb
Methods
initialize
-
A
¶
-
df_conds
¶
-
df_exp
¶
-
df_ptb
¶
-
dg
¶
-
has_link_perturb
¶
-
i2n
¶
-
iadj_to_idf
¶
-
initialize
(self, fpath, fname_network='network.sif', fname_ptb='ptb.tsv', fname_conds='conds.tsv', fname_exp='exp.tsv', inputs={})[source]¶
-
inputs
¶
-
n2i
¶
-
names_ptb
¶
-
vals_ptb
¶
-
class
sfa.
Result
[source]¶ Bases:
sfa.utils.FrozenClass
- Attributes
- df_sim
-
df_sim
¶
-
class
sfa.
AlgorithmSet
(*args, **kwargs)¶ Bases:
sfa.containers.AlgorithmSet
Methods
clear
(self)create
(self[, keys])Create a single or multiple objects according to keys.
get
(self, key[, default])items
(self)keys
(self)pop
(self, key[, default])If key is not found, d is returned if given, otherwise KeyError is raised.
popitem
(self)as a 2-tuple; but raise KeyError if D is empty.
setdefault
(self, key[, default])update
(\*args, \*\*kwds)If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
values
(self)get_all_keys
-
class
sfa.
DataSet
(*args, **kwargs)¶ Bases:
sfa.containers.DataSet
Methods
clear
(self)create
(self[, keys])Create a single or multiple objects according to keys.
get
(self, key[, default])items
(self)keys
(self)pop
(self, key[, default])If key is not found, d is returned if given, otherwise KeyError is raised.
popitem
(self)as a 2-tuple; but raise KeyError if D is empty.
setdefault
(self, key[, default])update
(\*args, \*\*kwds)If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v
values
(self)get_all_keys
-
sfa.
calc_accuracy
(df1, df2, get_cons=False)[source]¶ Count the same sign of each element between df1 and df2
df1: pandas.DataFrame or numpy.ndarray to be compared df2: pandas.DataFrame or numpy.ndarray to be compared getcons: decide whether to return consensus array in DataFrame or not
-
sfa.
rand_swap
(A, nsamp=10, noself=True, pivots=None, inplace=False)[source]¶ Randomly rewire the network connections by swapping.
- Parameters
- Anumpy.ndarray
Adjacency matrix (connection matrix).
- nsampint, optional
Number of sampled connections to rewire
- noselfbool, optional
Whether to allow self-loop link.
- pivotslist, optional
Indices of pivot nodes
- inplacebool, optional
Modify the given adjacency matrix for rewiring.
- Returns
- Bnumpy.ndarray
The randomized matrix. The reference of the given W is returned, when inplace is True.
-
sfa.
rand_flip
(A, nsamp=10, pivots=None, inplace=False)[source]¶ Randomly flip the signs of connections.
- Parameters
- Anumpy.ndarray
Adjacency matrix (connection matrix).
- nsampint, optional
Number of sampled connections to be flipped.
- pivotslist, optional
Indices of pivot nodes
- inplacebool, optional
Modify the given adjacency matrix for rewiring.
- Returns
- Bnumpy.ndarray
The randomized matrix. The reference of the given W is returned, when inplace is True.
-
sfa.
rand_weights
(W, lb=-3, ub=3, inplace=False)[source]¶ Randomly sample the weights of connections in W from 10^(lb, ub).
- Parameters
- Wnumpy.ndarray
Adjacency (connection) or weight matrix.
- lbfloat, optional
The 10’s exponent for lower bound
- inplacebool, optional
Modify the given adjacency matrix for rewiring.
- Returns
- Bnumpy.ndarray
The randomly sampled weight matrix. The reference of the given W is returned, when inplace is True.
-
sfa.
get_akey
(d)[source]¶ Get a key from a given dictionary. It returns the first key in d.keys().
- Parameters
- ddict
Dictionary of objects.
- Returns
- objobject
First item of iter(d.keys()).
-
sfa.
get_avalue
(d)[source]¶ Get a value from a given dictionary. It returns the value designated by sfa.get_akey().
- Parameters
- ddict
Dictionary of objects.
- Returns
- objobject
First item of d[iter(d.keys())].
-
sfa.
splo
(nxdg, sources, outputs, rtype='df')[source]¶ Calculate the shortest path length from each source node to the outputs. SPLO represents ‘shortest path length to output’.
- Parameters
- nxdg: NetworkX.DiGraph
A directed network in NetworkX.
- sources: list (or iterable) of str
Names of source nodes in nxdg.
- outputs: list (or iterable) of str
Names of output nodes in nxdg.
- rtype: str (optional)
Return object type: ‘df’ or ‘dict’.
- Returns
- splo: dict
All the shortest path lengths to the outputs.
-
sfa.
create_from_sif
(fpath, abbr=None, inputs=None, outputs=None)[source]¶ Create sfv.base.Data object from SIF file.
- Parameters
- fpathstr
Absolute path of SIF file
- abbrstr
Abbreviation to denote this data object for the network.
- inputsdict, optional
Input information with default values
- outputssequence, optional
Output information.
- Returns
- objsfv.base.Data
Data object with the information of network topology.