27 Feb 2006 mcxsubs 1.006, 06-058
1. | ||
2. | ||
3. | ||
4. | ||
5. | ||
6. | ||
7. |
mcxsubs - extract submatrices (subgraphs) of a matrix (graph).
mcxsubs can be used to inspect local cluster structure in a graph, for example by looking at the subgraph induced by a single cluster or a couple of clusterings, or the edge set where all tail nodes are from a set of domains and all head nodes are from the complement of this set, and many other variants and refinements.
Additionally, mcxsubs enables
* | selecting matrix entries based on value. | |
* | making the result characteristic (set all nonzero values to 1.0). | |
* | pruning empty columns and empty rows. | |
* | transposing the result. | |
* | remapping the indices of the result to consecutive indices. | |
* | and other miscellaneous operations. |
mcxsubs -imx <fname> [options] <specs>+
mcxsubs -imx <fname> (input matrix) [-dom <fname> (domain matrix)] [--block (use block matrix)] [--blockc (use complement of block matrix)] [--skin-read (read domain structure without entries)] [--extend (read extended submatrices)] [-tab (read tab file)] [--from-disk (space/speed optimizer)] [-out <fname> (special purpose output file name)] [-efac <num> (random edge selection)] [-dfac <num> (random domain selection)] [-rfac <num> (random column selection)] [-cfac <num> (random row selection)] [--rand-discard (remove random selections)] [--rand-merge (merge random selections)] [--rand-intersect (intersect random selections)] [--rand-exclusive (only random selections)] [-tag-digits k (set precision)] [--tag (tag nodes)] <specs>+
If you are a frequent mcxsubs user with very large graphs, consider converting the input matrix into binary format using mcxconvert and then using the mcxsubs --from-disk option. This should give you a 400-fold speed gain.
mcxsubs lets you extract submatrices/subgraphs corresponding with index sets and (possibly) sets of domains from a given domain matrix (e.g. a matrix representing a clustering). Columns and rows of the target submatrix can be specified both independently and simultaneously, and can be specified as unions of simple index and domain ranges and complements of these.
Because a submatrix or subgraph specification is composed of type, location, column, row, index, and set specifications, the word specification is abbreviated as spec. Multiple submatrices can be specified simultaneously. A submatrix is created for each submatrix spec. Everything encountered after the mcxsubs options are exhausted should be a spec. The syntax of specs is described in the SUBMATRIX SPECIFICATIONS section. By default, the domains of the submatrix will be set to the domains as described in the specification. This can be changed using the uni directives from the fin part.
A submatrix or subgraph spec may contain a number of spec parts. Each part is specified in a function-style notation. Different parts are separated by commas. Parts may occur multiple times, but for most parts only the last one specified will be effective. The spec parts are the following: dom, ext, val, size, fin, and out. These are described below in the sections DOMAINS, EXTENSION, VALUES, SIZE, FINALIZE and OUTPUT.
DOMAINS
The domain part is specified as
dom(X <, Y(ispec) >+)
Here X is the row/column indicator. Rows are indicated with either r or R, columns are indicated with either c or C. X may contain one or two indicators, with a single indicator per column domain and row domain allowed. Uppercase indicators indicate that the complement is being specified relative to the corresponding domain in the target matrix.
Y is the type indicator, it is exactly one of i, I, d, D, t, or T. The i/I indicators specify that ispec contains a simple index specifation. The d/D specify that ispec contains domain indices. ispec must contain a comma-separated list of integers or integer ranges (e.g. 2, 5, 4-8). t and T are restricted indicators that refer to the domain encoded in the tab file as specified by the -tab option. Their usage is described further below.
For domain specifications (d/D) the columns indexed by these integers in the matrix specified in the -dom option will be fetched and merged. If -dom was not used the target matrix itself (as specified by the -imx option) will be used. The special value -1 denotes the domain matrix column domain, the value -2 denotes the domain matrix row domain. For simple specifications (i/I) the result is simply the list of integers itself. Uppercase indicators indicate that the complement is being specified.
Examples:
dom(cr, i(0-6,10,11-14)) | ||
Principal submatrix on indices 0-6, 10, and 11-14 - all column and row indices are from this set. Equivalently, this encodes the subgraph on nodes 0-6, 10, 11-14. The 'c' stands for column, the 'r' for row, and the 'i' for index. It is also possible to specify a 'd' part (standing for domain), this is shown further below. | ||
dom(c, i(0-6,10,11-14)), dom(r, i(1-6,10,11-14)) | ||
Equivalent (but less clear) spec of the above. | ||
dom(cR, i(0-6,10,11-14)) | ||
Matrix with column indices in 0-6, 10, 11-14, and row indices in the complement of this set. Corresponds with all edges going out from the set 0-6, 10, 11-14. Complements are triggered by the use of a capital; see the next examples. | ||
dom(c, i(0-6,10,11-14)), dom(R, i(1-6,10,11-14)) | ||
dom(c, i(0-6,10,11-14)), dom(r, I(1-6,10,11-14)) | ||
Both these examples are equivalent to the previous one. In the last example, the capital 'I' indicates that the complement should be taken. In this example, 'r' combined with 'I' has the same effect as 'R' combined with 'i'. | ||
dom(c, d(3,5-9)), dom(r, d(8-14), i(10-30)) | ||
Column indices are taken from the domains 3, 5-9 (from the domain matrix specified by -dom), row indices are taken from domains 8-14 plus the indices 10-30. | ||
dom(cR, d(0-2)) | ||
Column indices are all indices from domains 0-2, row indices are all other indices. This gives all edges going out from domains 0-2. The use of 'D' is analogous to that of 'C', 'R', and 'I'. Thus, D(0-3,8,21-30) specifies all indices which are in the complement of the set formed by taking the union of domains 0-3,8,21-30. There are two special domains - use -1 to obtain the row domain of the domain matrix, use -2 to obtain its column domain. |
The t and T indicators must be followed by a matching pair of matching parentheses. They specify to take the domain found in the tab file or its complement.
As seen above, indices (either representing themselves or domains) are entered as comma-separated lists of single indices, ranges of indices (which may overlap), or staircases of indices (lists of indices with a fixed increment inbetween successive indices). The union of the corresponding elements is taken and passed along. Before anything else, the result set is replaced by its complement if 'I' is specified (for simple indices) or 'D' is specified (for domains). If there is both an index and a set spec string, the union of the results of both is taken and passed along. If the latter result is passed to either 'C' or 'R', it is replaced by its complement.
A range is specified e.g. as 10-14 and it is inclusive, denoting in this case the indices {10,11,12,13,14}.
EXTENSION
The extension part is specified as
ext( < disc(k) | cdisc(k) | rdisc(k) >)
This option requires the input matrix to be held in memory. This implies it will not work with the --from-disk option.
This assumes that the input matrix encodes a graph, so the column and row domains must be equal. It will take the currently selected domain (column domain for disc and cdisc, row domain for rdisc), and add all nodes to it that are reachable in k steps. The disc variant replaces both column and row domains by the extended domain, the other variants just change a single domain.
Setting k to -1 results in adding all nodes that can be reached from the start domain.
VALUES
The value part is specified as
val(<tf-spec>)
It transforms or removes values according to <tf-spec>. Refer to mcxio for a description of the transformation specification syntax and the available transformation primitives.
SIZE
The size part is specified as
size( < lt(x) | lq(x) | gq(x) | gt(x) > + )
Where x is a nonnegative integer, and multiple specifications are separated by commas. The strings 'lt', 'lq', 'gq', 'gt', respectively denote less than, less than or equal to, greater than or equal to, and greater than.
This prunes or removes column vectors based on their size. If lt or lq is used, column vectors are removed if they have not as much entries as the corresponding lower bound. If gt or gq is used and a column vector has an excess of entries over the corresponding upper bound, the smallest entries are removed. Ties are not arbitrarily broken, implying that the resulting vector may still have more entries than the specified bound.
FINALIZE
The finalize part is specified as
fin( < key > )
where key is a string and multiple keys are separated by commas. The
corresponding actions are generally applied to the matrix that was extracted
according to the domain and value specifications. Exceptions are indicated
below. Currently, there is a fixed order in which actions are considered,
corresponding with the order in which they are listed below.
empty | ||
This creates an empty submatrix on the specified domains, and does
not fill it with the corresponding entries from the
source matrix.
Options from the fin part that affect the column and
row domains of a matrix will still be in effect.
| ||
uni | ||
unir | ||
unic | ||
After the submatrix is selected from the source matrix, its domains
are changed to mirror one or both of the domains of the source matrix.
| ||
tp | ||
The resulting submatrix is replaced by its transpose.
| ||
cc | ||
The resulting submatrix is made characteristic.
| ||
weedc | ||
weedr | ||
weed | ||
Domains are shrunk if there are no corresponding entries in the matrix.
This is done for both domains if weed is specified, for the
column domain if weedc is specified, and for the row domain
if weedr is specified. Thus, with weedc columns are removed
from the domain and the matrix if they are empty.
| ||
mapc | ||
mapr | ||
map | ||
The appropriate domains are mapped onto consecutive indices starting at zero.
|
OUTPUT
The output part is specified as
out( fname <, key >* )
that is, the fname option is obligatory if the out part is specified.
Currently, key can be a single directive, namely wb specifying that
the resulting matrix should be output in binary format.