plotLDnetwork: Plots linkage disequilibrium networks

View source: R/plotLDnetwork.r

plotLDnetworkR Documentation

Plots linkage disequilibrium networks

Description

Allows for visual inspection of clusters identified by extractBranches.

Usage

plotLDnetwork(
  ldna,
  LDmat,
  option,
  threshold,
  clusters,
  summary,
  digits = 2,
  exl = NULL,
  full.network = TRUE,
  include.parent = FALSE,
  after.merger = FALSE,
  graph.object = FALSE,
  col = "grey",
  frame.color = "grey",
  pos = NULL
)

Arguments

ldna

Output from LDnaRaw

LDmat

a matrix of pairwise LD values

option

option=1 prints a full LD network from and edge list (LDmat) and a specified LD threshold (threshold). option=2 prints LD networks based on the files clusters and summary that contains information of extracted clusters.

threshold

Specifies the LD threshold at which an LD network is plotted. Only required for option=1.

clusters

Output from extractBranches.

summary

Output from summaryLDna.

digits

Needs to be the same as used LDnaRaw and extractBranches, if not default (2)

exl

A list of locus names to be excluded from the LD networks (default is NULL).

full.network

If TRUE (default), includes all loci in the LD networks, not recommended for large data sets.

include.parent

If full.network=FALSE and include.parent=TRUE all loci from the parent cluster (after merger) are included. If include.parent=FALSE only the focal cluster is shown.

after.merger

Whether to show LD networks at an LD threshold just before (FALSE) or just after (TRUE) merger.

graph.object

Whether to output graph object when option=1 (default=FALSE).

col

Color of vertices when using option=1, default is "grey"

frame.color

Frame color for vertices.

pos

A numeric vector giving the position of loci along each chromosome. This is converted into red-green color space such that within each cluster it is possible to infer if vertex position reflexts its physical position in the chromosome. Currently works only for option=1.

Details

See examples for more details

Value

If option=1 and graph.object=TRUE the output is an igraph.object that can further be manipulated for custom networks (see igraph for details).

Author(s)

Petri Kemppainen petrikemppainen2@gmail.com

See Also

LDnaRaw, extractBranches and summaryLDna

Examples

#### Example with option=1
data(LDna)
plotLDnetwork(LDmat=r2.baimaii_subs, option=1, threshold=0.4)
plotLDnetwork(LDmat=r2.baimaii_subs, option=1, threshold=0.4, col="red") # for more color
### Examples with option 2
par(mfcol=c(1,2))
ldna <- LDnaRaw(r2.baimaii_subs)
clusters <- extractBranches(ldna, min.edges=20)
summary <- summaryLDna(ldna, clusters,LDmat=r2.baimaii_subs)
#default settings with option=2
par(mfcol=c(2,2))
plotLDnetwork(ldna, r2.baimaii_subs, option=2, clusters=clusters, summary=summary)
## Other useful settings
# For large data sets
plotLDnetwork(ldna, r2.baimaii_subs, option=2, clusters=clusters, summary=summary, full.network=FALSE, include.parent=FALSE, after.merger=FALSE)
# To visualise the merger
plotLDnetwork(ldna, r2.baimaii_subs, option=2, clusters=clusters, summary=summary, full.network=TRUE, after.merger=TRUE)
# Or
plotLDnetwork(ldna, r2.baimaii_subs, option=2, clusters=clusters, summary=summary, full.network=FALSE, include.parent=TRUE, after.merger=TRUE)
# To show that ususally several clusters are involved in most mergers
plotLDnetwork(ldna, r2.baimaii_subs, option=2, clusters=clusters, summary=summary, full.network=FALSE, include.parent=TRUE, after.merger=FALSE)
### Print directly to file, recommended for large data sets with many clusters.
library(parallel)
fun <- function(x){
setEPS()
postscript(paste(x, "network.eps",  sep="_"))
plotLDnetwork(ldna, r2.baimaii_subs, option=2, clusters=clusters[x], summary=summary[x,], full.network=FALSE)
dev.off()
}
lapply(1:length(clusters), fun)
# a multicore version of this
mclapply(1:length(clusters), fun, mc.cores=4, mc.preschedule=TRUE)

petrikemppainen/LDna documentation built on April 14, 2024, 6:37 p.m.