prune.graph: Prunes spurious edges in a phenotypic hierarchy

Description Usage Arguments Details Value Author(s) Examples

View source: R/prune.graph.R

Description

A heuristic to prune spurious edges in a pehnotypic hierarchy

Usage

1
prune.graph(g,cutIN=NULL,cutOUT=NULL,quant=.95,verbose=TRUE)

Arguments

g

an adjacency matrix or a 'graphNEL' object

cutIN

minimum number of missing in-edges required to cut all in-edges. Default

cutOUT

minimum number of missing out-edges required to cut all out-edges

quant

if 'cutIN' or 'cutOUT' are not assigned, a quantile 'quant' of the distribution of missing in- or out-edges for all nodes is used

verbose

Default: TRUE

Details

prune.graph provides a heuristic approach to prune surious edges. prune.graph compares the input graph to its transitive closure, and counts for each node how many incoming and outgoing edges are missing. If the number is bigger than a user-defined cutoff, all incoming (outgoing) edges are removed.

Value

graph

the pruned phenotypic hierarchy (a 'graphNEL' object)

removed

number of removed edges

missing.in

number of missing in-edges for each node

missing.out

number of missing out-edges for each node

Author(s)

Florian Markowetz

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
    # a transitively closed core with two spurious edges
    g <- matrix(0,5,5)
    g[1,2] <- 1
    g[2,c(3,4)] <- 1
    g[3,4] <- 1
    g[4,5] <- 1
    dimnames(g) <- list(LETTERS[1:5],LETTERS[1:5])
    g <- as(g,"graphNEL")
    
    # prune graph
    gP <- prune.graph(g)
    
    # plot
    if(require(Rgraphviz)){
      par(mfrow=c(1,2))    
      plot(g,main="two spurious edges")
      plot(gP$graph,main="pruned")
    }

Example output

cutIN: 3  -  cutOUT: 3 
Removed 1 edge
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, basename, cbind, colMeans, colSums, colnames,
    dirname, 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

nem documentation built on Oct. 31, 2019, 2:12 a.m.