GithubHelp home page GithubHelp logo

qgraph's Introduction

qgraph's People

Contributors

alexchristensen avatar danielruss avatar erikson84 avatar giuliocostantini avatar jmbh avatar kai-nehler avatar maelle avatar sachaepskamp avatar vandenman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

qgraph's Issues

contralityPlot: include = "all" does not work

Hi Sacha,

I just installed the devel version of qgraph in order to compare different networks with the centralityPlot function. This is the code: centralityPlot(list(network1, network2, include = "all"))

When I don´t use the include = "all" command it gives me only strength for both, but when I use it I get the following error:

Error in UseMethod("getWmat") :
no applicable method for 'getWmat' applied to an object of class "character"

When I use centralityPlot(list(network1, network2), include ="ALL") it gives me the following error: Error: Faceting variables must have at least one value

I also tried centralityPlot(list(network1, network2, include = c("Strength", "Closeness","Betweenness","ExpectedInfluence"))) which gives me
Error in UseMethod("getWmat") :
no applicable method for 'getWmat' applied to an object of class "character"

again.

But I would also like to have at least betweenness and closeness in the graph, too.

When I do this for only one network (centralityPlot(network1, include = "all"))) it works fine.

Any suggestions?
Thanks,
Jan

Moving directional edges between two nodes closer together

Hello,

I've created a network graph (using an edgelist imported from a .csv) that has two weighted directional edges between each pair of nodes. I would like to move the two edges between each pair closer together to reduce overlap where the various edges join the nodes and improve readability. I've been trawling through the documentation and can't find a way to do this, though I've seen it in example graphs around the place so I suspect it's possible. Example:

qgraph(input_PTZ, parallelEdge = TRUE, layout = "spring")

Draft_1_PTZ_leg

For example, say the space between the two edges running between nodes 1 and 2 was (hypothetically) 1cm, I would like to reduce that gap to say 0.5cm (for all cases on the graph). You can see in the current format the various edges are overlapping close to each node. I've tried increasing the size of the nodes using vsize but the distance between the edges increases proprtionately - maybe there is a way to specify where the edges enter/leave the node? Any assistance appreciated

qgraph.pca not available

Hi, I've been following all of the awesome examples of qgraph on the web and have created some great visualizations with it, thanks!
For some reason qgraph.pca is not showing up in the list of available functions.
qgraph.loadings is available.
I'm using version 1.65 with a fresh install of R and Rstudio
I tried in R-Gui, also...
Thanks for any help you can give!
Cheers,
Percy

qgraph::flow produces weird edges for an mgm network

Ok, so I have this mgm-estimated network:

image

When I plot it with flow instead, I get this:
qgraph::flow(BCT_mgm, "PA accelerometer", theme = "colorblind", vsize = 8)

image

For another variable, this:
qgraph::flow(BCT_mgm, "PA selfrep", theme = "colorblind", vsize = 8)

image

Any thoughts?

Where can I set lambda argument in qgraph?

Hi Sacha,

First I appreciate your qgraph very much! I am now using this package for data analysis. I saw your instruction and example in this article, https://eiko-fried.com/wp-content/uploads/Epskamp-Fried-2018-Tutorial-partial-corr.pdf. However, I don't find where I can set the lamda argument. I only find the tunning and gamma argument (they are same if I don't misunderstand), so could you kindly tell me which I can set the lambda argument, or where can I find the code for you deme data in this article, https://eiko-fried.com/wp-content/uploads/Epskamp-Fried-2018-Tutorial-partial-corr.pdf. Thanks very much!

centralityPlot error

Hi Sasha,

I am getting an error running centralityPlot function:

Error in centralityTable(..., standardized = standardized, labels = labels, :
(list) object cannot be coerced to type 'double'

My code is below. I know there was a previous issue on this error closed on March 6th. I re-downloaded qgraph through R and also tried downloading github version. I am still getting the error. This same exact code worked for me a few months ago. Thanks for your help!

Data1 <- as.data.frame(read_excel("C:/...)
beepvar <- "beep"
dayvar <- "day"
Data1$time <- as.POSIXct(Data1$time)
Data1$Day <- as.Date(Data1$time)
data2 <-graphicalVAR(Data1, vars=Vars, beepvar=beepvar, gamma=0)
u1 <- plot(data2, "PCC", labels = names)
u2 <- plot(data2, "PDC", labels = names)
c1 <- centralityPlot(u1)
c2 <- centralityPlot(u2)

qgraph crash

I am unable to load qgraph package in my R environment. Whenever I am trying to load it crashing out R.
I am using R version 3.3.3 (2017-03-06) -- "Another Canoe"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-apple-darwin13.4.0 (64-bit)

library(qgraph)

*** caught segfault ***
address 0x318, cause 'memory not mapped'

Traceback:
1: dyn.load(file, DLLpath = DLLpath, ...)
2: library.dynam(lib, package, package.lib)
3: loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]])
4: asNamespace(ns)
5: namespaceImportFrom(ns, loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]), i[[2L]], from = package)
6: loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]])
7: asNamespace(ns)
8: namespaceImportFrom(ns, loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]), i[[2L]], from = package)
9: loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]])
10: asNamespace(ns)
11: namespaceImportFrom(ns, loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]), i[[2L]], from = package)
12: loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]])
13: asNamespace(ns)
14: namespaceImportFrom(ns, loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]), i[[2L]], from = package)
15: loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]])
16: asNamespace(ns)
17: namespaceImportFrom(ns, loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]), i[[2L]], from = package)
18: loadNamespace(package, lib.loc)
19: doTryCatch(return(expr), name, parentenv, handler)
20: tryCatchOne(expr, names, parentenv, handlers[[1L]])
21: tryCatchList(expr, classes, parentenv, handlers)
22: tryCatch(expr, error = function(e) { call <- conditionCall(e) if (!is.null(call)) { if (identical(call[[1L]], quote(doTryCatch))) call <- sys.call(-4L) dcall <- deparse(call)[1L] prefix <- paste("Error in", dcall, ": ") LONG <- 75L msg <- conditionMessage(e) sm <- strsplit(msg, "\n")[[1L]] w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w") if (is.na(w)) w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L], type = "b") if (w > LONG) prefix <- paste0(prefix, "\n ") } else prefix <- "Error : " msg <- paste0(prefix, conditionMessage(e), "\n") .Internal(seterrmessage(msg[1L])) if (!silent && identical(getOption("show.error.messages"), TRUE)) { cat(msg, file = stderr()) .Internal(printDeferredWarnings()) } invisible(structure(msg, class = "try-error", condition = e))})
23: try({ attr(package, "LibPath") <- which.lib.loc ns <- loadNamespace(package, lib.loc) env <- attachNamespace(ns, pos = pos, deps)})
24: library(qgraph)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

centralityPlot with confidence intervals

Hey Sacha,

Just trying to reproduce your Figure 2 in the Supplementary Materials (i.e. 95% quantile regions plotted in centralityPlot (Epskamp, Borsboom, Fried, 2018)

Bootstrap 95% CIs on centrality indices:
boot3 <- bootnet(Data, 100, default = "pcor", type = "parametric")

Plot the 95% quantile regions:
plot(boot3, statistics = c("strength","closeness","betweenness"),CIstyle = "quantiles")

Instead, I appear to be getting the node strength plot, like figure 6 (below) from the (Epskamp, Borsboom, Fried, 2018) tutorial paper

Arianne

error in qgraph

library("psych")
big5pca <- principal(cor(big5),5,rotate="promax")
qgraph(big5pca,groups=big5groups,layout="circle",rotation="promax",minimum=0.2,

  •    cut=0.4,vsize=c(1.5,10),borders=FALSE,vTrans=200,title="Big 5 PCA")
    

Error in qgraph(big5pca, groups = big5groups, layout = "circle", rotation = "promax", :
Input is not a weights matrix or an edgelist.

Does edge color really mean "positive/negative correlation" statistically?

Hi Sacha
Recently I found all the edge color of object from "mgm" were darkgrey in qgraph. When I searched
manual of qgraph and found "posCol Color of positive edges. Can be a vector of two to indicate color of edges under ’cut’ value and color of edges over ’cut’ value." This is to say, the edge color depends on "cut" value instead of actual positive/negative correlation. I was very confused about it. Can you explain it more? Thanks a lot!

Plotting subsetting results - no values on the y axis

When I am plotting the subsetting results, the plot does not show any values on the y axis.

subplot1 <- plot(sub1, labels = FALSE, order="sample")
subplot1 + ggtitle("Correlation Network") + 
  theme(plot.title = element_text(size = 10, face = "bold", hjust = 0.5))

When I try to add a y axis with ggplot2, as follows:

subplot1 <- plot(sub1, labels = FALSE, order="sample")
subplot1 + ggtitle("Correlation Network") + 
  theme(plot.title = element_text(size = 10, face = "bold", hjust = 0.5)) +
  scale_y_continuous(limits=c(1,-1))

It messes up the whole plot and I get the following error:

Scale for 'y' is already present. Adding another scale for 'y', which will replace the
existing scale.
Warning messages:
1: Removed 30 rows containing missing values (geom_point). 
2: Removed 1 rows containing missing values (geom_hline).

And although I can find subsetting plots online that have y axis values, I cannot find the relevant code. ``
Any suggestions?

centralityPlot error with 1.6

After updating to qgraph 1.6, I'm having errors with centralityPlot. I didn't have any problems generating the plot in 1.5.

Error in centralityTable(..., standardized = standardized, labels = labels, :
(list) object cannot be coerced to type 'double'

Question with getting zero closeness centralities

Hi I'm a R beginner and doing some study of network analysis of 30 item survey, thanks to great help from your cookbook website. I'm not sure if i should write my question on qgraph, but I couldn't find other place to get information.

I have a problem with computing closeness centrality. I got my centrality strength, betweenness centrality graph. Also I got my closeness centrality graph with warning messages "Removed 4 rows containing missing values (geom_point)", with missing four in the graph(as attached file).
The real problem is if I compute closeness centrality with 'centRes$Closeness', I get all zeros as below even though I got non-zero closeness centralities except four items.
capture

GDS.1 GDS.2 GDS.3 GDS.4 GDS.5 GDS.6 GDS.7 GDS.8 GDS.9 GDS.10 GDS.11
0 0 0 0 0 0 0 0 0 0 0
GDS.12 GDS.13 GDS.14 GDS.15 GDS.16 GDS.17 GDS.18 GDS.19 GDS.20 GDS.21 GDS.22
0 0 0 0 0 0 0 0 0 0 0
GDS.23 GDS.24 GDS.25 GDS.26 GDS.27 GDS.28 GDS.29 GDS.30
0 0 0 0 0 0 0 0

my made my codes as below:
library("IsingFit")
library("qgraph")
library("bootnet")
data=read.csv("dementia.csv")
Res <- IsingFit(as.matrix(data),gamma = 0.25, plot=FALSE)
Graph_Ising2 <- qgraph(Res$weiadj, layout = "spring")
centRes$OutDegree
centRes$Betweenness
centRes$Closeness
centralityPlot(Graph_Ising2, scale="raw", include = c("Strength", "Betweenness", "Closeness"), orderBy="Strength")

I can't figure out why all closeness centralities are zero inspite of other meaningful values.
Do I have missing points?

Thank you,
Kim

coloring of dots in legend when specifying colors using "colors=..." does not work properly

reproducible example:

set.seed(1)
p <- 10
g <- matrix(sample(0:1, p^2, replace=T),p,p)
g <- pmax(g,t(g)); diag(g) <- 0
groups <- sample(c("group1", "group2", "group3"), p, replace=T)
group_cols <- numeric(p)
group_cols[groups=="group1"] <- "blue"
group_cols[groups=="group2"] <- "green"
group_cols[groups=="group3"] <- "red"
qgraph(g, colors=group_cols, groups=groups)

qgraph error with non-ACSII symbols

Hi.

I have some troubles with the objects which names are not English.

> adj <- matrix(sample(0:1, 3^2, TRUE, prob = c(0.8, 0.2)), nrow = 3, ncol = 3)
> dimnames(adj) <- list(c("Аб", "Вг", "Ед"),  c("Аб", "Вг", "Ед"))
> adj
   Аб Вг Ед
Аб  0  1  1
Вг  0  0  0
Ед  0  1  0
> qgraph(adj)

(process:8196): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()

(process:8196): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()

(process:8196): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()

(process:8196): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text()

Session info:

> sessionInfo()
R version 3.1.2 (2014-10-31)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=ru_RU.UTF-8       LC_NUMERIC=C               LC_TIME=ru_RU.UTF-8        LC_COLLATE=ru_RU.UTF-8    
 [5] LC_MONETARY=ru_RU.UTF-8    LC_MESSAGES=ru_RU.UTF-8    LC_PAPER=ru_RU.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=ru_RU.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] qgraph_1.3   magrittr_1.5

loaded via a namespace (and not attached):
 [1] acepack_1.3-3.3     cluster_2.0.1       colorspace_1.2-4    corpcor_1.6.7       d3Network_0.5.2.1   digest_0.6.8       
 [7] ellipse_0.3-8       fdrtool_1.2.13      foreign_0.8-62      Formula_1.2-0       ggm_2.3             ggplot2_1.0.0      
[13] glasso_1.8          grid_3.1.2          gtable_0.1.2        gtools_3.4.1        Hmisc_3.14-6        huge_1.2.6         
[19] igraph_0.7.1        jpeg_0.1-8          lattice_0.20-29     latticeExtra_0.6-26 lavaan_0.5-17       MASS_7.3-37        
[25] Matrix_1.1-5        matrixcalc_1.0-3    mnormt_1.5-1        munsell_0.4.2       nnet_7.3-8          parallel_3.1.2     
[31] pbivnorm_0.6.0      pixmap_0.4-11       plyr_1.8.1          png_0.1-7           proto_0.3-10        psych_1.5.1        
[37] quadprog_1.5-5      RColorBrewer_1.1-2  Rcpp_0.11.4         reshape2_1.4.1      rjson_0.2.15        rpart_4.1-8        
[43] rtiff_1.4.4         scales_0.2.4        sem_3.1-5           sendplot_4.0.0      sna_2.3-2           splines_3.1.2      
[49] stats4_3.1.2        stringr_0.6.2       survival_2.37-7     tools_3.1.2         whisker_0.3-2      

[error] qgraph destroys base summary function for characters

Hi,
after loading package qgraph the base summary function does no longer work properly. It outputs all characters of class character instead of only 5.

Example:

iris2 <- iris
iris2$char <- as.character(iris$Petal.Width)
summary(iris2)
library(qgraph)
summary(iris2)

R Version 3.4.1
qgraph Version 1.4.3

Regards
Hans

clusteringPlot error when run with "list" object

I get clusteringPlot with
clusteringPlot(pcorGraph)

But I see error with
clusteringPlot(list(pcorGraph))

Error in clusteringTable(..., labels = labels, standardized = standardized, :
(list) object cannot be coerced to type 'double'

How can I get the clusteringPlot with multiple objects?

sincerely.

Jinseob Kim

Nodes of the same community not displayed next to each other

Hi Sacha,

I have plotted a graph of the network structure of various psychological symptoms, after using EGA to estimate the network ( my code is below). The EGA identified four distinct communities, as shown in the graph below. In the graph two of the red nodes of Community 1 are shown apart from the rest of the red nodes of this community. Is there a reason for this? Is it possible to plot the graph with all nodes of Community 1 next to each other?

gega.v1 <- EGA(gcombdata.v1, model = "glasso", algorithm = "louvain")

gega_v1_plot <- plot(gega.v1, vsize = 7, layout = "spring", groups = as.factor(gega.v1$wc), labels = colnames(gega_colnames_v1), label.prop=1, label.norm="OOOOOOO")

image

using argument res leads to incorrect warning

Here is a simple example

mat <- matrix(c(0,1,1,0,0,1,0,0,0),ncol=3,byrow = T)
qgraph(mat,filetype="png", filename="simplenet.png",height = 7, width = 10, res=100)
Output stored in /Users/druss/SingleCell/pipeline/simplenet.png
Warning message:
In qgraph(mat, filetype = "png", filename = "simplenet", height = 7,  :
  The following arguments are not documented and likely not arguments of qgraph and thus ignored: res

I believe all you have to do is add "res" to the allArgs on line 257.
Thank you,
Daniel

Changing arrowhead symbol

Any chance you could (explain how to) implement an option to replace the shape/symbol of the edge arrowheads with a different shape (e.g., any of the pch options of points())? I'm trying to create a graph that uses arrowheads to positive effects and circles (pch=19) for negative effects (e.g., link). thanks

Interpreting Edge Weight (Partial Correlation) Magnitude

Hi Sacha,

Firstly, thank you for making your knowledge and content on Network Analysis accessible to everyone. It is a cool analytical technique and I have enjoyed learning from your work.

I have recently computed a regularised partial correlation network using your tutorial as a guide (Epskamp & Fried, 2018). The network contains 12 nodes and 43 edge weights (65.15% of all possible pairwise associations). The magnitude of the edge weights (partial correlations) ranges from (r = .00 to .42).

How do you interpret the magnitude (and/or salience) of each association in the network. Is it appropriate to say that two nodes share a strong, moderate, or weak association based on the magnitude of the associated partial correlation. If so, what criteria would you employ to make such evaluations (e.g., > .10, >.30, >.50)?

Or alternatively, is it the case that any edges remaining following the LASSO regularisation (EBIC hyperparameter = 0.5) are important (regardless of the partial correlation magnitude)?

Any advice on the above would be of great help.

Best Regards,

Michael.

Node labels overlapping

Hi Sacha,

I'm a big fan of qgraph; I think it's great! It's been very useful for my particle physics data analysis, where I use it to study correlations between feature variables in my models.

But I have a problem with overlapping node labels with large force-directed networks (layout = "spring"). This happens when I have a lot of very highly-correlated features clustering together tightly. It's not possible to read the node labels. I could use abbreviated node labels or number the nodes and use a legend, but often this doesn't help, and it makes it harder to read the information contained in the visualisation.

I've been trying to develop a fix for this myself, but without much luck. I have tried to convert the qgraph object to an igraph object using as.igraph(), but the resultant igraph network doesn't look much like the qgraph network. They seem very different in their topology. It's possible that I just don't understand igraph well enough to use it effectively. My plan would then be to use ggnetwork to convert the igraph object into something that ggplot2 will understand, and use ggrepel for the node labels. This is kind of what I had in mind:
https://rud.is/projects/clinton_emails_01.html
See? No overlapping node labels! But, sadly, I haven't been able to do this. The networks from igraph and qgraph are very very different, and I've failed in my attempts to use ggnetwork to produce anything even remotely resembling the network that qgraph produced. My second idea was to parse the qgraph object for edge and node information, and although I can see how to use ggplot2 to get the node positions, I don't know how to proceed to get the node labels and edges.

Basically, I'd like either qgraph to support ggrepel for node labels, or I'd like to do:
qgraph(matrix) --> igraph object --> ggnetwork --> ggplot2 plot + ggrepel for node labels.

Any ideas on how either of these two options could be implemented?

With many thanks,

Andrew.

Using images as nodes without saving as objects

Hi,

I have images for nodes, which I'd like to use in a (multiplex network) graph, in a list of lists (i.e. 9 images corresponding to 9 nodes per person, for 19 people). Is there a way to use them as qgraph's node images without first saving them as files?

If not, could you perhaps point to a sensible approach of not having to explicitly list each of the 9*19 images?

Cheers!

move packages from Imports to Suggests field [Suggestion]

I suggest reviewing the necessity of declaring so many packages under 'imports' field in DESCRIPTION. I suspect some of those packages are only necessary for certain use cases (e.g. not for mine). Having to install so many dependencies bugs me.

Just a suggestion. Needless to say (but I still say it for emphasis) the decision is the package developers.

Font error

In doTryCatch(return(expr), name, parentenv, handler) :
no font could be found for family "Arial"

The graph has no labels I have tried to import fonts etc. but this has not fixed the problem. Any ideas?

switch from d3network to networkD3

d3Network was deprecated 2.5 years ago and development moved to networkD3. I'd be willing to help you convert your qgraphD3 function to use networkD3, though it looks like qgraphD3 is not exported nor mentioned anywhere else. Any interest?

Question on relation between qgrap output and correlation matrix, color of the edges

My question is about having red edges that do not correspond to negative numbers in the network correlation matrix.

I just start learning network analysis and to start I decided to replicate the
The application of a network approach to Health-Related Quality of Life (HRQoL): introducing a new method for assessing HRQoL in healthy adults and cancer patients.
Because I have cohort of subjects who answered sf36 (n=737).
I use the programs associate to the article: R program in https://osf.io/rwvm6/
I first replicated fig2 for the 36 items, I get a similar diagrams. I think some items may have been code in the opposite order, this is why I get some red edges where you don’t. Also, when I visually look at numbers of the correlation matrix the color and the size of the edges are coherent, ie negative correlations are in red, positive correlations are in green, bigger correlations are associated to larger edges. To get 2 groups, I split the cohort in 2, a group who answered that they often feel lonely and a group who answered sometimes or never feel lonely.
When I replicate fig 3 for the 8 domains, I get different results. First I get red edges but when I look at the correlation matrix, I don’t have any negative correlation. I don’t understand why I get red edges.
This is what I did
I ran this program for the sf36 domains for 737 subjects
I get the graph from those functions
labels2 <- c("PF","RP","BP","GH","VT","SF","RE","MH","DS")
Layout_Graph <- qgraph(graph_all, graph = "glasso", layout = "spring", sampleSize = nrow(data_all))
L1 <- averageLayout(Layout_Graph)
graph_all <- cor_auto(data_all)
Data_all has 737 row.
DS=0 feel lonely often, DS=1 feel lonely sometimes or never

Graph_all <- qgraph(graph_all, graph = "glasso", layout = L1, sampleSize = nrow(data_all), esize = 20, cut = 0.1, minimum = 0, maximum = 1,
color= c("yellow", "cornflowerblue", "purple", "grey", "orange", "green", "maroon1", "red", "chocolate3"),
borders = FALSE, vsize= 10, labels = labels2, legend = FALSE)
mtext("(c)", cex = 1.25, side = 1, line = 8.7, las = 1)

Here is the correlation matrix

dput(graph_all)

structure(c(1, 0.499931025056832, 0.553243490045503, 0.545853343556307,
0.408656958778119, 0.369330666775307, 0.289046953664939, 0.241953860982174,
0.19901569137775, 0.499931025056832, 1, 0.624401817605508, 0.54310418084152,
0.622747868221131, 0.641736656112912, 0.624778121078169, 0.470886680477519,
0.307696679449673, 0.553243490045503, 0.624401817605508, 1, 0.500283796401499,
0.4860506368617, 0.510760344253669, 0.403820838305521, 0.343061789506324,
0.180888071514773, 0.545853343556308, 0.54310418084152, 0.500283796401499,
1, 0.607091736780751, 0.491133953414105, 0.421119329051919, 0.475705823397117,
0.396924015777883, 0.408656958778119, 0.622747868221131, 0.4860506368617,
0.607091736780751, 1, 0.648335463054217, 0.557489184128694, 0.694982986114683,
0.449182711222666, 0.369330666775307, 0.641736656112912, 0.510760344253669,
0.491133953414105, 0.648335463054217, 1, 0.618408390041698, 0.642642564387107,
0.464702190917403, 0.289046953664939, 0.624778121078169, 0.403820838305521,
0.421119329051918, 0.557489184128694, 0.618408390041698, 1, 0.590310670736049,
0.406601300770822, 0.241953860982174, 0.470886680477519, 0.343061789506324,
0.475705823397117, 0.694982986114683, 0.642642564387107, 0.590310670736049,
1, 0.594106900304187, 0.19901569137775, 0.307696679449673, 0.180888071514773,
0.396924015777883, 0.449182711222666, 0.464702190917403, 0.406601300770822,
0.594106900304187, 1), .Dim = c(9L, 9L), .Dimnames = list(c("pf",
"rp", "bp", "gh", "vt", "sf", "re", "mh", "DS"), c("pf", "rp",
"bp", "gh", "vt", "sf", "re", "mh", "DS")))

The result of the qgraph is in the pdf document below, network (c) with the 2 groups together (lonely and sometimes or never lonely). I do not include information for network (a) and (b) but I get the same results with red edges and no negative correlation in the corresponding matrix.

Fig3domains.pdf

Thank you
Lyne

move edge labels

Is there a way to move edge labels such that they appear next to edges rather than on top of edges? Something like edge.label.offset?

issue with centralityTable ()

The latest version of qgraph returns an error when I want to compute the raw centrality measures, or if I want to include certain centrality measures.

MWE:

library(psych)
library(qgraph)
library(bootnet)

data(bfi)
bfiSub <- bfi[,1:25]

Estimate network:

Network <- estimateNetwork(bfiSub, default = "EBICglasso")
centralityTable(Network) # works
centralityTable(Network, scale = "raw") #error : Error in UseMethod("getWmat") :
no applicable method for 'getWmat' applied to an object of class "character"
centralityTable(Network, include = c("Strength")) # same error are above

Get edgeConnectPoints after plotting

Hi,

first of all I would like to say that I really like this package. Produces really nice plots.

However, I was wondering if it is possible to get the edgeConnectPoints when they are not specified as an argument.

The thing is that I would like to change only one edgeConnectPoint, because an arrow is overlapping. So what I would like to do is the following:

  1. get the edgeConnectPoints of the original plot
  2. Change one of the edgeConnectPoints
  3. Plot qgraph again while giving the argument for edgeConnectPoints with the new set.

When I give the edgeConnectPoints as an argument, I can find them via g$graphAttributes$Edges$edgeConnectPoints, but when I did not specify them at the beginning the output of the beforementioned code is NULL

Hope you can help me with this.
Thanks

Flow function in qgraph error edgeConnectPoints

Hello I'm new with R and start to learn network analysis using qgraph with a data cohort that have sf36 questionnaire.
I try to do a flow diagram from one of the item and I get this error below. I don't find references about this error.
I did a qgraph call g2
g2 <- qgraph(corMat_n, graph = "glasso", layout = L2, sampleSize = nrow(Datan),
esize = 20, cut = 0.1,
minimum = 0, maximum = 1, groups = groups1,
color = c("red", "yellow", "orange", "cornflowerblue", "green", "purple", "grey", "maroon1", "chocolate3"),
borders = FALSE, vsize= 10, labels = labels1, legend = FALSE)
mtext("(b)", cex = 1.25, side = 1, line = 8.7, las = 1)

then run the flow and get an error

flow(g2, "SF 32", theme = "colorblind", vsize = 4)
Error in qgraph(object, layout = Layout, curve = Curve, edgeConnectPoints = ECP, :
Number of rows in 'edgeConnectPoints' do not match number of edges

I don't know where to look for that type of error.
Am I giving enough information?

thank you
Lyne

error in installing the packages

Hi,
May I know the issue below? I cannot install this package. May I have yoru help?
Thanks.

install.packages("qgraph",type="source")
also installing the dependency ‘BDgraph’
trying URL 'https://cran.rstudio.com/src/contrib/BDgraph_2.51.tar.gz'
Content type 'application/x-gzip' length 2283912 bytes (2.2 MB)
downloaded 2.2 MB
trying URL 'https://cran.rstudio.com/src/contrib/qgraph_1.5.tar.gz'
Content type 'application/x-gzip' length 243083 bytes (237 KB)
downloaded 237 KB

  • installing source package ‘BDgraph’ ...
    ** package ‘BDgraph’ successfully unpacked and MD5 sums checked
    checking whether the C++ compiler works... yes
    checking for C++ compiler default output file name... a.out
    checking for suffix of executables...
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C++ compiler... yes
    checking whether clang++ -std=gnu++11 accepts -g... yes
    checking for clang++ -std=gnu++11 option to support OpenMP... unsupported
    configure: creating ./config.status
    config.status: creating src/Makevars
    ** libs
    clang -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c BDgraph_init.c -o BDgraph_init.o
    clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c MyLapack.cpp -o MyLapack.o
    clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c bd_for_ts.cpp -o bd_for_ts.o
    clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c check_nthread.cpp -o check_nthread.o
    clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c check_os.cpp -o check_os.o
    clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c copula.cpp -o copula.o
    clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c gcgm_DMH.cpp -o gcgm_DMH.o
    clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c gcgm_bd.cpp -o gcgm_bd.o
    clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c ggm_DMH.cpp -o ggm_DMH.o
    clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c ggm_bd.cpp -o ggm_bd.o
    clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c ggm_mpl_bd.cpp -o ggm_mpl_bd.o
    clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c gm_mpl_Hill_Climb.cpp -o gm_mpl_Hill_Climb.o
    clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c gm_mpl_bd_dis.cpp -o gm_mpl_bd_dis.o
    clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c gm_rj.cpp -o gm_rj.o
    clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c matrix.cpp -o matrix.o
    clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c omp_set_num_cores.cpp -o omp_set_num_cores.o
    clang++ -std=gnu++11 -I/Library/Frameworks/R.framework/Resources/include -DNDEBUG -I/usr/local/include -fPIC -Wall -g -O2 -c rgwish.cpp -o rgwish.o
    clang++ -std=gnu++11 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o BDgraph.so BDgraph_init.o MyLapack.o bd_for_ts.o check_nthread.o check_os.o copula.o gcgm_DMH.o gcgm_bd.o ggm_DMH.o ggm_bd.o ggm_mpl_bd.o gm_mpl_Hill_Climb.o gm_mpl_bd_dis.o gm_rj.o matrix.o omp_set_num_cores.o rgwish.o -L/Library/Frameworks/R.framework/Resources/lib -lRlapack -L/Library/Frameworks/R.framework/Resources/lib -lRblas -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0 -L/usr/local/gfortran/lib -lgfortran -lquadmath -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
    ld: warning: directory not found for option '-L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin15/6.1.0'
    ld: warning: directory not found for option '-L/usr/local/gfortran/lib'
    ld: library not found for -lgfortran
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make: *** [BDgraph.so] Error 1
    ERROR: compilation failed for package ‘BDgraph’
  • removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/BDgraph’
    Warning in install.packages :
    installation of package ‘BDgraph’ had non-zero exit status
    ERROR: dependency ‘BDgraph’ is not available for package ‘qgraph’
  • removing ‘/Library/Frameworks/R.framework/Versions/3.4/Resources/library/qgraph’
    Warning in install.packages :
    installation of package ‘qgraph’ had non-zero exit status

The downloaded source packages are in
‘/private/var/folders/jb/324x34fd61ng6j5qf5kdrsfr0000gn/T/Rtmprx3vRc/downloaded_packages’

Trying to use a map as a graph background using qgraph

Hi Sacha and others:

I wonder if there is any way to use a user specific plot as a background in a graph. Specifically, I'm trying to use latitude and longitude coordinates to put the graph nodes over a map... However I'm unable to use a map as a underling picture...

Any idea?

Cheers

"Spring" Details

Hi, thanks for the excellent package!

This is a request for information on the spring layout method and potentially to add this info to the documentation.

Initialisation

Spring layout is the Fruchterman Reingold method, but the FR algorithm in the '91 paper starts with a random initialisation of node positions. The "spring" layout in qgraph gives the same result each time which from the code seems to be because qgraph generates a fixed initialisation.

The current igraph implementation of fr (layout_with_fr) gives a different result each time unless you set.seed.

The qgraph() documentation says:

A solution to use this function for weighted graphs has been taken from the igraph package (Csardi G & Nepusz T, 2006) in which the same function was ported from the SNA package.

Igraph has had some updates, did it diverge since the function was modified for qgraph? Or was the deterministic behaviour added for qgraph?

Weight scaling

The weights used in the call to the qgraph FR algorithm are normalised weight / max(weight) and then squared (unless sig = TRUE). This diverges from igraph, and I don't think is documented? (apologies if I'm missing this).

I think the end result (graph layouts) in qgraph look great, and the deterministic behaviour is really desirable, but it would be great to clarify the deterministic behaviour and weight scaling points somewhere in the R docs.

Global Transitivity That Takes Weights and Signs Into Account?

Hi Dr. Epskamp,

This is not an "issue" per se, but seems potentially relevant to future implementations of qgraph.

I am working through some of your published tutorials in the qgraph package (all of which are great by the way!). In Constantini et al. (1), network transitivity is introduced in a way that does not take into account weights and signs, but then mentions that Opsahl & Panzarasa (2) and Kunegis et al. (3) have found solutions that do take those into account. In the qgraph documentation, I see that transitivity (called by the smallworldness() function) also does not take into account weights and signs. I also looked at the transitivity() function from the igraph package, but this too seems to ignore weights and signs (for global transitivity - local transitivity i.e., for individual nodes does seem to take those into account).

I was wondering if you knew of an implementation in r for getting the weighted and signed transitivity, and/or if you guys were planning on implementing/would consider implementing this into future iterations of qgraph?

Thanks for your time,
Matthew

(1) Costantini, G., Epskamp, S., Borsboom, D., Perugini, M., Mõttus, R., Waldorp, L. J., & Cramer, A. O. (2015). State of the aRt personality research: A tutorial on network analysis of personality data in R. Journal of Research in Personality, 54, 13-29.

(2) Opsahl, T., & Panzarasa, P. (2009). Clustering in weighted networks. Social Networks, 31(2), 155–163. http://dx.doi.org/10.1016/j.socnet.2009.02.002.

(3) Kunegis, J., Lommatzsch, A., & Bauckhage, C. (2009). The Slashdot Zoo: Mining a social network with negative edges. In Proceedings of the 18th international conference on world wide web (pp. 741–750). http://dx.doi.org/10.1145/ 1526709.1526809.

centralityPlot - grouping graphs without colour

Hi Sacha,

I am plotting centrality values for two graphs in the same panel, i.e.:

fig_list <- list(Group 1 = network1, Group 2 = network2)
fig_plot <- centralityPlot(fig_list, include = "ExpectedInfluence",
labels = names, orderBy = "ExpectedInfluence",
theme_bw = TRUE)

By default, this plots the groups by colour (pink and blue). I'm wanting to plot the groups by dots vs. dashes instead of colour. I've tried transferring the centrality data into ggplot via centralityTable() and doing it that way, but have found it difficult trying to reproduce the centrality plot in ggplot (I'm fairly new to ggplot). Is there an easy way?

Cheers!

Labels argument not accepting input

Submitting a vector of labels equal to the number of nodes does not result in labels being applied. Setting labels to false also doesnt result in omission of labels.

Correlations between two different set of variables

I am trying to plot the correlation between two set of variables, however I can't.
The problem arises from the check of (nrow(input) != ncol(input)) because I don't have the same number of variables for each set.

A reproducible example would be:

m <- matrix(runif(45, -1, 1), ncol = 9, nrow = 5)
qqgraph(m, graph = "cor")

Is there any workaround ?

Centrality plot not generated

Hello,

I was trying to create a centrality plot by referring your tutorial (http://sachaepskamp.com/files/Cookbook.html) especially for centralityPlot however all of the functions gave me the following error:

Error in combine_vars(data, params$plot_env, cols, drop = params$drop) : 
  At least one layer must contain all variables used for facetting

As I looked into centralityPlot.R, especially for facettinng part, it was using graph and measure as facetting variables.
centralityPlot.R

  if (length(unique(Long$graph)) > 1)
  {
    g <- g + facet_grid(graph ~ measure, scales = "free") 
  } else 
  {
    g <- g + facet_grid( ~ measure, scales = "free") 
  }

However, as I looked into it, the centralityTable Long does not seem to have the measure columm.

> names(Long)
[1] "graph"    "type"     "node"     "variable" "value"  

Here's the function definition of melt which does not seem to be accepting variable.name that you specified in centralityTable.

reshape2::melt

melt(data, ..., na.rm = FALSE, value.name = "value")

centralityTable.R

  # LONG FORMAT:
  LongCent <- reshape2::melt(WideCent, variable.name = "measure", id.var = c("graph","type", "node"))

So I changed the measure in the centralityPlot to variable which solved the problem.
I opened a merge request - or you may revise it by yourself. I hope this helps.

revised centralityPlot.R

  if (length(unique(Long$graph)) > 1)
  {
    g <- g + facet_grid(graph ~ variable, scales = "free") 
  } else 
  {
    g <- g + facet_grid( ~ variable, scales = "free") 
  }

devmui

Flow function - "number of rows in 'edgeConnectPoints' do not match number of edges" error

Hi,
I'm trying use the flow function using my lasso graph as an object. However, it produces an error saying "Number of rows in 'edgeConnectPoints' do not match number of edges". The flow function works well if I use my partial correlation graph instead of the lasso graph.
Here is my code for the lasso graph:

Graph_lasso<-qgraph(PolyCor, cut=0, graph="glasso",layout="spring",
                    sampleSize=193, threshold=TRUE)

This is the code for the partial correlation graph:

Graph_pcor<-qgraph(PolyCor, graph="pcor", layout="spring", sampleSize=nrow(Data))
This is the code for the flow function:

flow(Graph_lasso,"scd",horizontal=TRUE)

Thank you in advance!

Dependencies not resolved

Qgraph depends on ggm which depends of graph which is obsolete and disapear of CRAN repository...

Warning message: Removed 2 rows containing missing values (geom_point).

hello, Sacha.

I want to ask you errors about centrality.

centralityPlot(Network0, include = c("Strength", "Closeness", "Betweenness"), scale = "relative", orderBy = "Strength")
Note: relative centrality indices are shown on x-axis rather than raw centrality indices.
Warning message:
Removed 2 rows containing missing values (geom_point).

This error only appears in the data containing the threshold = TRUE, is it related? Please reply if you have any guesses.**

PCA not working

Hi, congrats for the packages, I've tested PCA, but PCA example is not working anymore probably due to psych package update:

> R.version
version.string R version 3.6.1 (2019-07-05)
> packageVersion("psych")
[1] ‘1.8.12’
> packageVersion("qgraph")
[1] ‘1.6.3’
> data(big5)
>  big5pca <- principal(cor(big5), 5, rotate = "promax")
> isCorrelation(big5pca)
[1] FALSE
>   qgraph(big5pca)
Error in qgraph(big5pca) : Input is not a weights matrix or an edgelist.

Confusion about centrality

Hi
When I use the centrality function, I get: OutDegree, InDegree, Closeness, Betweenness, InExpectedInfluence, OutExpectedInfluence, ShortestPathLengths, and ShortestPaths values. Surprisingly, there is no "strength" values in the output. However, when I use the centralityplot function, I get a plot of "strength". Can you please let me know why the centrality function does not output node strength values? how could one obtain numerical node strength values?

many thanks in advance,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.