Search code examples
rbioinformaticsgenetics

Mutation step/symbol size when plotting haplotype networks with pegas


I've been trying to figure out how to make the little circles that represent mutation steps on a haplotype network bigger. For whatever reason, all the normal ways I'd think don't seem to be working. It seems like no matter what I do, the symbols remain tiny. What am I missing?

Here's a base bit of sample code:

data(woodmouse)
h <- haplotype(woodmouse)
net <- haploNet(h)
plot(net, size=attr(net,"freq")*3,bg=pal,labels=F, fast=F, legend=F, 
      show.mutation=T,threshold=0)
# using scale.ratio = 1, the mutations are visisble
plot(net, size=attr(net,"freq")*3,bg=pal,labels=F, fast=F, legend=F, 
      show.mutation=T,threshold=0,scale.ratio=3)
# but using scale.ratio=3, they get tiny / disappear

You can see the mutations here, but if I set scale.ratio to something bigger (a requirement with my own data), they essentially disappear.

I've tried passing a larger cex to plot (doesn't work) as well as setting cex globally with par (makes the whole plot smaller for some reason).

It seems like the circles are scaled with the lines, but I don't know how to control that. Is it even possible? Am I missing something really obvious?


Solution

  • cex controls the font size and will not help with graphics size. From the help page for the haploNet and plot.haploNet functions:

    ?haploNet
    

    size: a numeric vector giving the diameter of the circles representing the haplotypes: this is in the same unit than the links and eventually recycled.
    scale.ratio: the ratio of the scale of the links representing the number of steps on the scale of the circles representing the haplotypes. It may be needed to give a value greater than one to avoid overlapping circles.

    This means that size of the links (circles representing mutations between haplotypes) is relative to the size of the haplotypes. To relatively enlarge the link size, you need to find a suitable combination of the two arguments.

    set.seed(123)
    net <- haploNet(haplotype(woodmouse[sample(15, size = 50, replace = TRUE), ]))
    
    par(mfrow=c(1,2))
    plot(net, size=attr(net,"freq"), labels=F, fast=F, legend=F, 
       show.mutation=T, threshold=0, scale.ratio=1)
    plot(net, size=attr(net,"freq")*.2, labels=F, fast=F, legend=F, 
       show.mutation=T, threshold=0, scale.ratio=.2)
    

    Enlarging circle size with haploNet runs into a risk that circles will overlap and the visible number of mutations will be incorrect. Use discretion with visualization and in case of problems, consider haplotype network calculation in TCS software where unsampled mutations are displayed with vertical bars or Network from Fluxus with proportional link lengths.