Closed vmkalbskopf closed 1 year ago
You can try to install the current version from GH (1.1-2). I fixed several bugs: see the NEWS file.
Hi Emmanuel, I've just downloaded the new version of pegas from here (and even copied the haplotype.R script manually), but the bug still persists. It is not using my own colour vector to colour all the haplotypes in the network (this with a msn network or a haplonet). If I remove bg = mtdna_colour, it colours all the haplotypes per region as it should
Hi Romina, I've just fixed another bug. Please try to re-install from GH. Best, Emmanuel
Hi Emmanuel, So sorry - I just tested it now with the new script (July 5th), and it still does the same thing - not using the palette correctly when specified by me.
Hi Romina, Did you re-install all the package?
Yes, I did. The haplotype script says haplotype.R (2022-07-05)
Assuming this is the new version?
And description file has: Package: pegas Version: 1.1-2 Date: 2022-07-28
Yes this seems correct. Do you have an example code to reproduce the bug?
Sure!
cervinus <- read.dna("D_cervinus.fasta", format ="fasta") cervinus2 <- haplotype(cervinus) dist_cervinus <- dist.dna(cervinus2, "K81") cervinus_msn <- msn(dist_cervinus) cervinus_haplonet <- haploNet(cervinus2)
haplo_freq_cerv <- summary(cervinus2) cerv_labs <- attr(cervinus_haplonet,"labels")
haplo_freq_cerv <- haplo_freq_cerv[cerv_labs] haplo_freq_cerv <- sqrt(haplo_freq_cerv) plot(cervinus_msn, size = haplo_freq_cerv)
region <- c("Madeira Islands", "Canary Islands","Canary Islands","Portugal","Portugal","Angola","Angola", "South Africa","South Africa","South Africa")
haplo_region <- haploFreq(cervinus, fac = region, haplo=cervinus2) haplo_region <- haplo_region[cerv_labs,]
mtdna_cervinus <- c("chartreuse2", "darkolivegreen", "chartreuse4", "darkseagreen4","darkslategray4")
names(mtdna_cervinus) <- c("Madeira Islands","Canary Islands", "Portugal", "Angola", "South Africa")
plot(cervinus_haplonet, size=haplo_freq_cerv, fast=TRUE, labels=FALSE, show.mutation=2, threshold=0, pie=haplo_region, scale.ratio = 0.01, fg="white",font=3, bg = mtdna_cervinus)
I used random data sampled from the woodmouse data in ape. It seems you have 10 sequences, so I did this:
library(pegas)
data(woodmouse)
cervinus <- woodmouse[sample.int(3, 10, rep = TRUE), ]
All the rest of the code is identical to yours (except the colours that I adapted to me), and this worked as expected. This also worked as expected if I sampled 10 different sequences.
Do you then think the problem is with the samples? When I don't specify bg = mtdna_cervinus, the haplotype network comes with 5 colours as expected.
It could be. I suggest you try with random data like I did yesterday and check if the pie slices are correct.
My custom palette:
pal =c( "#000000", "#FFFF00", "#1CE6FF", "#FF34FF", "#FF4A46")
The
net
object:net = structure(c(4, 4, 2, 2, 3, 1, 1, 1, 96, 0.998914290756452, 0.998914290756452, 0.620140160521222), dim = 3:4, dimnames = list(NULL, c("", "", "step", "Prob")), freq = c(1L, 1L, 1L, 2L), labels = c("I", "II", "III", "IV"), alter.links = structure(c(3, 1, 96, 0.620140160521222 ), dim = c(1L, 4L), dimnames = list(NULL, c("", "", "step", "Prob" ))), class = "haploNet")
This is what I get when I specify the custom palette for the bg parameter:
plot(net, size=attr(net, "freq"), bg = pal, scale.ratio = 0.2, cex = 1, labels=F, pie = ft, font=1, fast=T, threshold=0, show.mutation = 0, legend=F)
If I don't specify the bg parameter, it works correctly:
plot(net, size=attr(net, "freq"), scale.ratio = 0.2, cex = 1, labels=F, pie = ft, font=1, fast=T, threshold=0, show.mutation = 0, legend=F)
I'm running pegas 1.1 This seems to be a relatively new issue, as it worked correctly for me last year.