Re: [R] igraph_vertex

2024-02-26 Thread Ivan Krylov via R-help
В Mon, 26 Feb 2024 11:52:13 +0100
 пишет:

> TIFFOpen: figures/AES_network_bymembership.tiff: Cannot open.

> Warning message:
> In dev.off() :
>   unable to open TIFF file 'figures/AES_network_bymembership.tiff'

In the current directory (see getwd()), is there a subdirectory named
"figures"? Do you have write access to this subdirectory? Is there a
file named "AES_network_bymembership.tiff" in the subdirectory named
"figures"? Could it be open by a different program and therefore
locked?

Unfortunately, libtiff doesn't seem to provide any more information
regarding why it couldn't open the file at this point.

-- 
Best regards,
Ivan

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] igraph_vertex

2024-02-26 Thread SIBYLLE STÖCKLI via R-help
Dear Ivan

Thanks a lot.

I used:
windowsFonts(Helvetica = windowsFont("Helvetica"))
No warning now with Helvetica
Additionally I used "sans", similarly no warning  in the first part.

But still not able to open tiff with both versions:

Using "stress" as default layout
> dev.off()
TIFFOpen: figures/AES_network_bymembership.tiff: Cannot open.
RStudioGD 
2 
Warning message:
In dev.off() :
  unable to open TIFF file 'figures/AES_network_bymembership.tiff'

Kind regards
Sibylle

-Original Message-
From: Ivan Krylov  
Sent: Monday, February 26, 2024 10:15 AM
To: SIBYLLE STÖCKLI via R-help 
Cc: sibylle.stoec...@gmx.ch
Subject: Re: [R] igraph_vertex

В Mon, 26 Feb 2024 09:02:56 +0100
SIBYLLE STÖCKLI via R-help  пишет:

> In the following code, which loads the tiff file, I get the following 
> error

This warning is definitely worth investigating, but it shouldn't interrupt your 
code. Does the figure come out wrong after you see this warning?

> In doTryCatch(return(expr), name, parentenv, handler) : Character set 
> family not found in the Windows character set database
> 
> --> I am unsure if mySQL is the right solution. I have no experience
> how to change mySQL. 

I see you've tried to do the right thing and searched for the warning message. 
Unfortunately, the search engines are wrong; this doesn't seem related to MySQL.

A similarly-worded warning message exists in the Windows-related font functions 
inside R:

>> warning(_("font family not found in Windows font database"))

If running a sufficiently new version of R, try Sys.setLanguage('en') before 
reproducing the problem and searching for the exact warning message in double 
quotes. (Reset it back using
Sys.setLanguage(your_language_code) or restart R afterwards.) Translated error 
and warning messages are good for understanding, but they fragment the search 
engine results.

I see that a few messages back you set a font family:

>  vertex.label.family="Helvetica",

R probably doesn't know where to get it in order to render the plot as TIFF. If 
you have a copy of Helvetica installed in your system, try registering it using 
windowsFonts(Helvetica = windowsFont("how the font is named in the system")). 
(See help(windowsFonts) for more
information.) Otherwise you may be limited to R's predefined font families.

It's annoying that "Helvetica" exists for PDF plots and such seemingly without 
a problem, but if you change the output format to TIFF, the set of fonts 
available to you changes too. Unfortunately, there are multiple different font 
rendering engines in play, and their predefined lists of fonts also differ.

--
Best regards,
Ivan

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] igraph_vertex

2024-02-26 Thread Ivan Krylov via R-help
В Mon, 26 Feb 2024 09:02:56 +0100
SIBYLLE STÖCKLI via R-help  пишет:

> In the following code, which loads the tiff file, I get the following
> error

This warning is definitely worth investigating, but it shouldn't
interrupt your code. Does the figure come out wrong after you see this
warning?

> In doTryCatch(return(expr), name, parentenv, handler) : Character set
> family not found in the Windows character set database
> 
> --> I am unsure if mySQL is the right solution. I have no experience
> how to change mySQL. 

I see you've tried to do the right thing and searched for the warning
message. Unfortunately, the search engines are wrong; this doesn't seem
related to MySQL.

A similarly-worded warning message exists in the Windows-related font
functions inside R:

>> warning(_("font family not found in Windows font database"))

If running a sufficiently new version of R, try Sys.setLanguage('en')
before reproducing the problem and searching for the exact warning
message in double quotes. (Reset it back using
Sys.setLanguage(your_language_code) or restart R afterwards.)
Translated error and warning messages are good for understanding, but
they fragment the search engine results.

I see that a few messages back you set a font family:

>  vertex.label.family="Helvetica",

R probably doesn't know where to get it in order to render the plot as
TIFF. If you have a copy of Helvetica installed in your system, try
registering it using windowsFonts(Helvetica = windowsFont("how the
font is named in the system")). (See help(windowsFonts) for more
information.) Otherwise you may be limited to R's predefined font
families.

It's annoying that "Helvetica" exists for PDF plots and such seemingly
without a problem, but if you change the output format to TIFF, the set
of fonts available to you changes too. Unfortunately, there are
multiple different font rendering engines in play, and their predefined
lists of fonts also differ.

-- 
Best regards,
Ivan

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] igraph_vertex

2024-02-26 Thread SIBYLLE STÖCKLI via R-help
Dear Kimmo

First of all many thanks for the valuable advice to publish code and csv. 
Noted. 
Yes, "edge.width= E(.)$weight" makes definitively sense.

In the following code, which loads the tiff file, I get the following error
tiff("figures/AES_network_bymembership.tiff", width=1000, height=700, res=120)
Warning message:
In doTryCatch(return(expr), name, parentenv, handler) : Character set family 
not found in the Windows character set database

--> I am unsure if mySQL is the right solution. I have no experience how to 
change mySQL.

Kind regards
Sibylle


tiff("figures/AES_network_bymembership.tiff", width=1000, height=700, res=120)
network %>%
  ggraph(., layout = "auto")+
  geom_edge_arc(curvature=0.3, aes(width=(E(network)$weight/10), color=from, 
alpha=0.5)) +
  geom_node_point(aes(size = V(network)$hub_score*200, color= 
as.factor(V(network)$community))) +
  geom_node_text(aes(label =  V(network)$name), size=5, color="white", repel=T)+
  scale_color_scico_d(palette = "batlow")+
  scale_edge_width(range = c(0.2,4))+
  scale_size(range = c(0.5,20)) +
  #scale_edge_color_manual(values = c(scico(21, palette="batlow")))+
  theme(plot.background = element_rect(fill = "black"),
legend.position = "right",
panel.background = element_rect(fill = "black"))
dev.off()





-Original Message-

From: R-help  On Behalf Of Kimmo Elo
Sent: Monday, February 26, 2024 8:10 AM
To: r-help@r-project.org
Subject: Re: [R] igraph_vertex


Hi,

a quick additional note: try

"edge.width= E(.)$weight"

instead of the current "edge.width= network". Seems to work and makes a visible 
difference...

HTH,
Kimmo

su, 2024-02-25 kello 19:11 +, Kimmo Elo kirjoitti:
> 
> Hi again,
> 
> your code is still not reproducible without modifications, but I 
> succeed in getting the data straight. All read.csv-command are missing 
> 'sep="\t"', it is need to read you tsv-data.
> 
> And it could be more reproducible if you used e.g.
> 
> --- snip ---
> aes<-read.csv(text="A.A B.B C.C D.D E.E F.F 
> A.A 0   0   5   5   5   5 B.B 4   0   
> 1   1   1   1 C.C 5   5   0   5   4   
> 2 D.D 5   0   5   0   5   3 E.E 5   1   
> 5   5   0   4 F.F 1   2   3   4   5   
> 5", sep="\t", row.names = 1)
> --- snip ---
> 
> This would save us from unnecessary copy-pasting :-)
> 
> However, the error is still the same I mentioned in my first reply,
> i.e.:
> 
> network %>% plot(
> vertex.color=clrs[V(.)$community],
> vertex.size=V(.)$hub_score*5,
> vertex.frame.color=V(.)$color,
> vertex.label.color="white",
> vertex.label.cex=0.5,
> vertex.label.family="Helvetica",
> vertex.label.font=1,
> edge.curved=0.5,
> HERE -->edge.width= network,  <-- HERE
> layout=layout_with_mds(.))
> 
> Try to comment out his line and see what happens. What network data 
> variable should be mapped to edge width?
> 
> Best,
> Kimmo
> 
> su, 2024-02-25 kello 09:59 +0100, sibylle.stoec...@gmx.ch kirjoitti:
> > Dear coummunity
> > 
> > Thanks a lot to David and Kimmo. Yes I see now that I need to 
> > provide the two raw tables. Find here the reproducible example.
> > 
> > Kind regards
> > Sibylle
> > 
> > # R-labraries
> > library(circlize)
> > library(ggplot2)
> > library(igraph)
> > library(tidyverse)
> > library(RColorBrewer)
> > library(stringi)
> > library(scico)
> > library(plotly)
> > library(ggraph)
> > 
> > 
> > # Tables
> > aes<-read.csv("Test_adjac.csv", row.names = 1)
> > details<-read.csv("Test_cat.csv")
> > 
> > # Edge table, reorganisation
> > aes_collapsed<-aes %>%
> >   rownames_to_column(var='Names') %>%
> >   tidyr::gather(target, weight, 1:ncol(aes)+1) %>%
> >   dplyr::filter(weight != 0) %>%
> >   mutate(weight = ifelse(weight == "-1", 0, weight)) # here 0 = 
> > negative values
> > 
> > write.csv(aes_collapsed, "edges_table_Test.csv", row.names = F)
> > edge_list<-read.csv("edges_table_Test.csv")
> > 
> > # Network attributes
> > network <- graph_from_data_frame(aes_collapsed, directed= FALSE,
> >  vertices = details)
> > 
> > 
> > temp<-cluster_optimal(network)
> > temp<-cbind(membership=temp$membership, Names=temp$name) 
> > aes_collapsed <- aes

Re: [R] igraph_vertex

2024-02-25 Thread Kimmo Elo

Hi,

a quick additional note: try

"edge.width= E(.)$weight"

instead of the current "edge.width= network". Seems to work and makes a
visible difference...

HTH,
Kimmo

su, 2024-02-25 kello 19:11 +, Kimmo Elo kirjoitti:
> 
> Hi again,
> 
> your code is still not reproducible without modifications, but I
> succeed in getting the data straight. All read.csv-command are
> missing
> 'sep="\t"', it is need to read you tsv-data.
> 
> And it could be more reproducible if you used e.g.
> 
> --- snip ---
> aes<-read.csv(text="    A.A B.B C.C D.D E.E F.F
> A.A 0   0   5   5   5   5
> B.B 4   0   1   1   1   1
> C.C 5   5   0   5   4   2
> D.D 5   0   5   0   5   3
> E.E 5   1   5   5   0   4
> F.F 1   2   3   4   5   5", 
> sep="\t", row.names = 1)
> --- snip ---
> 
> This would save us from unnecessary copy-pasting :-)
> 
> However, the error is still the same I mentioned in my first reply,
> i.e.:
> 
> network %>% plot(
>     vertex.color=clrs[V(.)$community], 
>     vertex.size=V(.)$hub_score*5, 
>     vertex.frame.color=V(.)$color, 
>     vertex.label.color="white", 
>     vertex.label.cex=0.5, 
>     vertex.label.family="Helvetica",
>     vertex.label.font=1,
>     edge.curved=0.5,
> HERE -->    edge.width= network,  <-- HERE
>     layout=layout_with_mds(.))
> 
> Try to comment out his line and see what happens. What network data
> variable should be mapped to edge width?
> 
> Best,
> Kimmo
> 
> su, 2024-02-25 kello 09:59 +0100, sibylle.stoec...@gmx.ch kirjoitti:
> > Dear coummunity
> > 
> > Thanks a lot to David and Kimmo. Yes I see now that I need to
> > provide
> > the two raw tables. Find here the reproducible example.
> > 
> > Kind regards
> > Sibylle
> > 
> > # R-labraries
> > library(circlize)
> > library(ggplot2)
> > library(igraph)
> > library(tidyverse)
> > library(RColorBrewer)
> > library(stringi)
> > library(scico)
> > library(plotly)
> > library(ggraph)
> > 
> > 
> > # Tables
> > aes<-read.csv("Test_adjac.csv", row.names = 1)
> > details<-read.csv("Test_cat.csv")
> > 
> > # Edge table, reorganisation
> > aes_collapsed<-aes %>%
> >   rownames_to_column(var='Names') %>%
> >   tidyr::gather(target, weight, 1:ncol(aes)+1) %>%
> >   dplyr::filter(weight != 0) %>%
> >   mutate(weight = ifelse(weight == "-1", 0, weight)) # here 0 =
> > negative values
> > 
> > write.csv(aes_collapsed, "edges_table_Test.csv", row.names = F)
> > edge_list<-read.csv("edges_table_Test.csv")
> > 
> > # Network attributes
> > network <- graph_from_data_frame(aes_collapsed, directed= FALSE, 
> >  vertices = details)
> > 
> > 
> > temp<-cluster_optimal(network)
> > temp<-cbind(membership=temp$membership, Names=temp$name)
> > aes_collapsed <- aes_collapsed %>%
> >   merge(temp, by="Names")
> > 
> > 
> > network <- network %>%
> >   set_edge_attr(name = "type", value = factor(aes_collapsed$Names, 
> >  ordered =
> > is.ordered(V(network)$name))) %>%
> >   set_edge_attr(name = "membership", value =
> > aes_collapsed$membership) %>%
> >   set_edge_attr(name = "color", 
> >   value = c(viridis::viridis(5))
> >   [match(E(.)$type, c(factor(V(.)$name)))]) %>%
> >   set_vertex_attr(name = "trans_v_net", value = c(transitivity(.,
> > type = "local"))) %>%
> >   set_vertex_attr(name = "hub_score", value =
> > c(hub_score(.)$vector))
> > %>%
> >   set_vertex_attr(name = "color", 
> >   value = c(viridis::viridis((5)))
> >   [match(V(.)$name, c(factor(V(.)$name)))]) %>%
> >   set_vertex_attr(name= "community",
> > value=cluster_optimal(.)$membership)
> > 
> > clrs<-scico(3, palette = "batlow")
> > 
> > par(bg="black")
> > network %>% plot(
> >  vertex.color=clrs[V(.)$community], 
> >  vertex.size=V(.)$hub_score*5, 
> >  vertex.frame.color=V(.)$color, 
> >  vertex.label.color="white", 
> >  vertex.label.cex=0.5, 
> >  vertex.label.family="Helvetica",
> >  vertex.label.font=1,
> >  edge.curved=0.5,
> >  edge.width= network,
> >  layout=layout_with_mds(.))
> > 
> > #error
> > Error in intI(i, n = x@Dim[1], dn[[1]], give.dn = FALSE) : 
> >   Index größer als maximales 6
> > 
> > # Test_adjac.csv
> > A.A B.B C.C D.D E.E F.F
> > A.A 0   0   5   5   5   5
> > B.B 4   0   1   1   1   1
> > C.C 5   5   0   5   4   2
> > D.D 5   0   5   0   5   3
> > E.E 5   1   5   5   0   4
> > F.F 1   2   3   4   5   5
> > 
> > # Test_cat.csv
> > Names   corresponding-
> > NCP   CategorySubcategory_typesources.cytos
> > ou
> > rce  Factor
> > A.A 7   hydrologic attribute"A" A   1
> > B.B 6, 11   hydrologic 

Re: [R] igraph_vertex

2024-02-25 Thread Kimmo Elo

Hi again,

your code is still not reproducible without modifications, but I
succeed in getting the data straight. All read.csv-command are missing
'sep="\t"', it is need to read you tsv-data.

And it could be more reproducible if you used e.g.

--- snip ---
aes<-read.csv(text="A.A B.B C.C D.D E.E F.F
A.A 0   0   5   5   5   5
B.B 4   0   1   1   1   1
C.C 5   5   0   5   4   2
D.D 5   0   5   0   5   3
E.E 5   1   5   5   0   4
F.F 1   2   3   4   5   5", 
sep="\t", row.names = 1)
--- snip ---

This would save us from unnecessary copy-pasting :-)

However, the error is still the same I mentioned in my first reply,
i.e.:

network %>% plot(
vertex.color=clrs[V(.)$community], 
vertex.size=V(.)$hub_score*5, 
vertex.frame.color=V(.)$color, 
vertex.label.color="white", 
vertex.label.cex=0.5, 
vertex.label.family="Helvetica",
vertex.label.font=1,
edge.curved=0.5,
HERE -->edge.width= network,  <-- HERE
layout=layout_with_mds(.))

Try to comment out his line and see what happens. What network data
variable should be mapped to edge width?

Best,
Kimmo

su, 2024-02-25 kello 09:59 +0100, sibylle.stoec...@gmx.ch kirjoitti:
> Dear coummunity
> 
> Thanks a lot to David and Kimmo. Yes I see now that I need to provide
> the two raw tables. Find here the reproducible example.
> 
> Kind regards
> Sibylle
> 
> # R-labraries
> library(circlize)
> library(ggplot2)
> library(igraph)
> library(tidyverse)
> library(RColorBrewer)
> library(stringi)
> library(scico)
> library(plotly)
> library(ggraph)
> 
> 
> # Tables
> aes<-read.csv("Test_adjac.csv", row.names = 1)
> details<-read.csv("Test_cat.csv")
> 
> # Edge table, reorganisation
> aes_collapsed<-aes %>%
>   rownames_to_column(var='Names') %>%
>   tidyr::gather(target, weight, 1:ncol(aes)+1) %>%
>   dplyr::filter(weight != 0) %>%
>   mutate(weight = ifelse(weight == "-1", 0, weight)) # here 0 =
> negative values
> 
> write.csv(aes_collapsed, "edges_table_Test.csv", row.names = F)
> edge_list<-read.csv("edges_table_Test.csv")
> 
> # Network attributes
> network <- graph_from_data_frame(aes_collapsed, directed= FALSE, 
>  vertices = details)
> 
> 
> temp<-cluster_optimal(network)
> temp<-cbind(membership=temp$membership, Names=temp$name)
> aes_collapsed <- aes_collapsed %>%
>   merge(temp, by="Names")
> 
> 
> network <- network %>%
>   set_edge_attr(name = "type", value = factor(aes_collapsed$Names, 
>  ordered =
> is.ordered(V(network)$name))) %>%
>   set_edge_attr(name = "membership", value =
> aes_collapsed$membership) %>%
>   set_edge_attr(name = "color", 
>   value = c(viridis::viridis(5))
>   [match(E(.)$type, c(factor(V(.)$name)))]) %>%
>   set_vertex_attr(name = "trans_v_net", value = c(transitivity(.,
> type = "local"))) %>%
>   set_vertex_attr(name = "hub_score", value = c(hub_score(.)$vector))
> %>%
>   set_vertex_attr(name = "color", 
>   value = c(viridis::viridis((5)))
>   [match(V(.)$name, c(factor(V(.)$name)))]) %>%
>   set_vertex_attr(name= "community",
> value=cluster_optimal(.)$membership)
> 
> clrs<-scico(3, palette = "batlow")
> 
> par(bg="black")
> network %>% plot(
>  vertex.color=clrs[V(.)$community], 
>  vertex.size=V(.)$hub_score*5, 
>  vertex.frame.color=V(.)$color, 
>  vertex.label.color="white", 
>  vertex.label.cex=0.5, 
>  vertex.label.family="Helvetica",
>  vertex.label.font=1,
>  edge.curved=0.5,
>  edge.width= network,
>  layout=layout_with_mds(.))
> 
> #error
> Error in intI(i, n = x@Dim[1], dn[[1]], give.dn = FALSE) : 
>   Index größer als maximales 6
> 
> # Test_adjac.csv
> A.A B.B C.C D.D E.E F.F
> A.A 0   0   5   5   5   5
> B.B 4   0   1   1   1   1
> C.C 5   5   0   5   4   2
> D.D 5   0   5   0   5   3
> E.E 5   1   5   5   0   4
> F.F 1   2   3   4   5   5
> 
> # Test_cat.csv
> Names   corresponding-
> NCP   CategorySubcategory_typesources.cytosou
> rce  Factor
> A.A 7   hydrologic attribute"A" A   1
> B.B 6, 11   hydrologic attribute"B" B   1
> C.C 1, 14, 15, 16, 17,
> 18   AES intrinsic   "C" C   0
> D.D 1, 14, 15, 16, 17,
> 18   AES intrinsic   "D" D   0
> E.E 1, 14, 15, 16, 17,
> 18   AES intrinsic   "E" E   0
> F.F 7   AES material"F" F   0
> 
> 
> # edges_tables_Test.csv
> Names   target  weight
> B.B A.A 4
> C.C A.A 5
> D.D A.A 5
> E.E A.A 5
> F.F A.A 1
> C.C B.B 5
> E.E B.B 

Re: [R] igraph_vertex

2024-02-25 Thread SIBYLLE STÖCKLI via R-help
Dear coummunity

Thanks a lot to David and Kimmo. Yes I see now that I need to provide the two 
raw tables. Find here the reproducible example.

Kind regards
Sibylle

# R-labraries
library(circlize)
library(ggplot2)
library(igraph)
library(tidyverse)
library(RColorBrewer)
library(stringi)
library(scico)
library(plotly)
library(ggraph)


# Tables
aes<-read.csv("Test_adjac.csv", row.names = 1)
details<-read.csv("Test_cat.csv")

# Edge table, reorganisation
aes_collapsed<-aes %>%
  rownames_to_column(var='Names') %>%
  tidyr::gather(target, weight, 1:ncol(aes)+1) %>%
  dplyr::filter(weight != 0) %>%
  mutate(weight = ifelse(weight == "-1", 0, weight)) # here 0 = negative values

write.csv(aes_collapsed, "edges_table_Test.csv", row.names = F)
edge_list<-read.csv("edges_table_Test.csv")

# Network attributes
network <- graph_from_data_frame(aes_collapsed, directed= FALSE, 
 vertices = details)


temp<-cluster_optimal(network)
temp<-cbind(membership=temp$membership, Names=temp$name)
aes_collapsed <- aes_collapsed %>%
  merge(temp, by="Names")


network <- network %>%
  set_edge_attr(name = "type", value = factor(aes_collapsed$Names, 
 ordered = 
is.ordered(V(network)$name))) %>%
  set_edge_attr(name = "membership", value = aes_collapsed$membership) %>%
  set_edge_attr(name = "color", 
  value = c(viridis::viridis(5))
  [match(E(.)$type, c(factor(V(.)$name)))]) %>%
  set_vertex_attr(name = "trans_v_net", value = c(transitivity(., type = 
"local"))) %>%
  set_vertex_attr(name = "hub_score", value = c(hub_score(.)$vector)) %>%
  set_vertex_attr(name = "color", 
  value = c(viridis::viridis((5)))
  [match(V(.)$name, c(factor(V(.)$name)))]) %>%
  set_vertex_attr(name= "community", value=cluster_optimal(.)$membership)

clrs<-scico(3, palette = "batlow")

par(bg="black")
network %>% plot(
 vertex.color=clrs[V(.)$community], 
 vertex.size=V(.)$hub_score*5, 
 vertex.frame.color=V(.)$color, 
 vertex.label.color="white", 
 vertex.label.cex=0.5, 
 vertex.label.family="Helvetica",
 vertex.label.font=1,
 edge.curved=0.5,
 edge.width= network,
 layout=layout_with_mds(.))

#error
Error in intI(i, n = x@Dim[1], dn[[1]], give.dn = FALSE) : 
  Index größer als maximales 6

# Test_adjac.csv
A.A B.B C.C D.D E.E F.F
A.A 0   0   5   5   5   5
B.B 4   0   1   1   1   1
C.C 5   5   0   5   4   2
D.D 5   0   5   0   5   3
E.E 5   1   5   5   0   4
F.F 1   2   3   4   5   5

# Test_cat.csv
Names   corresponding-NCP   CategorySubcategory_type
sources.cytosource  Factor
A.A 7   hydrologic attribute"A" A   1
B.B 6, 11   hydrologic attribute"B" B   1
C.C 1, 14, 15, 16, 17, 18   AES intrinsic   "C" C   0
D.D 1, 14, 15, 16, 17, 18   AES intrinsic   "D" D   0
E.E 1, 14, 15, 16, 17, 18   AES intrinsic   "E" E   0
F.F 7   AES material"F" F   0


# edges_tables_Test.csv
Names   target  weight
B.B A.A 4
C.C A.A 5
D.D A.A 5
E.E A.A 5
F.F A.A 1
C.C B.B 5
E.E B.B 1
F.F B.B 2
A.A C.C 5
B.B C.C 1
D.D C.C 5
E.E C.C 5
F.F C.C 3
A.A D.D 5
B.B D.D 1
C.C D.D 5
E.E D.D 5
F.F D.D 4
A.A E.E 5
B.B E.E 1
C.C E.E 4
D.D E.E 5
F.F E.E 5
A.A F.F 5
B.B F.F 1
C.C F.F 2
D.D F.F 3
E.E F.F 4
F.F F.F 5

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] igraph_vertex

2024-02-24 Thread David Winsemius



On 2/24/24 12:10, Kimmo Elo wrote:

Hi,

first of all, your example was not reproducible! But once I added
"library(igraph)" and "library(scico)" plus generally replaced
"aes_collapsed" by "edge_list", I started to work :-)



After copying your lead in that replacement the error I got was:


network <- graph_from_data_frame(edge_list, directed= FALSE, + vertices 
= details) #Error: object 'details' not found Same conclusion, though. 
Incomplete presentation of code. -- David.




Anyway, the error is produced by this line:

+ edge.width= network,

It seems to me that you have forgotten to name a variable here (you now
use the whole network object as variable, which most probably won't
work).

Just as a kind advice for the future: if you encounter errors like
this, it is always a good idea to debug the problematic code by
commenting it out line by line. So you will - most probably - find our
those sections resulting in errors.

HTH,

Kimmo

la, 2024-02-24 kello 12:09 +0100, SIBYLLE STÖCKLI via R-help kirjoitti:

Dear R-community

  


It would be nice to get some input how to find a solution for the
following
error in igraph and vertex setting.

  


Thank you very much

Sibylle

  


par(bg="black")
network %>% plot(

+ vertex.color=clrs[V(.)$community],

+ vertex.size=V(.)$hub_score*1,

+ vertex.frame.color=V(.)$color,

+ vertex.label.color="white",

+ vertex.label.cex=0.5,

+ vertex.label.family="Helvetica",

+ vertex.label.font=1,

+ edge.curved=0.5,

+ edge.width= network,

+ layout=layout_with_mds(.))

Error in intI(i, n = x@Dim[1], dn[[1]], give.dn = FALSE) :

   Index gr��er als maximales 6

  

  


Reproducible example:

  


edge_list<-read.csv("edges_table_Test.csv")

  


#create network and add some necessary attributes (vertices) for the
plot

network <- graph_from_data_frame(aes_collapsed, directed= FALSE,

  vertices = details)

  

  


temp<-cluster_optimal(network)

temp<-cbind(membership=temp$membership, Names=temp$name)

aes_collapsed <- aes_collapsed %>%

   merge(temp, by="Names")

  

  


network <- network %>%

   set_edge_attr(name = "type", value = factor(aes_collapsed$Names,

  ordered =
is.ordered(V(network)$name))) %>%

   set_edge_attr(name = "membership", value =
aes_collapsed$membership) %>%

   set_edge_attr(name = "color",

   value = c(viridis::viridis(5))

   [match(E(.)$type, c(factor(V(.)$name)))]) %>%

   set_vertex_attr(name = "trans_v_net", value = c(transitivity(.,
type =
"local"))) %>%

   set_vertex_attr(name = "hub_score", value = c(hub_score(.)$vector))
%>%

   set_vertex_attr(name = "color",

   value = c(viridis::viridis((5)))

   [match(V(.)$name, c(factor(V(.)$name)))]) %>%

   set_vertex_attr(name= "community",
value=cluster_optimal(.)$membership)

  


clrs<-scico(3, palette = "batlow")

  


par(bg="black")

network %>% plot(

  vertex.color=clrs[V(.)$community],

  vertex.size=V(.)$hub_score*5,

  vertex.frame.color=V(.)$color,

  vertex.label.color="white",

  vertex.label.cex=0.5,

  vertex.label.family="Helvetica",

  vertex.label.font=1,

  edge.curved=0.5,

  edge.width= network,

  layout=layout_with_mds(.))

  

  


edges_table_Test.csv

  



Names

target

weight


B.B

A.A

4


C.C

A.A

5


D.D

A.A

5


E.E

A.A

5


F.F

A.A

1


C.C

B.B

5


E.E

B.B

1


F.F

B.B

2


A.A

C.C

5


B.B

C.C

1


D.D

C.C

5


E.E

C.C

5


F.F

C.C

3


A.A

D.D

5


B.B

D.D

1


C.C

D.D

5


E.E

D.D

5


F.F

D.D

4


A.A

E.E

5


B.B

E.E

1


C.C

E.E

4


D.D

E.E

5


F.F

E.E

5


A.A

F.F

5


B.B

F.F

1


C.C

F.F

2


D.D

F.F

3


E.E

F.F

4


F.F

F.F

5

  



 [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] igraph_vertex

2024-02-24 Thread Kimmo Elo

Hi,

first of all, your example was not reproducible! But once I added
"library(igraph)" and "library(scico)" plus generally replaced
"aes_collapsed" by "edge_list", I started to work :-)

Anyway, the error is produced by this line:

+ edge.width= network,

It seems to me that you have forgotten to name a variable here (you now
use the whole network object as variable, which most probably won't
work).

Just as a kind advice for the future: if you encounter errors like
this, it is always a good idea to debug the problematic code by
commenting it out line by line. So you will - most probably - find our
those sections resulting in errors.

HTH,

Kimmo

la, 2024-02-24 kello 12:09 +0100, SIBYLLE STÖCKLI via R-help kirjoitti:
> Dear R-community
> 
>  
> 
> It would be nice to get some input how to find a solution for the
> following
> error in igraph and vertex setting.
> 
>  
> 
> Thank you very much
> 
> Sibylle
> 
>  
> 
> > par(bg="black")
> 
> > network %>% plot(
> 
> + vertex.color=clrs[V(.)$community], 
> 
> + vertex.size=V(.)$hub_score*1, 
> 
> + vertex.frame.color=V(.)$color, 
> 
> + vertex.label.color="white", 
> 
> + vertex.label.cex=0.5, 
> 
> + vertex.label.family="Helvetica",
> 
> + vertex.label.font=1,
> 
> + edge.curved=0.5,
> 
> + edge.width= network,
> 
> + layout=layout_with_mds(.))
> 
> Error in intI(i, n = x@Dim[1], dn[[1]], give.dn = FALSE) : 
> 
>   Index gr��er als maximales 6
> 
>  
> 
>  
> 
> Reproducible example:
> 
>  
> 
> edge_list<-read.csv("edges_table_Test.csv")
> 
>  
> 
> #create network and add some necessary attributes (vertices) for the
> plot
> 
> network <- graph_from_data_frame(aes_collapsed, directed= FALSE, 
> 
>  vertices = details)
> 
>  
> 
>  
> 
> temp<-cluster_optimal(network)
> 
> temp<-cbind(membership=temp$membership, Names=temp$name)
> 
> aes_collapsed <- aes_collapsed %>%
> 
>   merge(temp, by="Names")
> 
>  
> 
>  
> 
> network <- network %>%
> 
>   set_edge_attr(name = "type", value = factor(aes_collapsed$Names, 
> 
>  ordered =
> is.ordered(V(network)$name))) %>%
> 
>   set_edge_attr(name = "membership", value =
> aes_collapsed$membership) %>%
> 
>   set_edge_attr(name = "color", 
> 
>   value = c(viridis::viridis(5))
> 
>   [match(E(.)$type, c(factor(V(.)$name)))]) %>%
> 
>   set_vertex_attr(name = "trans_v_net", value = c(transitivity(.,
> type =
> "local"))) %>%
> 
>   set_vertex_attr(name = "hub_score", value = c(hub_score(.)$vector))
> %>%
> 
>   set_vertex_attr(name = "color", 
> 
>   value = c(viridis::viridis((5)))
> 
>   [match(V(.)$name, c(factor(V(.)$name)))]) %>%
> 
>   set_vertex_attr(name= "community",
> value=cluster_optimal(.)$membership)
> 
>  
> 
> clrs<-scico(3, palette = "batlow")
> 
>  
> 
> par(bg="black")
> 
> network %>% plot(
> 
>  vertex.color=clrs[V(.)$community], 
> 
>  vertex.size=V(.)$hub_score*5, 
> 
>  vertex.frame.color=V(.)$color, 
> 
>  vertex.label.color="white", 
> 
>  vertex.label.cex=0.5, 
> 
>  vertex.label.family="Helvetica",
> 
>  vertex.label.font=1,
> 
>  edge.curved=0.5,
> 
>  edge.width= network,
> 
>  layout=layout_with_mds(.))
> 
>  
> 
>  
> 
> edges_table_Test.csv
> 
>  
> 
> 
> Names
> 
> target
> 
> weight
> 
> 
> B.B
> 
> A.A
> 
> 4
> 
> 
> C.C
> 
> A.A
> 
> 5
> 
> 
> D.D
> 
> A.A
> 
> 5
> 
> 
> E.E
> 
> A.A
> 
> 5
> 
> 
> F.F
> 
> A.A
> 
> 1
> 
> 
> C.C
> 
> B.B
> 
> 5
> 
> 
> E.E
> 
> B.B
> 
> 1
> 
> 
> F.F
> 
> B.B
> 
> 2
> 
> 
> A.A
> 
> C.C
> 
> 5
> 
> 
> B.B
> 
> C.C
> 
> 1
> 
> 
> D.D
> 
> C.C
> 
> 5
> 
> 
> E.E
> 
> C.C
> 
> 5
> 
> 
> F.F
> 
> C.C
> 
> 3
> 
> 
> A.A
> 
> D.D
> 
> 5
> 
> 
> B.B
> 
> D.D
> 
> 1
> 
> 
> C.C
> 
> D.D
> 
> 5
> 
> 
> E.E
> 
> D.D
> 
> 5
> 
> 
> F.F
> 
> D.D
> 
> 4
> 
> 
> A.A
> 
> E.E
> 
> 5
> 
> 
> B.B
> 
> E.E
> 
> 1
> 
> 
> C.C
> 
> E.E
> 
> 4
> 
> 
> D.D
> 
> E.E
> 
> 5
> 
> 
> F.F
> 
> E.E
> 
> 5
> 
> 
> A.A
> 
> F.F
> 
> 5
> 
> 
> B.B
> 
> F.F
> 
> 1
> 
> 
> C.C
> 
> F.F
> 
> 2
> 
> 
> D.D
> 
> F.F
> 
> 3
> 
> 
> E.E
> 
> F.F
> 
> 4
> 
> 
> F.F
> 
> F.F
> 
> 5
> 
>  
> 
> 
> [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] igraph_vertex

2024-02-24 Thread SIBYLLE STÖCKLI via R-help
Dear R-community

It would be nice to get some input how to find a solution for the following 
error in igraph and vertex setting.

Error in intI(i, n = x@Dim[1], dn[[1]], give.dn = FALSE) : 
  Index größer als maximales 6

Kind regards
Sibylle 

Working example

library(circlize)
library(ggplot2)
library(igraph)
library(tidyverse)
library(RColorBrewer)
library(stringi)
library(scico)
library(plotly)
library(ggraph)

edges_table_Test.csv

Names   target  weight
B.B A.A 4
C.C A.A 5
D.D A.A 5
E.E A.A 5
F.F A.A 1
C.C B.B 5
E.E B.B 1
F.F B.B 2
A.A C.C 5
B.B C.C 1
D.D C.C 5
E.E C.C 5
F.F C.C 3
A.A D.D 5
B.B D.D 1
C.C D.D 5
E.E D.D 5
F.F D.D 4
A.A E.E 5
B.B E.E 1
C.C E.E 4
D.D E.E 5
F.F E.E 5
A.A F.F 5
B.B F.F 1
C.C F.F 2
D.D F.F 3
E.E F.F 4
F.F F.F 5

edge_list<-read.csv("edges_table_Test.csv")

network <- graph_from_data_frame(aes_collapsed, directed= FALSE, 
 vertices = details)


temp<-cluster_optimal(network)
temp<-cbind(membership=temp$membership, Names=temp$name)
aes_collapsed <- aes_collapsed %>%
  merge(temp, by="Names")


network <- network %>%
  set_edge_attr(name = "type", value = factor(aes_collapsed$Names, 
 ordered = 
is.ordered(V(network)$name))) %>%
  set_edge_attr(name = "membership", value = aes_collapsed$membership) %>%
  set_edge_attr(name = "color", 
  value = c(viridis::viridis(5))
  [match(E(.)$type, c(factor(V(.)$name)))]) %>%
  set_vertex_attr(name = "trans_v_net", value = c(transitivity(., type = 
"local"))) %>%
  set_vertex_attr(name = "hub_score", value = c(hub_score(.)$vector)) %>%
  set_vertex_attr(name = "color", 
  value = c(viridis::viridis((5)))
  [match(V(.)$name, c(factor(V(.)$name)))]) %>%
  set_vertex_attr(name= "community", value=cluster_optimal(.)$membership)

clrs<-scico(3, palette = "batlow")

par(bg="black")
network %>% plot(
 vertex.color=clrs[V(.)$community], 
 vertex.size=V(.)$hub_score*5, 
 vertex.frame.color=V(.)$color, 
 vertex.label.color="white", 
 vertex.label.cex=0.5, 
 vertex.label.family="Helvetica",
 vertex.label.font=1,
 edge.curved=0.5,
 edge.width= network,
 layout=layout_with_mds(.))

Error in intI(i, n = x@Dim[1], dn[[1]], give.dn = FALSE) : 
  Index größer als maximales 6


tiff("figures/AES_network_bymembership.tiff", width=1000, height=700, res=120)
network %>%
  ggraph(., layout = "auto")+
  geom_edge_arc(curvature=0.3, aes(width=(E(network)$weight/10), color=from, 
alpha=0.5)) +
  geom_node_point(aes(size = V(network)$hub_score*200, color= 
as.factor(V(network)$community))) +
  geom_node_text(aes(label =  V(network)$name), size=5, color="white", repel=T)+
  scale_color_scico_d(palette = "batlow")+
  scale_edge_width(range = c(0.2,4))+
  scale_size(range = c(0.5,20)) +
  #scale_edge_color_manual(values = c(scico(21, palette="batlow")))+
  theme(plot.background = element_rect(fill = "black"),
legend.position = "right",
panel.background = element_rect(fill = "black"))
dev.off()

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] igraph_vertex

2024-02-24 Thread David Winsemius
The reason html is specifically advised against as a format is that it 
does things like mangling data such as is happening in your example. You 
should repost using settings on you mail client for plain-text. Your 
code should start by loading necessary packages. You should also not 
post screen output versions of code since that will insert lots of 
superfluous "+"'s. Some but not all API will be able to strip those 
characters.



--

David.

On 2/24/24 03:09, SIBYLLE STÖCKLI via R-help wrote:

Dear R-community

  


It would be nice to get some input how to find a solution for the following
error in igraph and vertex setting.

  


Thank you very much

Sibylle


par(bg="black")
network %>% plot(

+ vertex.color=clrs[V(.)$community],

+ vertex.size=V(.)$hub_score*1,

+ vertex.frame.color=V(.)$color,

+ vertex.label.color="white",

+ vertex.label.cex=0.5,

+ vertex.label.family="Helvetica",

+ vertex.label.font=1,

+ edge.curved=0.5,

+ edge.width= network,

+ layout=layout_with_mds(.))

Error in intI(i, n = x@Dim[1], dn[[1]], give.dn = FALSE) :

   Index gr��er als maximales 6

  

  


Reproducible example:

  


edge_list<-read.csv("edges_table_Test.csv")

  


#create network and add some necessary attributes (vertices) for the plot

network <- graph_from_data_frame(aes_collapsed, directed= FALSE,

  vertices = details)

  

  


temp<-cluster_optimal(network)

temp<-cbind(membership=temp$membership, Names=temp$name)

aes_collapsed <- aes_collapsed %>%

   merge(temp, by="Names")

  

  


network <- network %>%

   set_edge_attr(name = "type", value = factor(aes_collapsed$Names,

  ordered =
is.ordered(V(network)$name))) %>%

   set_edge_attr(name = "membership", value = aes_collapsed$membership) %>%

   set_edge_attr(name = "color",

   value = c(viridis::viridis(5))

   [match(E(.)$type, c(factor(V(.)$name)))]) %>%

   set_vertex_attr(name = "trans_v_net", value = c(transitivity(., type =
"local"))) %>%

   set_vertex_attr(name = "hub_score", value = c(hub_score(.)$vector)) %>%

   set_vertex_attr(name = "color",

   value = c(viridis::viridis((5)))

   [match(V(.)$name, c(factor(V(.)$name)))]) %>%

   set_vertex_attr(name= "community", value=cluster_optimal(.)$membership)

  


clrs<-scico(3, palette = "batlow")

  


par(bg="black")

network %>% plot(

  vertex.color=clrs[V(.)$community],

  vertex.size=V(.)$hub_score*5,

  vertex.frame.color=V(.)$color,

  vertex.label.color="white",

  vertex.label.cex=0.5,

  vertex.label.family="Helvetica",

  vertex.label.font=1,

  edge.curved=0.5,

  edge.width= network,

  layout=layout_with_mds(.))

  

  


edges_table_Test.csv

  



Names

target

weight


B.B

A.A

4


C.C

A.A

5


D.D

A.A

5


E.E

A.A

5


F.F

A.A

1


C.C

B.B

5


E.E

B.B

1


F.F

B.B

2


A.A

C.C

5


B.B

C.C

1


D.D

C.C

5


E.E

C.C

5


F.F

C.C

3


A.A

D.D

5


B.B

D.D

1


C.C

D.D

5


E.E

D.D

5


F.F

D.D

4


A.A

E.E

5


B.B

E.E

1


C.C

E.E

4


D.D

E.E

5


F.F

E.E

5


A.A

F.F

5


B.B

F.F

1


C.C

F.F

2


D.D

F.F

3


E.E

F.F

4


F.F

F.F

5

  



[[alternative HTML version deleted]]


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] igraph_vertex

2024-02-24 Thread SIBYLLE STÖCKLI via R-help
Dear R-community

 

It would be nice to get some input how to find a solution for the following
error in igraph and vertex setting.

 

Thank you very much

Sibylle

 

> par(bg="black")

> network %>% plot(

+ vertex.color=clrs[V(.)$community], 

+ vertex.size=V(.)$hub_score*1, 

+ vertex.frame.color=V(.)$color, 

+ vertex.label.color="white", 

+ vertex.label.cex=0.5, 

+ vertex.label.family="Helvetica",

+ vertex.label.font=1,

+ edge.curved=0.5,

+ edge.width= network,

+ layout=layout_with_mds(.))

Error in intI(i, n = x@Dim[1], dn[[1]], give.dn = FALSE) : 

  Index gr��er als maximales 6

 

 

Reproducible example:

 

edge_list<-read.csv("edges_table_Test.csv")

 

#create network and add some necessary attributes (vertices) for the plot

network <- graph_from_data_frame(aes_collapsed, directed= FALSE, 

 vertices = details)

 

 

temp<-cluster_optimal(network)

temp<-cbind(membership=temp$membership, Names=temp$name)

aes_collapsed <- aes_collapsed %>%

  merge(temp, by="Names")

 

 

network <- network %>%

  set_edge_attr(name = "type", value = factor(aes_collapsed$Names, 

 ordered =
is.ordered(V(network)$name))) %>%

  set_edge_attr(name = "membership", value = aes_collapsed$membership) %>%

  set_edge_attr(name = "color", 

  value = c(viridis::viridis(5))

  [match(E(.)$type, c(factor(V(.)$name)))]) %>%

  set_vertex_attr(name = "trans_v_net", value = c(transitivity(., type =
"local"))) %>%

  set_vertex_attr(name = "hub_score", value = c(hub_score(.)$vector)) %>%

  set_vertex_attr(name = "color", 

  value = c(viridis::viridis((5)))

  [match(V(.)$name, c(factor(V(.)$name)))]) %>%

  set_vertex_attr(name= "community", value=cluster_optimal(.)$membership)

 

clrs<-scico(3, palette = "batlow")

 

par(bg="black")

network %>% plot(

 vertex.color=clrs[V(.)$community], 

 vertex.size=V(.)$hub_score*5, 

 vertex.frame.color=V(.)$color, 

 vertex.label.color="white", 

 vertex.label.cex=0.5, 

 vertex.label.family="Helvetica",

 vertex.label.font=1,

 edge.curved=0.5,

 edge.width= network,

 layout=layout_with_mds(.))

 

 

edges_table_Test.csv

 


Names

target

weight


B.B

A.A

4


C.C

A.A

5


D.D

A.A

5


E.E

A.A

5


F.F

A.A

1


C.C

B.B

5


E.E

B.B

1


F.F

B.B

2


A.A

C.C

5


B.B

C.C

1


D.D

C.C

5


E.E

C.C

5


F.F

C.C

3


A.A

D.D

5


B.B

D.D

1


C.C

D.D

5


E.E

D.D

5


F.F

D.D

4


A.A

E.E

5


B.B

E.E

1


C.C

E.E

4


D.D

E.E

5


F.F

E.E

5


A.A

F.F

5


B.B

F.F

1


C.C

F.F

2


D.D

F.F

3


E.E

F.F

4


F.F

F.F

5

 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.