Importing Structure results into dartRverse

81 views
Skip to first unread message

Nelia Perry

unread,
May 5, 2025, 2:22:58 AMMay 5
to dartR
Hi all,

I ran Structure and got my results. I used Structure Selector to determine the optimal K and to run CLUMPAK. For some additional visualization, I was hoping to use dartRverse packages. However, I am not sure how to read in my Structure results to R. Everything I am seeing is how to use gl.plot.structure, for example, if your results are stored in R already because Structure was run withing R (I used the Microsoft app of Structure). I am wondering if there is a way to read in my Structure results to R.

A second question: I used CLUMPAK to visualize my clusters for the best K value, but I am not sure if there is a way to see which individual is actually assigned to each cluster. Is there a straightforward way to do this? I was thinking this might be possible within R, but again I need to be able to import my Structure data first.

All help is very appreciated!

Best,
Nelia

Jose Luis Mijangos

unread,
May 8, 2025, 2:31:09 AMMay 8
to dartR
Hi Nelia,

We added a new function to read Structure's output files into dartR (gl.read.structure). To try the function, please install the developing version of dartR.popgen as shown below:

#Install developing version of dartR.popgen
devtools::install_github("green-striped-gecko/dartR.popgen@dev")
library(dartRverse)
# load genlight object
t1 <- readRDS("filtered_ledbirdi_genlight.rds")
# read output files from running structure outside of dartR
sr <- gl.read.structure(folder.path= "lidgbirdi_all_results",
                        x = t1)
# evanno plot
ev <- gl.evanno(sr)
# bar plot ordered by population
gl.plot.structure(sr,
                  K=6)
# bar plot ordered using dendrogram
gl.plot.structure(sr,
                  K=6,
                  den = T,
                  x=t1,
                  ind_name = F)

Cheers,
Luis

Rajneesh Paliwal

unread,
May 8, 2025, 4:55:59 AMMay 8
to da...@googlegroups.com
Dear Jose,

Can you help us how to use Admixture software results similarly for bar plot and barplot with dendrogram, and population confirmation plot? How can be get the list of our lines based on over 70% ancestry coefficient and admixture lines in the population and its plot? Many time 
Please help us to share the script for admixture software as you shared for structure results. Most of times, with large data people preferred Admixture over Structure due to running time constraints. Thanks in advance for your kind help.
Best regards
Rajneesh

Rajneesh Paliwal, PhD (DAAD Fellow)

Associate Scientist

Genetic Resources Center

International Inst. for Tropical Agriculture

Oyo Road PMB-5320, Ibadan, Nigeria



--
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 visit https://groups.google.com/d/msgid/dartr/5315e672-1774-4cb5-8daf-acb31ddc5149n%40googlegroups.com.

Jose Luis Mijangos

unread,
May 11, 2025, 10:36:00 PMMay 11
to dartR

Hi,

We haven’t implemented Admixture in dartR yet, but there are several alternative methods for population structure analysis that are already available:

  1. gl.run.faststructure() – works on macOS and Linux systems only

  2. gl.run.snmf() – also known as LEA

  3. gl.run.popcluster() – based on:
    Wang, J. (2022). Fast and accurate population admixture inference from genotype data from a few microsatellites to millions of SNPs. Heredity, 129(2), 79–92. https://doi.org/10.1038/s41437-022-00538-1

Cheers,

Luis


Message has been deleted

Susan Miller

unread,
Aug 12, 2025, 6:44:32 PMAug 12
to dartR
Hi Luis,

I would like to use gl.run.popcluster(), but the function does not appear to be available with my installation. I have installed dartRverse and have all the modules installed. When I check for functions using ls("package:dartR"), gl.run.popcluster is not in the list (both gl.run.structure and gl.run.faststructure are there along with all the expected other functions for those programs). The version of dartR I have installed is 2.9.9.5, which I believe is the most recent version. Is there something else I need to install to get gl.run.popcluster to work?

Also, could you share an example of the code for gl.run.structure to input the various parameters. I'm familiar with the program as I've used the gui version in windows, but I'm not sure how to write the parameters as R code once the function is available.

thanks for all your efforts on the dartR code - everything else I've used in dartR has been working really well!

cheers,
Susan

Jose Luis Mijangos

unread,
Aug 12, 2025, 8:26:12 PMAug 12
to dartR
Hi Susan,

We are no longer maintaining the dartR package. Instead, we are now developing the dartRverse packages. You can find more information here:

https://github.com/green-striped-gecko/dartR/wiki/Installation-tutorial#dartrverse

To install the development versions of the dartRverse packages, please follow these steps:

# 1. Clean your workspace
# Menu > Session > Clear workspace

# 2. Restart your R session
# Menu > Session > Restart R

# 3. Install the necessary Bioconductor packages
install.packages("devtools")
install.packages("BiocManager")
BiocManager::install("SNPRelate",force = TRUE)
BiocManager::install("LEA",force = TRUE)
BiocManager::install("snpStats",force = TRUE)
BiocManager::install("gdsfmt",force = TRUE)
BiocManager::install("BiocGenerics",force = TRUE)
BiocManager::install("zlibbioc",force = TRUE)

# 4. Install dartRverse
install.packages("dartRverse")

# 4. Install the development versions of the dartRverse packages
devtools::install_github('green-striped-gecko/dartR.sexlinked@dev',force = TRUE)
devtools::install_github('green-striped-gecko/dartR.spatial@dev',force = TRUE)
devtools::install_github('green-striped-gecko/dartR.captive@dev',force = TRUE)
devtools::install_github('green-striped-gecko/dartR.popgen@dev',force = TRUE)
devtools::install_github('green-striped-gecko/dartR.base@dev',force = TRUE)
devtools::install_github('green-striped-gecko/dartR.sim@dev',force = TRUE)

# Example usage
library(dartRverse)
t1 <- platypus.gl

# Download the popcluster binary and place it in your working directory:
# https://www.zsl.org/about-zsl/resources/software/popcluster
r1 <- gl.run.popcluster(
  x = t1,
  popcluster.path = getwd(),
  output.path = getwd(),
  filename = "output",
  minK = 2,
  maxK = 4,
  rep = 2
)
p1 <- gl.plot.popcluster(r1, plot.K = 3)

# Download the STRUCTURE binary for your OS and place it in your working directory:
# https://web.stanford.edu/group/pritchardlab/structure_software/release_versions/v2.3.4/html/structure.html
# For Windows, use exec = './structure.exe'
r2 <- gl.run.structure(
  x = t1,
  exec = "./structure",
  k.range = 2:4,
  num.k.rep = 2,
  burnin = 1000,
  numreps = 1000,
  noadmix = TRUE,
  freqscorr = FALSE,
  randomize = TRUE,
  seed = 0,
  locpriorinit = 1,
  maxlocprior = 20,
  gensback = 2,
  migrprior = 0.05,
  pfrompopflagonly = TRUE,
  inferalpha = FALSE,
  alpha = 1,
  unifprioralpha = TRUE,
  alphamax = 20,
  alphapriora = 0.05,
  alphapriorb = 0.001,
  plot.out = TRUE,
  plot_theme = theme_dartR(),
  plot.dir = tempdir(),
  delete.files = TRUE
)

p2 <- gl.plot.structure(r2, K = 2:4,
                        color_clusters = c("green","red","yellow","blue"),
                        den = TRUE, x = t1)

p3 <- gl.plot.structure(r2, K = 3,
                        color_clusters = c("green","red","yellow","blue"),
                        den = FALSE, x = t1)

p4 <- gl.map.structure(p3, x = t1, K = 3)


Cheers,
Luis
Reply all
Reply to author
Forward
0 new messages