stefpeschel / NetCoMi

Network construction, analysis, and comparison for microbial compositional data
GNU General Public License v3.0
146 stars 26 forks source link

Can't change edge colour when plotting differential networks #51

Closed VivienPichon closed 2 years ago

VivienPichon commented 2 years ago

Hi,

First of all thank you for this great package and it's amazing documentation.

I run into a issue when I try to use change the colors of the edges with the plot.diffnet() function with the following code:

diffnet_colors <- RColorBrewer::brewer.pal(6, "Paired")

netDiff_Gen3 <- diffnet(netComp_Gen3,
                        diffMethod = "discordant",
                        discordThresh = 0.8, #default
                        adjust = "lfdr" #default
                        )

plot(netDiff_Gen3, 
     cexNodes = 1, 
     cexLegend = 1,
     cexTitle = 2,
     edgeCol = diffnet_colors,,
     legendGroupnames = c("Sensitive", "Resistant"),
     legendPos = c(0.7,1.6))

I get the following error message:

Error in plot.diffnet(netDiff_Gen3, cexNodes = 1, cexLegend = 1, cexTitle = 2,  : 
  length(col) == 6 is not TRUE

I checked manually and the object diffnet_colors is a character vector of length 6 just as required with the discordant method. I also tried to use the edgeCol argument with its default values:

plot(netDiff_Gen3, 
     cexNodes = 1, 
     cexLegend = 1,
     cexTitle = 2,
     edgeCol = c("hotpink", "aquamarine", "red", "orange", "green", "blue"),
     legendGroupnames = c("Sensitive", "Resistant"),
     legendPos = c(0.7,1.6))

And I get the same error message. The function plot.diffnet() works very well if I don't use the edgeCol argument.

Am I doing something wrong or is it a bug?

Thank you for your help :-)

Vivien

stefpeschel commented 2 years ago

Hey Vivien,

I checked your code (thanks for the detailed description!) and found indeed a bug in the plot.diffnet function. The col vector, you can see in the error, doesn't exist anymore. I changed the name to edgecol and unfortunately missed this one spot.

While running your example, I found another bug when using the discordant method, which occurs if in netConstruct the jointPrepro argument is TRUE. It seems that the discordant method is only rarely used so that no one stumbled across this problem before. So, great that you spotted the bug!

I fixed the issues on "develop" branch but could not cherry pick them to master because I already did some further changes in the diffnet function which would lead to merge conflicts. So, I would kindly ask you to install NetCoMi from develop branch via

devtools::install_github("stefpeschel/NetCoMi", ref = "develop", force = TRUE).

I just checked whether the current version on develop branch runs without errors and hope, you won't encounter any problems. I'll merge the branch into master as soon as possible.

Best, Stefanie

VivienPichon commented 2 years ago

Hi Stefanie,

I just tried and it works great. Thank you so much for the quick fix! :-)

Best, Vivien

stefpeschel commented 2 years ago

Happy to hear that it worked, Vivien. Thanks for the feedback.

Best, Stefanie

VivienPichon @.***> schrieb am Mo., 16. Mai 2022, 08:30:

Hi Stefanie,

I just tried and it works great. Thank you so much for the quick fix! :-)

Best, Vivien

— Reply to this email directly, view it on GitHub https://github.com/stefpeschel/NetCoMi/issues/51#issuecomment-1127325062, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGHNJLR3VL7BI7LYO3VGJILVKH2QRANCNFSM5VUVIMIQ . You are receiving this because you commented.Message ID: @.***>