mcxsubs(1)

πŸ“¦
version 22-282 Β· 2 versions
  • 22-282 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 14-137 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

okay bestie, sit down, hydrate, because this is mcxsubs(1) β€” section 1, living under USER COMMANDS, and it is lowkey one of the most powerful little graph-slicing tools in the whole mcl/mcx family. πŸ’–


πŸŽ€ NAME πŸŽ€

mcxsubs - extract submatrices (subgraphs) of a matrix (graph).

mcxsubs is your go-to for peeking at the local cluster structure inside a graph. Like, you can stare at the subgraph induced by one single cluster, or by a couple of clusterings, or grab the edge set where all the tail nodes come from one set of domains and all the head nodes come from the complement of that set β€” and honestly so many other variants and refinements, the girlies stay busy. πŸ¦‹

And on top of all that, mcxsubs also 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.

✨ SYNOPSIS ✨

mcxsubs -imx <fname> [options] <specs>+

mcxsubs -imx <fname> (input matrix) [-dom <fname> (domain matrix)] [-tf
spec (apply tf-spec to input 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>+
bestie, real talk: if you're a frequent mcxsubs user with very large graphs, consider converting your input matrix into binary format using mcxconvert and then hitting the mcxsubs --from-disk option. That combo should give you a 400-fold speed gain. no cap. πŸ”₯

🌸 DESCRIPTION 🌸

mcxsubs lets you extract submatrices/subgraphs corresponding with index sets and (possibly) sets of domains from a given domain matrix (like, say, a matrix representing a clustering). Columns and rows of the target submatrix can be specified both independently and simultaneously, and they can be specified as unions of simple index and domain ranges β€” plus complements of those. iconic behaviour, honestly. πŸ’…

Because a submatrix or subgraph specification is composed of type, location, column, row, index, and set specifications, the word specification gets shortened to spec. (iykyk.) You can specify multiple submatrices at the same time, and a submatrix is created for each submatrix spec. Everything you run into after the mcxsubs options are exhausted should be a spec. The syntax of specs lives in the SUBMATRIX SPECIFICATIONS section. By default, the domains of the submatrix will be set to the domains as described in the specification. Want to change that? That's what the uni directives from the fin part are for. 🧚


πŸ‘‘ OPTIONS πŸ‘‘

  • -imx <fname> (input matrix) β€” Submatrices will all be selected from the matrix in file <fname>. This option is obligatory, and throughout this manual its argument is called the source matrix.
  • -dom <fname> (domain matrix) β€” Submatrices are specified in terms of sets (or domains) of indices. These sets are specified by (the label of) the vectors from the matrix given by this option.
  • --block (use block matrix) β€” This replaces the input matrix by the block diagonal matrix induced by the domain matrix specified by the -dom option. It works by including a block for each domain in the domain matrix, and it will work if there are overlapping domains. That is, it will not include overlapping parts more than once. The output file name can either be specified in the submatrix specification language using the out(fname) directive, or with the -out option.
  • --blockc (use complement of block matrix) β€” This replaces the input matrix by the complement of the block diagonal matrix described above, and selection of the output name is exactly the same. πŸ’€
  • --skin-read (read domain structure without entries) β€” This reads a skeleton matrix by only considering its domain structure and not reading any entries, pertaining to the matrix specified by the -imx option. Transform the input matrix values according to the syntax described in mcxio(5).
  • -tab (read tab file) β€” Read a tab file. Its domain can be used by the t and T indicators.
  • --extend (read extended submatrices) β€” This causes the selection of submatrices where either a row index is in the selected row domain or a column index is in the selected column domain or both. Equivalently, it only excludes matrix entries for which neither the column nor row index is in the selected domains. The resulting matrix has both domains equal to the source matrix.
  • -out <fname> (special purpose output file name) β€” This specifies an output name that can be used for special purposes. Normally, output file names are specified in the submatrix specification using the out(fname) directive.
  • -efac <num> (random edge selection) β€” num should be inbetween zero and one. It denotes the probability with which each edge is selected. 🎲
  • -dfac <num> (random domain selection) β€” num should be inbetween zero and one. It denotes the probability with which entries in the domains will make it into the randomized selection used for subsequent processing. By default the randomized selection is intersected with whatever the other selection criteria (if any) yield, i.e. the behaviour under the --rand-intersect option.

If the column and row domain are identical, they are submitted to the same selection process and will end up identical. If you don't want this, use -rfac and -cfac separately. πŸ™ˆ

If you just want a randomized selection, doing

mcxsubs -imx foo -dfac 0.5 'out(foo.rnd)'

will not yield the expected result. Randomized selections only work if a domain has explicitly been specified. The minimal way to achieve this is the following:

mcxsubs -imx foo -dfac 0.5 'dom(cr), out(foo.rnd)'
  • -rfac <num> (random column selection) β€” As -dfac, limited to the column domain.
  • -cfac <num> (random row selection) β€” As -dfac, limited to the row domain.
  • --rand-merge (merge random selections) β€” The random selection(s) of domains identify parts of the matrix that will be merged with the result of the main selection process (default).
  • --rand-discard (remove random selections) β€” The random selection(s) of domains identify parts of the matrix that will be removed from the result of the main selection process.
  • --rand-intersect (intersect random selections) β€” The random selection(s) of domains identify parts of the matrix that will be intersected with the result of the main selection process. This is the default.
  • --rand-exclusive (only random selections) β€” The random selection(s) of domains identify parts of the matrix from which the result of the main selection process will be removed.
  • -tag-digits k (set precision) β€” Sets the precision for tagged output. Setting it to -tag-digits -1 disables the output of values altogether β€” only the node indices and the cluster indices are written. πŸ“
  • --tag (tag nodes) β€” Each node in the column (tail node) listing of the matrix (graph) spec is tagged with the domain it is in. This requires the use of the -dom option. This output mode, called tagged matrix, is currently not recognized by any of the mcl/mcx input routines. It is present to facilitate easier visual inspection of clustering results. πŸ‘€
  • --from-disk (space/speed optimizer) β€” Use this if the input graph is in binary format, or if the input graph is very large and the subgraph(s) to extract are small in comparison, or if the available memory does not comfortably exceed the size of the graph.

The effect of this option is that the subgraph will be read directly from disk, without reading in the entire graph in advance. This will be done repeatedly for all subgraphs that are specified.

This option reduces memory consumption to the size of the subgraph(s) to be extracted. πŸ’Ύ

For graphs in interchange format, the speed gain is not dramatic. If more than one subgraph is specified, there will most likely be a loss in speed. 😭

With input graphs in binary format, mcxsubs will be *very* much faster, to the extent of 400-fold speed gains. It does not matter whether more than one subgraph is specified. πŸ”₯


πŸ¦‹ SUBMATRIX SPECIFICATIONS πŸ¦‹

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, c, r, t, or T. The i/I indicators specify that ispec contains a simple index specification. 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). c and r are restricted indicators that refer to the domains in the domain matrix. 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. 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.

...and the vibe check continues, bestie, because the examples are NOT done ✨

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 of these are literally the same thing as the example right before them. No cap. In the last one, that capital I is out here saying "take the complement, bestie." And notice: in this example, r paired up with I does the exact same job as R paired with i. Same energy, different outfit πŸ’…

dom(c, d(3,5-9)), dom(r, d(8-14), i(10-30))

Here the column indices get pulled from the domains 3, 5-9 (those come from the domain matrix you set up with -dom), and the row indices come from domains 8-14 plus the plain old indices 10-30.

dom(cR, d(0-2))

Column indices = every index from domains 0-2, row indices = every single other index. So what you get is all the edges going out from domains 0-2. Chef's kiss for reachability questions πŸ‘‘

Also, D behaves the same way C, R, and I do. So like, D(0-3,8,21-30) gives you all indices sitting in the complement of the set you'd get by taking the union of domains 0-3,8,21-30. Periodt.

The c and r indicators must be followed by a pair of matching parentheses. They tell it to take the column domain and the row domain of the domain matrix respectively (peep -dom).

The t and T indicators also must be followed by a pair of matching parentheses. They say: take the domain you found in the tab file, or its complement.

So as we saw above, indices (whether they're standing in for themselves or for domains) get typed in as comma-separated lists of single indices, ranges of indices (which are allowed to overlap, go off), or staircases of indices (that's a list of indices with a fixed increment between successive ones). The union of all those corresponding elements is taken and passed along. And before anything else happens, the result set gets swapped out for its complement if I is specified (for simple indices) or D is specified (for domains). If you've got both an index and a set spec string going on, the union of both results is taken and passed along. And if that result then gets handed to either C or R, it gets replaced by its complement. Layers, babe. πŸ§…

A range looks like 10-14, for example, and it's inclusive β€” meaning in this case it denotes the indices {10,11,12,13,14}. Inclusive is the moment, we love her.


EXTENSION

The extension part gets written like this:

ext( < disc(k) | cdisc(k) | rdisc(k) >)
Heads up bestie: this option needs the input matrix to be held in memory. Which means it will not work with the --from-disk option. They are not compatible, it's giving enemies to lovers but without the lovers 😭

This one assumes your input matrix encodes a graph, so the column and row domains have to be equal, fr fr. It takes the currently selected domain (column domain for disc and cdisc, row domain for rdisc) and adds every node to it that's reachable in k steps. The disc variant replaces both the column and row domains with the extended domain β€” the other variants just change a single domain, lowkey modest of them.

Set k to -1 and you'll add all nodes that can be reached from the start domain. All of them. The whole squad. πŸ’–


VALUES

The value part is specified as:

val(<tf-spec>)

It transforms or removes values according to <tf-spec>. For the description of the transformation specification syntax and the transformation primitives that are available, go read mcxio(5). Not me sending you to another manpage, but do it 🫢


SIZE

The size part is specified as:

size( < lt(x) | ceil(x) | gq(x) | rmgq(x) > + )

Where x is a nonnegative integer, and multiple specifications get separated by commas. The strings lt, lq, gq, gt respectively mean less than, less than or equal to, greater than or equal to, and greater than.

This one prunes or removes column vectors based on their size. If lt is used, column vectors get removed if the number of entries exceeds the specified bound. If gq is used, vectors get discarded if the number of entries is smaller than the specified bound. And if a column vector has an excess of entries over the bound specified by ceil, the smallest entries get removed. Ties are not arbitrarily broken β€” which implies the resulting vector may still have more entries than the specified bound. She's imperfect, she's thriving, she's still valid πŸ’…


FINALIZE

The finalize part is specified as fin( < key > ) where key is a string and multiple keys are separated by commas. These actions generally get applied to the matrix that was extracted according to the domain and value specifications. Exceptions get flagged below, so don't come for me. Currently there's a fixed order in which actions are considered, and it matches the order they're listed in down here. Order matters, bestie. Iconic of it, honestly.

skel

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 though. She's empty but she's still dressed πŸ’€

uni

unir

unic

After the submatrix is selected from the source matrix, its domains get changed to mirror one or both of the domains of the source matrix.

tp

The resulting submatrix gets replaced by its transpose. Flip it, turn it, slay it πŸ”₯

cc

The resulting submatrix is made characteristic.

scrubc

scrubr

scrubg

scrub

Domains get shrunk if there are no corresponding entries in the matrix. This happens for both domains if scrub is specified, for the column domain if scrubc is specified, and for the row domain if scrubr is specified. So with scrubc, columns get removed from the domain and from the matrix if they're empty. And with scrubg, the union of the resulting domains is taken.

mapc

mapr

map

The appropriate domains get mapped onto consecutive indices starting at zero. Fresh start, new me, index zero energy ✨


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.


πŸ‘‘ AUTHOR

Stijn van Dongen.


πŸ¦‹ SEE ALSO

mcx(1), and mclfamily(7) for an overview of all the documentation and the utilities in the mcl family.


And that's the whole page, bestie, you made it to the end and I'm so proud of you 🫢 this was mcxsubs version 22-282, dated 9 Oct 2022 β€” go forth and subset responsibly, mwah πŸ’–βœ¨

πŸ“¦ where this page comes from