SachaEpskamp / qgraph

Developmental version of qgraph
GNU General Public License v2.0
68 stars 21 forks source link

Error in if (sign(tans) != sign(curve[i])) { : argument is of length zero #87

Closed johannesnicolaus closed 6 months ago

johannesnicolaus commented 6 months ago

Hi, thanks so much for the very nice package. I just have a problem which might be a bug? And I don't really know what is happening. I get the error message Error in if (sign(tans) != sign(curve[i])) { : argument is of length zero, but I'm not really sure what is wrong with the code.

Here is the dataframe I supplied

df <- data.frame(
  from = c(
    "g11367\nSP8", "g11367\nSP8", "g11367\nSP8", "g11367\nSP8", "g11367\nSP8",
    "g11367\nSP8", "g11367\nSP8", "g11367\nSP8", "g11367\nSP8", "g11367\nSP8",
    "g11367\nSP8", "g11367\nSP8", "g11367\nSP8", "g11367\nSP8", "g4717\nUSF2",
    "g13117\nFOXF1", "g2871\nFOXA3", "g151\nfkh", "g12038\nFOXB1", "g9775\nFOXI3"
  ),
  to = c(
    "g11367\nSP8", "g11367\nSP8", "g4717\nUSF2", "g4717\nUSF2", "g13117\nFOXF1",
    "g13117\nFOXF1", "g12038\nFOXB1", "g8578\nGATA3", "g5112\nGATA3", "g10540\nNKX2-3",
    "g10540\nNKX2-3", "g8771\nCHD1", "g4531\nPAX5", "g6789\nHES4", "g13117\nFOXF1",
    "g13117\nFOXF1", "g13117\nFOXF1", "g13117\nFOXF1", "g13117\nFOXF1", "g13117\nFOXF1"
  ),
  weight = c(
    6.20711, 9.12723, 6.57728, 4.35922, 11.46320,
    6.93222, 4.45250, 5.06128, 5.31614, 1.61409,
    1.94034, 9.50634, 5.28726, 8.74708, 9.78652,
    9.78652, 9.78652, 9.78652, 9.78652, 9.78652
  ),
  stringsAsFactors = FALSE # to keep strings as characters
)

And the code I used (I used 1:7 just as an example, in practice I use some other sizes and they also don't work). interestingly 1:2 works but 1:3 does not work...

qgraph(df, vsize = 1:7)

Would be great if this works because the plot produced by qgraph is really nice.

SachaEpskamp commented 6 months ago

You have 13 nodes but are only supplying 7 node sizes. You need to supply either one node size for all nodes or a node size per node (vsize should have 1 or 13 elements).