hasse: Draw Hasse diagram

Description Usage Arguments Examples

View source: R/hasse.R

Description

This function draws Hasse diagram – visualization of transitive reduction of a finite partially ordered set.

Usage

1
hasse(data, labels = c(), parameters = list())

Arguments

data

n x n matrix, which represents partial order of n elements in set. Each cell [i, j] has value TRUE iff i-th element precedes j-th element.

labels

Vector containing labels of elements. If missing or NULL then data row names will be used as labels. If rownames(data) are not present, the labels will be generated as ('a' + element index).

parameters

List with named elements:

  • arrow – direction of arrows: "forward", "backward", "both" or "none" (default "forward"),

  • cluster – whether to cluster elements which have the same parents and children and are connected all to all (see first commented example) (default TRUE),

  • clusterMerge – merge clustered nodes within single node frame (default FALSE),

  • clusterNonAdjacent – to allow clustering elements that are not mutually adjacent (default FALSE),

  • edgeColor – edge color, from colors() (default "black"),

  • newpage – whether to call grid.newpage() before drawing (default TRUE),

  • nodeColor – node frame color, from colors() (default "black"),

  • margin – node margins, a list with 4 numerical items: "tb" for top-bottom margin, "rl" for right-left margin, "otb" and "orl" for outer margin when multiple labels are present,

  • shape – shape of diagram nodes: "roundrect", "rect" or "none" (default "roundrect"),

  • transitiveReduction – whether to perform transitive reduction (default TRUE).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
randomData <- generateRandomData(15, 2, 0.5)
hasse(randomData)

# Clustering example
data <- matrix(data = FALSE, ncol = 4, nrow = 4)
data[1, 2] = data[1, 3] = data[2, 4] = data[3, 4] = TRUE
data[2, 3] = data[3, 2] = TRUE
hasse(data, c(), list(cluster = TRUE))
hasse(data, c(), list(cluster = FALSE))

# Hasse to pdf example
# randomData <- generateRandomData(15, 2, 0.5)
# pdf("path-for-diagram.pdf")
# hasse(randomData, NULL, list(newpage = FALSE))
# dev.off()

Example output

Loading required package: Rgraphviz
Loading required package: graph
Loading required package: BiocGenerics
Loading required package: parallel

Attaching package: 'BiocGenerics'

The following objects are masked from 'package:parallel':

    clusterApply, clusterApplyLB, clusterCall, clusterEvalQ,
    clusterExport, clusterMap, parApply, parCapply, parLapply,
    parLapplyLB, parRapply, parSapply, parSapplyLB

The following objects are masked from 'package:stats':

    IQR, mad, sd, var, xtabs

The following objects are masked from 'package:base':

    Filter, Find, Map, Position, Reduce, anyDuplicated, append,
    as.data.frame, cbind, colMeans, colSums, colnames, do.call,
    duplicated, eval, evalq, get, grep, grepl, intersect, is.unsorted,
    lapply, lengths, mapply, match, mget, order, paste, pmax, pmax.int,
    pmin, pmin.int, rank, rbind, rowMeans, rowSums, rownames, sapply,
    setdiff, sort, table, tapply, union, unique, unsplit, which,
    which.max, which.min

Loading required package: grid

hasseDiagram documentation built on June 10, 2021, 9:10 a.m.