Options for gl.plot.structure()

155 views
Skip to first unread message

Peter K

unread,
May 19, 2022, 3:41:14 AM5/19/22
to dartR
Hi folks, a couple of hopefully a fairly quick queries:

How can I change the x-axis font size and plot margins for my Structure plots using gl.plot.structure()? (need to allow more space so that longer id names display fully)

Also how to change (or retain) the sort order (i.e. what are valid options for sort =  ), while subsetting my data set (so I the can display the genotypes for my full data set across a few different subplots so that the individual labels are not too crowded)?

Otherwise, how to set the x-axis labels to simply display the populations rather than the individual genotypes?

Thanks, Peter

Jose Luis Mijangos

unread,
May 20, 2022, 2:33:37 AM5/20/22
to dartR
Hi Peter,

We're still working on the customisation of the Structure plot.
In the meantime, you could use the code below.

Cheers,
Luis


devtools::install_github("EricArcher/strataG")

library(strataG)
library(dartR)
bc <- bandicoot.gl[,1:100]
sr <- gl.run.structure(bc, k.range = 2:5, num.k.rep = 3, exec = './structure.exe')
ev <- gl.evanno(sr)
qmat <- gl.plot.structure(sr, k=3, CLUMPP="./")

qmat_plot_tmp <- qmat
# preparing data
qmat_plot_tmp$ID <- paste0(qmat_plot_tmp$orig.pop,"_",qmat_plot_tmp$id)
qmat_plot_tmp <- qmat_plot_tmp[,-c(1:3)]
qmat_plot <- reshape2::melt(qmat_plot_tmp,id="ID")
#ordering data
qmat_plot <- qmat_plot[order(qmat_plot$ID),]
#plot
ggplot(qmat_plot, aes(x=ID, y=value, fill=variable))+
  geom_col(color="black") +
  theme_classic() +
  theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1)) +
  ylab("Ancestry proportion") +
 xlab("") +
  labs(fill = "K")
 

Peter K

unread,
May 20, 2022, 2:59:06 AM5/20/22
to da...@googlegroups.com
Great. Thanks Luis. That code seems to work fine and I should be able to adjust ggplot() options as required for other data sets.

Cheers,
Peter


--
You received this message because you are subscribed to the Google Groups "dartR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dartr+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dartr/e27df4f1-6c75-44af-8223-e72385ff819bn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages