[adegenet-forum] newbie help: formatting xy data stored in genind object for use in a sPCA

Judy (Duffie), Caroline JudyC at si.edu
Fri Nov 3 22:04:35 CET 2017


Dear Adegenet forum,

I created a genind object using the “read.structure” command. As you see in the code below - I specified the columns [,3:8] as “other”. These original data contain four traits, and xy coordinates [,7:8]. After conversion to a genind object, the resulting structure of @other is a list with one object, $X, which is a 158 x 6 matrix. The columns represent the four traits and the x,y data stored in separate columns.

How can I reformat $X to contain five objects: the four traits (each as a separate object), and an xy matrix as a single matrix with dimensions 158 x 2 for use in a downstream sPCA?

Many thanks in advance for help.
Caroline

------------------------------------------------------

> mydata <- read.structure("~/Documents/Trochilus/second_chapter/Analysis/structure/input/GBS_all_pop_pheno.stru",
+ n.ind=158,
+ n.loc=6451,
+ onerowperin=TRUE,
+ col.lab=1,
+ col.pop=2,
+ col.others=3:8,
+ row.marknames=0,
+ ask=FALSE,
+  )

 Converting data from a STRUCTURE .stru file to a genind object...

> mydata at other
$X
    [,1]     [,2]     [,3] [,4]    [,5]          [,6]
1   "female" "black"  "1"  "3.72"  "18.02911667" "-76.3886"
2   "female" "black"  "1"  "3.55"  "18.02911667" "-76.3886"
3   "male"   "black"  "1"  "3.97"  "18.02953333" "-76.38783333"
4   "male"   "black"  "1"  "3.55"  "18.0337"     "-76.38993333"
5   "female" "black"  "1"  "3.735" "18.0337"     "-76.38993333"
6   "male"   "black"  "1"  "3.95"  "18.0295"     "-76.38831667"
7   "male"   "black"  "1"  "3.99"  "18.02953333" "-76.38783333"

Caroline D. Judy
PhD Candidate (LSU)
Peter Buck Predoctoral Fellow (NMNH)
email: judyc at si.edu<mailto:judyc at si.edu>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20171103/ae25fd0e/attachment.html>


More information about the adegenet-forum mailing list