stefpeschel / NetCoMi

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

Node names truncated to 6 positions in netAnalyze plot #54

Closed ranfoxall closed 2 years ago

ranfoxall commented 2 years ago

Hi Stefpeschel, I've been making a lot of progress comparing networks using NetCoMI based on covariates and am trying to prepare figures showing results from my network analyses. One problem I'm stuck on is how to enable longer node names on the plots from function "netAnalyze". The ASV (or taxa) names are truncated to 6 positions so I have manny duplicate names. When I plot my differential networks (diffnet) I do not run into the same issue, the full ASV name is printed and not truncated to 6 positions. I tried changing the font size but that did not fix the problem.


#network analysis of netConstruct

C0204_netAnalyze<- netAnalyze(C0204_network, 
                           centrLCC = FALSE,
                           avDissIgnoreInf = TRUE,
                           sPathNorm = FALSE,
                           clustMethod = "cluster_fast_greedy",
                           hubPar = c("degree", "between", "closeness"),
                           hubQuant = 0.9,
                           lnormFit = TRUE,
                           normDeg = FALSE,
                           normBetw = FALSE,
                           normClose = FALSE,
                           normEigen = FALSE)
#for plotting
plot(C0204_netAnalyze, 
     sameLayout = TRUE, 
     layoutGroup="union",
     rmSingles="inboth",
     nodeColor = "cluster",
     nodeSize = "mclr",
     labelScale = FALSE,
     cexNodes = 1.5, 
     cexLabels = .5,
     cexHubLabels = 1,
     cexTitle = 1.5,
     groupNames = c("No", "Yes"),
     hubBorderCol  = "gray40")
``
ranfoxall commented 2 years ago

Untitled

stefpeschel commented 2 years ago

Hey @ranfoxall,

Labels can be shortened via the three arguments shortenLabels, labelLength, and labelPattern.

You have three options:

  1. Setting shortenLabels to FALSE does not shorten the labels at all.
  2. Setting shortenLabels to "simple" in combination with labelLength = x cuts the labels after x characters (duplicates may occur).
  3. Setting shortenLabels to "intelligent" in combination with labelLength and labelPattern shortens the labels to a desired length by avoiding duplicates.

Default is shortenLabels = "simple" and labelLength = 6L, which explains the behavior in your case.

Please see the help page (?plot.microNetProps) for further details.

Best, Stefanie

ranfoxall commented 2 years ago

Thanks so much Stefanie!