Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

plotNet

Network plot


Description

Network plot of testing and training individuals from an object of the class 'SSI'

Usage

plotNet(fm, B, Z = NULL, K, indexK = NULL, subsetG = NULL,
           tst = NULL, U = NULL, d = NULL, group = NULL, group.shape = NULL,
           set.color = NULL, set.size = NULL, df = NULL, title, axis.labels = TRUE,
           curve = FALSE, bg.color = "gray20", unified = TRUE, ntst = 36,
           line.color = "gray90", line.tick = 0.3, legend.pos="right",
           point.color = "gray20", sets = c("Testing","Supporting","Non-active"))

Arguments

fm

An object of the 'SSI' class

B

(numeric matrix) (Optional) Regression coefficients for individuals corresponding to fm$tst (in rows) and to fm$trn (in columns)

Z

(numeric matrix) Design matrix for random effects. When Z=NULL an identity matrix is considered (default) thus G = K; otherwise G = Z K Z' is used

K

(numeric matrix) Kinship relationships. This can be a (character) name of a binary file where the matrix is stored

indexK

(integer vector) Which columns and rows will be read when K is the name of a binary file. Default indexK=NULL will read the whole matrix

subsetG

(integer vector) Which columns (and rows) from G the vectors fm$trn and fm$tst refer to. Default subsetG=NULL considers that elements fm$trn and fm$tst refer to columns (and rows) from G; otherwise elements in training and testing in G have indices subsetG[fm$trn] and subsetG[fm$tst]

tst

(integer vector) Which individuals are in testing set and to plot. It must be contained in fm$tst. Default tst=NULL will consider the whole vector fm$tst to plot

U

(numeric matrix) Eigenvectors from spectral value decomposition of G = U D U'

d

(numeric vector) Eigenvalues from spectral value decomposition of G = U D U'

group

(data.frame) Column grouping for the individuals. The rows must match with the rows in G matrix

df

(numeric) Average number of training individuals contributing to the prediction (active) of testing individuals. Default df=NULL will use the df that yielded the optimal accuracy

title

(character/expression) Title of the plot

bg.color

(character) Plot background color

line.color

(character) Color of lines connecting 'active' training individuals with each individual in testing set

line.tick

(numeric) Tick of lines connecting 'active' training individuals with each individual in testing set

set.color

(character vector) Color point of each level of 'testing', 'active', and 'non-active' elements, respectively

set.size

(numeric vector) Size of 'testing', 'active', and 'non-active' elements, respectively

group.shape

(integer vector) Shape of each level of the grouping column provided as group

curve

TRUE or FALSE to whether draw curve of rect lines connecting 'active' training individuals with each individual in testing set

axis.labels

TRUE or FALSE to whether show labels in both axes

unified

TRUE or FALSE to whether show an unified plot or separated for each individual in 'testing'

point.color

(character) Color of the points in the plot

ntst

(integer) Maximum number of individuals in 'testing' that are plotted separated as indicated by unified=FALSE

legend.pos

(character) Either "right", topright","bottomleft","bottomright","topleft", or "none" indicating where the legend is positioned in the plot

sets

(character vector) Names of the sets: testing group, predictors with non-zero coefficient, and predictors with zero coefficient in the SSI, respectively

Value

Returns the top-2 PC's plot connecting testing (predicted) individuals with training (predictors) individuals

Author(s)

Marco Lopez-Cruz (maraloc@gmail.com) and Gustavo de los Campos

Examples

require(SFSI)
  data(wheatHTP)
  
  X = scale(X[1:200,])/sqrt(ncol(X))    # Subset and scale markers
  G = tcrossprod(X)                     # Genomic relationship matrix
  y = as.vector(scale(Y[1:200,"YLD"]))  # Subset ans scale response variable
  
  fm = SSI(y,K=G,tst=1:20,trn=21:length(y))
  
  # Basic setting
  plotNet(fm,K=G,bg.color="white",line.color="gray25")
  plotNet(fm,K=G,unified=FALSE)
  
  
  # Passing a matrix of coefficients
  B = as.matrix(coef(fm,df=15))
  plotNet(fm,B=B,K=G,curve=TRUE,set.size=c(3.5,1.5,1))
  
  # Using Spectral Value Decomposition and grouping
  EVD = eigen(G)
  gp = data.frame(group=kmeans(EVD$vectors[,1:3],centers=5)$cluster)
  plotNet(fm,curve=TRUE,group=gp,U=EVD$vectors,d=EVD$values)

SFSI

Sparse Family and Selection Index

v0.3.0
GPL-3
Authors
Marco Lopez-Cruz [aut, cre], Gustavo de los Campos [aut], Paulino Perez-Rodriguez [ctb]
Initial release
2021-04-29

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.