get_alluvialplot: Plot alluvial plot of dynamic community membership

Description Usage Arguments Details Examples

View source: R/MTRfuncs.R

Description

Plots dynamic communities and the movements between them as an alluvial plot https://en.wikipedia.org/wiki/Alluvial_diagram

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
get_alluvialplot(
  track,
  allcols = NULL,
  fluxbysource = T,
  fluxsinglecol = T,
  fluxmovecol = "grey",
  fluxsinglecolremain = T,
  fluxremaincol = "grey",
  fluxalpha = 0.4,
  figwidth = 8,
  figheight = 2,
  rlabels = NULL,
  rstart = NULL,
  rstop = NULL,
  rmargins = c(0, 0.2, 1, 1),
  cwidth = 0.2,
  clusterlw = 0.5,
  labelsize = -1,
  reimport = T,
  removefile = T,
  exportfilename = "Rplot.png"
)

Arguments

track

A MajorTrack object as produced by do_track.

allcols

A vector of colours, the same length at the number of unique dynamic communities in the MajorTrack object. Defaults to rainbow colours.

fluxbysource

Boolean. If TRUE, the connecting fluxes between timesteps will be coloured the same as the dynamic community from which they originate. Defaults to TRUE.

fluxsinglecol

Boolean. If TRUE, the connecting fluxes between timesteps will be a single colour as defined by fluxmovecol. Overrides fluxbysource.

fluxmovecol

Single colour of movements between different dynamic communities in different timesteps. Defaults to "grey".

fluxsinglecolremain

Boolean. If TRUE fluxes between the same dynamic community in different timesteps will be a single colour as defined by fluxremaincol. Defaults to TRUE.

fluxremaincol

Single colour for remaining in the same dynamic community in different timesteps. Defaults to "grey".

fluxalpha

Transparency of fluxes, where 1 is opaque and 0 is invisible. Defaults to 0.4

figwidth

Width of figure in inches. Defaults to 8.

figheight

height of figure in inches. Defaults to 2.

rlabels

Vector of labels that, if supplied, will override the timestep labels.

rstart

Integer specifying timestep at which to start plotting.

rstop

Integer specifying timestep at which to stop plotting.

rmargins

Vector of numbers between 0 and 1 in the format c(left,bottom,right,top). Specifies a rectangle in which the alluvial plot (blocks and fluxes) is placed in the overall plotting area. By default the alluvial plot takes up the entirety of the plotting area, except for the bottom where a gap is left for the labels: c(0,0.2,1,1).

cwidth

Number between 0 and 1 defining cluster width. 0 will hide clusters, 1 will leave no room between clusters. Defaults to 0.2

clusterlw

Number between 0 and 1 defining line width of cluster borders. Defaults to 0.5. Currently has no effect.

labelsize

Number defining size of per cluster labels. Defaults to 0, hiding labels.

reimport

Boolean. If TRUE, the python figure will be imported into R. Defaults to TRUE.

removefile

Boolean. If TRUE, the exported python figure will be deleted when the function is finished. Defaults to TRUE.

exportfilename

String giving the name and path of the exported file. Defaults to "Rplot.png"

Details

The R function for the MT alluvial plots is a wrapper for the python plotting functions.

If reimport is TRUE it will run the plotting code, export an image then bring it back into R. By default the image file will then be removed.

The code attempts to place the R margins and axis in the same positions as those in the python plot. There is a chance this might fail on some graphics devices. If succesful the resulting plotting device will have an x-axis where each tick is a timestep.

Combining fluxbysource, fluxsinglecol and fluxsinglecolremain will produce different effects. fluxsinglecol being TRUE will colour all fluxes the same. If fluxsinglecolremain is also TRUE, this will result in remain fluxes being one colour and all other fluxes (moves, splits, merges) being another colour. If fluxsinglecol is FALSE and fluxbysource is TRUE then fluxes will be coloured by the community they originate from. and all other fluxes (moves, splits, merges) being another colour. If fluxsinglecol is FALSE and fluxbysource is also FALSE then fluxes will be coloured by the community they are heading toward. Both these combinations can further be combined with fluxsinglecolremain being TRUE to separate remain fluxes and all other fluxes.

Examples

1
2
3
4
5
6
7
8
data(allnets)
data(allnets)
#detect each networks communities
coms=lapply(allnets,function(x){
  igraph::cluster_louvain(x)
})
track = do_track(allnets, coms, history=1)
get_similarities(track)

jevansbio/MajorTrackR documentation built on Dec. 20, 2021, 11:06 p.m.