Structure speed and plotting error

44 views
Skip to first unread message

Vanessa Morris

unread,
Oct 6, 2025, 4:57:34 PMOct 6
to dartR
Hi Luis and team,

Other than lowering the settings, do you have any advice on speeding up structure? I'm using a PC.

I've also received the following error when trying to plot results:

> qmat <- gl.plot.structure(st, K=4, clumpak = TRUE)

Starting gl.plot.structure

Error in mcl(simMatrix, addLoops = TRUE)$Cluster : $ operator is invalid for atomic vectors


Could you please help let me know what this means and how I could plot the results?


Many thanks,

Vanessa

Peter Unmack

unread,
Oct 6, 2025, 6:58:18 PMOct 6
to da...@googlegroups.com
The best way to speed up structure is to stop using it and switch over
to using popcluster. It runs super fast. We've been using it for a
little while and have been very happy with it's performance and output.

https://onlinelibrary.wiley.com/doi/10.1111/1755-0998.14058

https://www.zsl.org/about-zsl/resources/software/popcluster

First export a vcf file in dartRverse

gl2vcf(gl, plink.bin.path = ("C:/peter/progs.genetics/plink"), outfile =
"burdekin", outpath = getwd())

Open popcluster, under DataConvert convert the vcf file to a dat file

then go project, new project and set up the paramater file. You can
also use / manually edit an existing parameter file instead.

The output file you want to look at is the Q file, I open it in excel,
switch from tab delimited to comma and make a plot from there. You can
also view the relevant details and plot stuff in popcluster too.

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
> <mailto:dartr+un...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/
> dartr/8caadb5e-2d90-4e66-9c5b-b7f6fd5eadd1n%40googlegroups.com <https://
> groups.google.com/d/msgid/dartr/8caadb5e-2d90-4e66-9c5b-
> b7f6fd5eadd1n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Bernd.Gruber

unread,
Oct 6, 2025, 6:59:57 PMOct 6
to da...@googlegroups.com
This or snmf (which is also now available in dartR).

gl.run.snmf

cheers, Bernd
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/8a52fb0c-5d28-4d55-b6a1-d4fbd859dab5%40unmack.net.

Vanessa Morris

unread,
Oct 6, 2025, 9:48:43 PMOct 6
to dartR
Thank you both.

Peter, how do you get a Q file? I only get a K file which specifies the best run for each k value but I would like to make my own barplot showing the assignment of each individual from a csv file.

Bernd, do I need to uninstall dartRverse to run gl.run.snmf? My code can't find the function.

Thanks,
Vanessa

Peter Unmack

unread,
Oct 6, 2025, 10:15:25 PMOct 6
to da...@googlegroups.com
For each K replicate popcluster outputs 6 files. The one you want ends
in .Q, eg, Burdekin_K_3_R_1.Q

Just add .csv to the end of the file name and it will open in excel.

The snmf code is a bit more convoluted. I've pasted what I have below.
I would just use popcluster though as it seems quite good, snmf though
will give you a basic view of the data very very quickly though, but
probably not quite as accurate I'd guess. From memory LEA is an R
package which you may need to install if it complains about not finding it.

Cheers
Peter

gl2geno(gl,outpath=getwd(), outfile = "macc-tc.structure2")
#run LEA
ss <- snmf(input.file = file.path(getwd(), "macc-tc.structure2.geno"),
K = 1:3,
entropy = TRUE,
repetitions = 5,
project = "new",
alpha = 10)
ss
#plot the results
plot(ss, cex = 1.2, col = "darkblue", pch = 19)
# get the cross-entropy of the 5 runs for K =2
ce <- cross.entropy(ss, K =3)
#find best run of the 5 (k=3)
best_run <- which.min(ce)
#plot the qmat

q_mat <- LEA::Q(ss, K= 3, run = best_run)
rownames(q_mat)<- indNames(gl)
head(q_mat)

write.csv(q_mat, file="macc-tc.structurek2.csv", row.names=TRUE)
write.csv(q_mat, file ="bream.structure2.csv")
colnames(q_mat) <- levels(pop(gl))




On 7/10/2025 12:48 pm, Vanessa Morris wrote:
> Thank you both.
>
> Peter, how do you get a Q file? I only get a K file which specifies the
> best run for each k value but I would like to make my own barplot
> showing the assignment of each individual from a csv file.
>
> Bernd, do I need to uninstall dartRverse to run gl.run.snmf? My code
> can't find the function.
>
> Thanks,
> Vanessa
>
> On Tuesday, October 7, 2025 at 9:59:57 AM UTC+11 Bernd. Gruber wrote:
>
> This or snmf (which is also now available in dartR).
>
> gl.run.snmf
>
> cheers, Bernd
>
> -----Original Message-----
> From: peter...@unmack.net <peter...@unmack.net> On Behalf Of 'Peter
> Unmack' via dartR
> Sent: Tuesday, 7 October 2025 9:58 AM
> To: da...@googlegroups.com
> Subject: Re: [dartR] Structure speed and plotting error
>
> The best way to speed up structure is to stop using it and switch
> over to using popcluster. It runs super fast. We've been using it
> for a little while and have been very happy with it's performance
> and output.
>
> https://onlinelibrary.wiley.com/doi/10.1111/1755-0998.14058
> <https://onlinelibrary.wiley.com/doi/10.1111/1755-0998.14058>
>
> https://www.zsl.org/about-zsl/resources/software/popcluster
> <https://groups.google.com/d/msgid/>
> > dartr/8caadb5e-2d90-4e66-9c5b-b7f6fd5eadd1n%40googlegroups.com
> <http://40googlegroups.com>
> > <https://
> > groups.google.com/d/msgid/dartr/8caadb5e-2d90-4e66-9c5b- <http://
> groups.google.com/d/msgid/dartr/8caadb5e-2d90-4e66-9c5b->
> > b7f6fd5eadd1n%40googlegroups.com?
> utm_medium=email&utm_source=footer <http://40googlegroups.com?
> utm_medium=email&utm_source=footer>>.
>
> --
> 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/8a52fb0c-5d28-4d55-b6a1-d4fbd859dab5%40unmack.net <https://
> groups.google.com/d/msgid/dartr/8a52fb0c-5d28-4d55-b6a1-
> d4fbd859dab5%40unmack.net>.
>
> --
> 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
> bf3ae386-43e1-4d0f-b7f7-fbced07613e8n%40googlegroups.com <https://
> groups.google.com/d/msgid/dartr/bf3ae386-43e1-4d0f-b7f7-
> fbced07613e8n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Matthew Holen

unread,
Oct 7, 2025, 4:51:21 PMOct 7
to dartR
Hi Bernd,

When attempting to use the gl.plot.snmf function I get the following error:
> Q <- gl.plot.snmf(snmf_result = snmf1, plot.K = 9, ind_name=F, border_ind = 0.15) Starting gl.plot.snmf Completed: gl.plot.snmf Warning messages: 1: The `size` argument of `element_line()` is deprecated as of ggplot2 3.4.0. Please use the `linewidth` argument instead. The deprecated feature was likely used in the dartR.base package. Please report the issue at <https://groups.google.com/g/dartr?pli=1>. This warning is displayed once every 8 hours. Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated. 2: The `size` argument of `element_rect()` is deprecated as of ggplot2 3.4.0. Please use the `linewidth` argument instead. The deprecated feature was likely used in the dartR.base package. Please report the issue at <https://groups.google.com/g/dartr?pli=1>. This warning is displayed once every 8 hours. Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated. 3: `aes_()` was deprecated in ggplot2 3.0.0. Please use tidy evaluation idioms with `aes()` The deprecated feature was likely used in the dartR.popgen package. Please report the issue at <https://groups.google.com/g/dartr?pli=1>. This warning is displayed once every 8 hours. Call `lifecycle::last_lifecycle_warnings()` to see where this warning was generated. 4: In geom_col(color = "black", size = border_ind, width = 1) : Ignoring unknown parameters: `size`

Any ideas on a fix?

Thank you!

Bernd.Gruber

unread,
Oct 7, 2025, 5:12:43 PMOct 7
to da...@googlegroups.com, dartR
This is just a warning, but should not affect the plot. New ggplot is asking for line width instead of size. We are fixing it currently. 

Cheers Bernd
---------


On 8 Oct 2025, at 07:51, 'Matthew Holen' via dartR <da...@googlegroups.com> wrote:

Hi Bernd,

Vanessa Morris

unread,
Oct 7, 2025, 6:25:59 PMOct 7
to dartR
I don't have output files which end in .Q but each K-run file e.g wa_K_2_R_1 contains the cluster results for that run which I can use. Thanks for your help!

Peter Unmack

unread,
Oct 7, 2025, 9:19:55 PMOct 7
to da...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages