jgx65 / hierfstat

the hierfstat package
24 stars 14 forks source link

plot boot.ppfst #55

Closed andreiaamaral closed 2 years ago

andreiaamaral commented 2 years ago

Hello,

is there a function to plot a heatmap with the matrix obtained using boot.ppfst? thanks.

jgx65 commented 2 years ago

Hi Andreia, something like this?


plot.boot.ppfst<-function(x,...){
  a<-dim(x$ll)[1]
  ci<-matrix(nrow=a,ncol=a)
  dimnames(ci)<-dimnames(x$ll)
  for (i in 2:a)
    for (j in 1:(a-1)){
      ci[j,i]<-x$ul[j,i]
      ci[i,j]<-x$ll[j,i]
    }
    image(1:a,1:a,ci,xlab="population",ylab="Population")
}

##example use:

data(gtrunchier)
plot(boot.ppfst(gtrunchier[,-2]))
courtiol commented 2 years ago

Indirectly, hierfstat depends both on lattice (via ade4) and ggplot2 (via adegenet): image So there would also be the option of declaring a direct dependence to e.g. lattice and coding something with a scale as well. Such as:

plot.boot.ppfst<-function(x,...){
  a<-dim(x$ll)[1]
  ci<-matrix(nrow=a,ncol=a)
  dimnames(ci)<-dimnames(x$ll)
  for (i in 2:a)
    for (j in 1:(a-1)){
      ci[j,i]<-x$ul[j,i]
      ci[i,j]<-x$ll[j,i]
    }
  lattice::levelplot(ci,xlab="Population", ylab="Population", colorkey=list(title="Fst"), ...)
}

data(gtrunchier)
plot(boot.ppfst(gtrunchier[,-2]), col.regions = \(n) rev(grey.colors(n)))

image

That could open the door for more plotting...

jgx65 commented 2 years ago

Thanks for the tip! @andreiaamaral , does this solve your question? I'm closing it now, feel free to reopen if need be

andreiaamaral commented 2 years ago

Hi

sorry thanks for your tips and help!

On Wed, Mar 2, 2022 at 2:22 PM Jerome Goudet @.***> wrote:

Closed #55 https://github.com/jgx65/hierfstat/issues/55.

— Reply to this email directly, view it on GitHub https://github.com/jgx65/hierfstat/issues/55#event-6171259935, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB5KMU77SYW45GA7XN36EA3U552S3ANCNFSM5PD34H5A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>