randomWAMGraph: Generates a random graph

Description Usage Arguments Value Author(s) See Also Examples

View source: R/randomWAMGraph.R

Description

Generates a random graph.

Usage

1
randomWAMGraph(nnodes=5, nedges=nnodes, verbose=FALSE)

Arguments

nnodes

A numeric value, the desired number of nodes.

nedges

A numeric value, the desired number of edges.

verbose

If TRUE, extra information is output.

Value

An object of class graphAM.

Author(s)

Laurent Jacob, Pierre Neuvial and Sandrine Dudoit

See Also

graphAM.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
library("KEGGgraph")
library("rrcov")

## Create a random graph
graph <- randomWAMGraph(nnodes=5, nedges=7, verbose=TRUE)
plot(graph)

## Retrieve its adjacency matrix
A <- graph@adjMat

## write it to KGML file
grPathname <- "randomWAMGraph.xml"
writeAdjacencyMatrix2KGML(A, pathname=grPathname, verbose=TRUE, overwrite=TRUE)

## read it from file
gr <- parseKGML2Graph(grPathname)

## Two examples of Laplacians from the same graph
lapMI <- laplacianFromA(A, ltype="meanInfluence")
print(lapMI)

lapN <- laplacianFromA(A, ltype="normalized")
print(lapN)

U <- lapN$U
p <- nrow(A)
sigma <- diag(p)/sqrt(p)

X <- twoSampleFromGraph(100, 120, shiftM2=1, sigma, U=U, k=3)

## T2
t <- T2.test(X$X1,X$X2)
str(t)

tu <- graph.T2.test(X$X1, X$X2, lfA=lapMI, k=3)
str(tu)

Example output

Loading required package: R.utils
Loading required package: R.oo
Loading required package: R.methodsS3
R.methodsS3 v1.7.1 (2016-02-15) successfully loaded. See ?R.methodsS3 for help.
R.oo v1.21.0 (2016-10-30) successfully loaded. See ?R.oo for help.

Attaching package: 'R.oo'

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

    getClasses, getMethods

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

    attach, detach, gc, load, save

R.utils v2.5.0 (2016-11-07) successfully loaded. See ?R.utils for help.

Attaching package: 'R.utils'

The following object is masked from 'package:utils':

    timestamp

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

    cat, commandArgs, getOption, inherits, isOpen, parse, warnings


Attaching package: 'KEGGgraph'

The following objects are masked from 'package:R.oo':

    getName, getTitle

The following object is masked from 'package:graphics':

    plot

Loading required package: robustbase
Scalable Robust Estimators with High Breakdown Point (version 1.4-3)


Attaching package: 'rrcov'

The following object is masked from 'package:R.utils':

    getRaw

$U
           [,1]          [,2]       [,3]        [,4]          [,5]
[1,] -0.4472136  5.992908e-01  0.3193880  0.44496211 -3.753005e-01
[2,] -0.4472136  3.753005e-01 -0.5445805 -0.05858362  5.992908e-01
[3,] -0.4472136 -3.753005e-01 -0.5445805 -0.05858362 -5.992908e-01
[4,] -0.4472136 -2.220446e-16  0.4503850 -0.77275699 -1.443290e-15
[5,] -0.4472136 -5.992908e-01  0.3193880  0.44496211  3.753005e-01

$l
[1] 3.552714e-15 5.196613e-01 1.353491e+00 2.424287e+00 2.619228e+00

$kIdx
[1]  TRUE FALSE FALSE FALSE FALSE

$U
           [,1]          [,2]       [,3]          [,4]          [,5]
[1,] -0.3779645  5.869337e-01 -0.3273268  5.000000e-01 -3.943461e-01
[2,] -0.4629100  3.943461e-01  0.5345225 -7.216450e-16  5.869337e-01
[3,] -0.4629100 -3.943461e-01  0.5345225  4.718448e-16 -5.869337e-01
[4,] -0.5345225  5.551115e-17 -0.4629100 -7.071068e-01 -8.881784e-16
[5,] -0.3779645 -5.869337e-01 -0.3273268  5.000000e-01  3.943461e-01

$l
[1] 1.776357e-15 7.257081e-01 1.166667e+00 1.500000e+00 1.607625e+00

$kIdx
[1]  TRUE FALSE FALSE FALSE FALSE

Warning message:
In sqrt(shiftM2) * diff[1:k]/sqrt(rawShiftNorm) :
  Recycling array of length 1 in vector-array arithmetic is deprecated.
  Use c() or as.vector() instead.

List of 9
 $ statistic  : Named num [1:2] 44.66 8.77
  ..- attr(*, "names")= chr [1:2] "T2" "F"
 $ parameter  : Named num [1:2] 5 214
  ..- attr(*, "names")= chr [1:2] "df1" "df2"
 $ p.value    : num 1.39e-07
 $ conf.int   : NULL
 $ estimate   : num [1:2, 1:5] -2.28 -2.678 -0.897 -1.144 0.35 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:2] "mean x-vector" "mean y-vector"
  .. ..$ : NULL
 $ null.value : NULL
 $ alternative: chr "true difference in mean vectors is not equal to (0,0,0,0,0)"
 $ method     : chr "Two-sample Hotelling test"
 $ data.name  : chr "X$X1 and X$X2"
 - attr(*, "class")= chr "htest"
List of 9
 $ statistic  : Named num [1:2] 43.3 14.3
  ..- attr(*, "names")= chr [1:2] "T2" "F"
 $ parameter  : Named num [1:2] 3 216
  ..- attr(*, "names")= chr [1:2] "df1" "df2"
 $ p.value    : num 1.57e-08
 $ conf.int   : NULL
 $ estimate   : num [1:2, 1:3] 1.586 2.106 -1.018 -1.253 -0.577 ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:2] "mean x-vector" "mean y-vector"
  .. ..$ : NULL
 $ null.value : NULL
 $ alternative: chr "true difference in mean vectors is not equal to (0,0,0)"
 $ method     : chr "Two-sample Hotelling test"
 $ data.name  : chr "X1 %*% U[, 1:rk, drop = FALSE] and X2 %*% U[, 1:rk, drop = FALSE]"
 - attr(*, "class")= chr "htest"

DEGraph documentation built on Nov. 8, 2020, 5:52 p.m.