plot_igraph {TraRe} | R Documentation |
Collection of functions for generating graphs layouts to plot GRN obtained from NET_run()
method.
return_layout()
generates a layout from the graph object returned by NET_run()
and return_layout_phenotype()
plots targets according to the t-statistic from the differential expression analysis of the desired phenotype.
plot_igraph()
takes in the igraph object and generated layout and generates plot.
plot_igraph(mygraph = NULL, mytitle = "", titlecol = "black", mylayout = NULL) return_layout(regs = NULL, targets = NULL, namehash = NULL) return_layout_phenotype( regs = NULL, targets = NULL, varfile = NULL, namehash = NULL ) orderGraphWeights(graph, edgelist)
mygraph |
igraph object returned from |
mytitle |
Desired tittle. |
titlecol |
Color for the tittle. |
mylayout |
desired layout. |
regs |
regulators name list |
targets |
targets name list |
namehash |
list containing the drivers genes as names and transcripts as values. If only genes are required, leave it empty. |
varfile |
two column file containing, gene names as rows, t-statistic from the differential expression analysis of the desired phenotype column and a boolean variable for regulator (1) - no regulator (0) column. |
graph |
igraph object |
edgelist |
list containing the edges of the igraph object. |
plot of the desired single GRN using a specific layout.
## Assume we have run the rewiring method and the `NET_run()` method to generate the ## igraph object. We are going to generate and plot both layouts for the example. ## We are going to generate all the files we need except for the igraph object, which ## is included as an example file in this package. ## We load the igraph object that we generated from the `NET_run()` example. ## Note: the igraph object is inside the list `NET_run()` generates. graph <- readRDS(paste0(system.file('extdata',package='TraRe'), '/graph_netrun_example.rds'))$graphs$VBSR ## We first generate the normal layout for the plot. ## We need the drivers and target names. drivers <- readRDS(paste0(system.file('extdata',package='TraRe'),'/tfs_linker_example.rds')) drivers_n <- rownames(drivers) targets <- readRDS(paste0(system.file('extdata',package='TraRe'),'/targets_linker_example.rds')) targets_n <- rownames(targets) ## As for this example we are working at gene level (we dont have transcripts inside genes), ## we will generate a dictionary with genes as keys and values (see param `namehash`) normal_layout <- return_layout(drivers_n,targets_n) ## We now generate the phenotype layout and the `varfile` we ned for this layout. ## (I leave here a way to generate) We need to separate our expression matrix by ## a binary phenotype, for this case, i will consider the first 40 samples are ## responding to a treatment (R) and the rest not (NR). gnames <- c(drivers_n,targets_n) expmat <-rbind(drivers,targets) phenotype <- utils::read.delim(paste0(system.file('extdata',package='TraRe'), '/phenotype_rewiring_example.txt')) expmat_R <- expmat[,phenotype$Class=='R'] expmat_NR <- expmat[,phenotype$Class=='NR'] varfile <- t(as.matrix(sapply(gnames, function(x) c(stats::t.test(expmat_R[x,],expmat_NR[x,])$statistic, if(x%in%drivers_n) 1 else 0)))) colnames(varfile)<-c('t-stat','is-regulator') phenotype_layout <- return_layout_phenotype(drivers_n,targets_n,varfile) plot_igraph(graph,mytitle='Normal Layout',titlecol='black',mylayout=normal_layout) plot_igraph(graph,mytitle='Phenotype Layout',titlecol='black',mylayout=phenotype_layout)