Filtering and STRUCTURE analyses

387 views
Skip to first unread message

Francisco Rubianes L.

unread,
Apr 4, 2022, 11:02:39 PM4/4/22
to dartR
Hi everyone. I have a large data base with more than 89 SNPs and I would like to filter it and produce new cvs files after filtering. Is  it possible? I found the filtering tutorial but I am not sure how to create new files after filtering. Also I need to run LEA for structure analyses. I would like to know if there is a command for converting genlight objects to STRUCTURE files. My goal is to run STRUCTURE after filtering.

Any help will be greatly appreciated!

Regards,

Francisco.  

Bernd.Gruber

unread,
Apr 4, 2022, 11:16:29 PM4/4/22
to da...@googlegroups.com

There is a gl2structure function, but since version 2.0.3 you can use the inbuilt structure functions yourself (

 

 

gl.run.structure() see examples and you need to download the non-gui version of structure for your system.

 

The gl.plot.structure and gl.evanno do unfortunately not work on Macs (as CLUMPP) does not run no Macs.

 

Finally you can using the beautiful new function.

 

gl.map.structure in case your samples have coordinates

 

from the example: ?gl.run.structure

 

 

sr <- gl.run.structure(bc, k.range = 2:5, num.k.rep = 3, exec = 'd:/programms/structure/structure.exe')

ev <- gl.evanno(sr)

qmat <- gl.plot.structure(sr, k=3, CLUMPP='d:/programms/structure/')

 

gl.map.structure(qmat, bc, scalex=1, scaley=0.5)

 

 

Cheers, Bernd

 

 

 

 

 

==============================================================================

Dr Bernd Gruber                                              )/_         

                                                         _.--..---"-,--c_    

Professor Ecological Modelling                      \|..'           ._O__)_     

Tel: (02) 6206 3804                         ,=.    _.+   _ \..--( /          

Fax: (02) 6201 2328                           \\.-''_.-' \ (     \_          

Institute for Applied Ecology                  `'''       `\__   /\          

Faculty of Science and Technology                          ')                

University of Canberra   ACT 2601 AUSTRALIA

Email: bernd....@canberra.edu.au

WWW: bernd-gruber

 

Australian Government Higher Education Provider Number CRICOS #00212K 

NOTICE & DISCLAIMER: This email and any files transmitted with it may contain
confidential or copyright material and are for the attention of the addressee
only. If you have received this email in error please notify us by email
reply and delete it from your system. The University of Canberra accepts
no liability for any damage caused by any virus transmitted by this email.

==============================================================================

--
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/3e018dee-a4ee-42c2-9591-5b389ea3b828n%40googlegroups.com.

Jose Luis Mijangos

unread,
Apr 4, 2022, 11:30:05 PM4/4/22
to dartR
There is also function to convert to LEA format: gl2geno()
or to convert to faststructure: gl2faststructure()

Cheers,
Luis

Francisco Rubianes L.

unread,
Apr 4, 2022, 11:32:22 PM4/4/22
to dartR
Thanks Dr Gruber. I would like to run the structure just with the results from  the filters. From my original 89 000 SNPs, I end up with 14 000  after filtering, but I am not sure how to create a new csv with the filtered data

Cheers

Francisco Rubianes L.

unread,
Apr 4, 2022, 11:34:03 PM4/4/22
to dartR
Thanks a lot, Luis
very useful!!

Bernd.Gruber

unread,
Apr 5, 2022, 2:21:18 AM4/5/22
to da...@googlegroups.com

You do not need to.

 

You can run structure from within dartR via gl.run.structure.

 

Or you create a csv file in structure format via

 

gl2structure

 

Cheers, Bernd

Arthur Georges

unread,
Apr 5, 2022, 4:21:37 AM4/5/22
to dartR
Or use gl.write.csv to dump your SNP scores to a simple csv file.

A

Francisco Rubianes L.

unread,
Apr 5, 2022, 10:58:46 PM4/5/22
to dartR
Thank you all.

I already installed the STRUCTURE versions. I generate my genlinght object:
gl <- gl.read.dart(filename = "YFT2.csv", ind.metafile = "meta2.csv")

my ind.metafile has_ ind ID, pop ( I have 3 areas) and lat and log. And I am using my data from dart in SNP_singlerow_ format

I am running your suggestions but when I try to run gl.run.structure , I get this error:

gl.run.structure(
+   gl,
+   exec = "C:/Users/User/Downloads/structure_windows_console/console",
+   plot.out = TRUE,
+   plot_theme = theme_dartR(),
+   save2tmp = FALSE,
+   verbose = NULL
+ )
Starting gl.run.structure
  Processing genlight object with SNP data
Error in getClass(Class, where = topenv(parent.frame())) :
  “gtypes” is not a defined class

any ideas why that happens?

Bernd.Gruber

unread,
Apr 6, 2022, 7:25:51 PM4/6/22
to da...@googlegroups.com
Hi there is still a “bug” in the function. you have to install package strataG from github via

dev tools::install_github(‘ EricArcher/strataG’)

library(strataG)

and it should work. 

will be fixed soon on the beta branch.

Cheers, Bernd

On 7 Apr 2022, at 09:11, Francisco Rubianes L. <francisco...@gmail.com> wrote:

Thank you all.
--
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.

Francisco Rubianes L.

unread,
Apr 6, 2022, 10:33:50 PM4/6/22
to dartR
Thank you!
 I already installed the strataG and both STRUCTURE versions but I have this error now (Sorry for bothering you!):


Starting gl.run.structure
  Processing genlight object with SNP data
Error in FUN(X[[i]], ...) : You do not have STRUCTURE installed.

I am stumped



On Wednesday, 6 April 2022 at 18:25:51 UTC-5 Bernd. Gruber wrote:
Hi there is still a “bug” in the function. you have to install package strataG from github via

dev tools::install_github(‘ EricArcher/strataG’)

library(strataG)

and it should work. 

will be fixed soon on the beta branch.

Cheers, Bernd


Thank you all.


I already installed the STRUCTURE versions. I generate my genlinght object:
gl <- gl.read.dart(filename = "YFT2.csv", ind.metafile = "meta2.csv")

my ind.metafile has_ ind ID, pop ( I have 3 areas) and lat and log. And I am using my data from dart in SNP_singlerow_ format

I am running your suggestions but when I try to run gl.run.structure , I get this error:

gl.run.structure(
+   gl,
+   exec = "C:/Users/User/Downloads/structure_windows_console/console",
+   plot.out = TRUE,
+   plot_theme = theme_dartR(),
+   save2tmp = FALSE,
+   verbose = NULL
+ )
Starting gl.run.structure
  Processing genlight object with SNP data
Error in getClass(Class, where = topenv(parent.frame())) :
  “gtypes” is not a defined class

any ideas why that happens?

On Tuesday, 5 April 2022 at 03:21:37 UTC-5 Arthur Georges wrote:
Or use gl.write.csv to dump your SNP scores to a simple csv file.

A

On Tuesday, April 5, 2022 at 1:02:39 PM UTC+10 francisco  wrote:
Hi everyone. I have a large data base with more than 89 SNPs and I would like to filter it and produce new cvs files after filtering. Is  it possible? I found the filtering tutorial but I am not sure how to create new files after filtering. Also I need to run LEA for structure analyses. I would like to know if there is a command for converting genlight objects to STRUCTURE files. My goal is to run STRUCTURE after filtering.

Any help will be greatly appreciated!

Regards,

Francisco.  
--
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+

Bernd.Gruber

unread,
Apr 7, 2022, 1:05:16 AM4/7/22
to da...@googlegroups.com
You need to provide the full path to the structure.exe in the exec argument. 

Eg

"C:/Users/User/Downloads/structure_windows_console/console/structure.exe"

Cheers Bernd

---------


On 7 Apr 2022, at 12:37, Francisco Rubianes L. <francisco...@gmail.com> wrote:

Thank you!
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/b0edfff3-850a-4b08-a923-11cdc51853f5n%40googlegroups.com.

Francisco Rubianes L.

unread,
Apr 9, 2022, 3:11:23 AM4/9/22
to dartR
Hi Dr Bernd.
Thank you so much for your replies! The command worked, however, I have problems with the function theme_dartR. When the run finished, I obtained three graphs, however, I can't run the evanno calculations because I don't have the  result from the structure run.

I ran the next code:

structure <- gl.run.structure(
  gl,
  k.range = 2:5,
  num.k.rep=3,
  exec = "C:/Users/User/Downloads/structure_windows_console/console/structure.exe",
  plot.out = TRUE,
  plot_theme = theme_dartR(),
  save2tmp = FALSE,
  verbose = NULL
)

Error in theme_dartR() : could not find function "theme_dartR"
In addition: Warning message:
Removed 3 rows containing missing values (geom_segment).

gl.evanno(gl)
Error in utils.structure.evanno(sr, plot = plot.out) :
  'sr' is not a result from 'structure.run'.

Do you have any ideas on what I might be doing wrong? sorry about the insistence!

Bernd.Gruber

unread,
Apr 10, 2022, 1:30:48 AM4/10/22
to da...@googlegroups.com

Can you try to leave away the theme_dartR() argument in the gl.run.structure.

This is the default anyway, hence not necessary.

 

You would need to define your own theme if you want to use this functionality.

 

And also you need to call

 

gl.evanno(structure)

 

because the output of your gl.run.structure you called ‘structure’.

 

Also for the gl.plot.structure you need to set it to

 

gl.plot.structure(structure, k=3)

 

 

Regards, Bernd

 

 

In the example I used sr as output for gl.runstructure.

 

From: da...@googlegroups.com <da...@googlegroups.com> On Behalf Of Francisco Rubianes L.


Sent: Saturday, 9 April 2022 5:11 PM
To: dartR <da...@googlegroups.com>

Francisco Rubianes L.

unread,
Apr 13, 2022, 1:18:46 AM4/13/22
to dartR
Dr Bernd,

Thank you very much for all your help! the code is working perfectly now!

Regards,

Francisco
Reply all
Reply to author
Forward
0 new messages