hallucigenia-sparsa / seqtime

The seqtime R package provides functions to analyse sequencing data time series and to simulate community dynamics
Other
21 stars 9 forks source link

fixed negative weight for network plot #26

Closed jotech closed 1 year ago

jotech commented 1 year ago

The network plot in plotA from the tutorial does not work with the current igraph version:

library(seqtime)
N=20
A=generateA(N, c=0.1)
rownames(A)=c(1:N)
colnames(A)=rownames(A)
network=plotA(A,method="network")

Error in layout_with_fr(list(20, TRUE, c(0, 0, 0, 1, 1, 1, 2, 3, 3, 4,  : 
  At core/layout/fruchterman_reingold.c:401 : Weights must be positive for Fruchterman-Reingold layout. Invalid value

The Fruchterman-Reingold layout in igraph needs weights > 0 (see https://igraph.org/r/doc/layout_with_fr.html).

The pull request uses absolute values instead and saves old values as weight.org.

szhorvat commented 1 year ago

Another solution is to pass the absolute values of weights explicitly to layout_with_fr instead of letting the function take them automatically from the graph. This way it won't be necessary to modify the weights stored in the graph.

jotech commented 1 year ago

good point! I updated my pull request accordingly

szhorvat commented 1 year ago

Another note is that most (though not all) igraph functions with dots in their name are deprecated. It's a good idea to replace these by the new names, which usually have underscores. To find the new name, simply look up the old name in the documentation. So layout.reingold.tilford should be layout_with_fr to future-proof the code.

antagomir commented 1 year ago

Seems good to me at least but I would leave it to @hallucigenia-sparsa to decide on the merge.

If could you update version number to 0.1.2 in this PR that would be useful.

hallucigenia-sparsa commented 1 year ago

Thanks for the fix.