number of elements in 'fac' not the same than number of sequences

YLG_Sequences.fas as dataframe
x y
|Guipuzcoa|-2.022542|43.31686|
|Vizcaya|-2.806765|43.42304|
|Cantabria|-3.599561|43.48535|
|Asturias|-5.847326|43.63396|
|Galicia|-9.146732|43.15141|
|Portugal|-8.908798|40.09411|
|Azores|-27.226497|38.65332|
|Huelva|-6.972588|37.17709|
|Gibraltar|-5.388123|35.97587|
|MoroccoAtl|-9.712831|31.52262|
|MadeiraI|-16.974115|32.72644|
|CanaryI|-16.636954|28.21373|
|MoroccoMed|-3.895493|35.19959|
|Argelia|5.775968|36.77743|
|BalearicI|2.411911|39.57711|
|EbroDelta|0.859234|40.69580|
|MedasI|3.221679|42.04187|
|Camargue|4.503297|43.47467|

YLG_coords.csv
x, y
Guipuzcoa, -2.022542, 43.316862
Vizcaya, -2.806765, 43.423044
Cantabria, -3.599561, 43.485352
Asturias, -5.847326, 43.633958
Galicia, -9.146732, 43.151411
Portugal, -8.908798, 40.094108
Azores, -27.226497, 38.653323
Huelva, -6.972588, 37.177091
Gibraltar, -5.388123, 35.975872
MoroccoAtl, -9.712831, 31.522619
MadeiraI, -16.974115, 32.726438
CanaryI, -16.636954, 28.213732
MoroccoMed, -3.895493, 35.199594
Argelia, 5.775968, 36.777429
BalearicI, 2.411911, 39.577113
EbroDelta, 0.859234, 40.695801
MedasI, 3.221679, 42.041875
Camargue, 4.503297, 43.474675

install.packages("pegas")
library("pegas")
Gull<-read.dna("/cloud/project/Dataset_Gulls/YLG_Sequences.fas", format="fasta")
Gull
Gull.strata<-read.csv("/cloud/project/Dataset_Gulls/YLG_Coords.csv") 
Gull.pop<-Gull.strata[,1]
Gull.region<-Gull.strata[,2]
Gull.region
table(Gull.region, Gull.pop)
Gull.haps<-haplotype(Gull) 
Gull.haps
Gull.dist<-dist.dna(Gull.haps, model="N")
Gull.dist
Gull.net<-haploNet(Gull.haps, d=Gull.dist) 
Gull.net
plot(Gull.net)
summary(Gull.haps)
Gull.haps.size<-summary(Gull.haps)
Gull.net.labs<-attr(Gull.net, "labels")
Gull.net.labs
Gull.haps.size<-Gull.haps.size[Gull.net.labs]
plot(Gull.net, size=Gull.haps.size)
Gull.reg.freq<-haploFreq(Gull, fac = Gull.region, haplo=Gull.haps)
Gull.reg.freq
Gull.pop.freq<-haploFreq(Gull, fac = Gull.pop, haplo = Gull.haps)
Gull.pop.freq
Gull.reg.freq<-Gull.reg.freq[Gull.net.labs,]
Gull.pop.freq<-Gull.pop.freq[Gull.net.labs,]
plot(Gull.net, size=Gull.haps.size, pie=Gull.reg.freq, legend=c(-25,-20))
plot(Gull.net, size=Gull.haps.size, pie=Gull.pop.freq, legend=c(-25,-20))

Without a reprex or experience with pegas or haploFreq, there isn't much to go on here.

The docs suggest (haploFreq: Haplotype Frequencies With a Covariate in pegas: Population and Evolutionary Genetics Analysis System) the number of sequences in Gull need to match the number of values of fac, Gull.region, but your error message suggests these numbers don't match.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.