<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Caroline,<div class=""><br class=""></div><div class="">To format your spatial data:</div><div class=""><br class=""></div><div class="">By default, spca will look in the "other" slot to find a data frame or matrix called "xy" that has numeric coordinates.</div><div class="">You have a matrix called "X" in your other slot, which contains character data. To convert the last two columns to xy coordinates, there are three steps: 1) subset X to the last two columns, 2) save these as a matrix in the "other" slot called "xy", 3) convert xy to numeric:</div><div class=""><br class=""></div><div class="">other(mydata)$xy <- other(mydata)$X[, 5:6]</div><div class="">mode(other(mydata)$xy) <- "numeric"</div><div class="">colnames(other(mydata)$xy) <- c("x", "y")</div><div class=""><br class=""></div><div class="">To format your trait data:</div><div class=""><br class=""></div><div class="">If you will be using any of the categorical traits to separate your data, you can add them as strata:</div><div class=""><br class=""></div><div class="">strata(mydata) <- as.data.frame(other(mydata)$X[, 1:3]) # you can rename them with nameStrata()</div><div class=""><br class=""></div><div class="">Otherwise, you can add the traits one by one to your "other" slot like so:</div><div class=""><br class=""></div><div class="">other(mydata)$sex <- other(mydata)$X[, 1, drop = TRUE]</div><div class="">... </div><div class=""><br class=""></div><div class="">I hope that helps,</div><div class="">Zhian</div><div class=""><br class=""></div><div class=""><div class=""><div class="">
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">-----</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Zhian N. Kamvar, Ph. D.</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Postdoctoral Researcher (Everhart Lab)</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Department of Plant Pathology</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">University of Nebraska-Lincoln</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;">ORCID: 0000-0003-1458-7108</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div></div></div><div><blockquote type="cite" class=""><div class=""><div class="">Date: Fri, 3 Nov 2017 21:04:35 +0000<br class="">From: "Judy (Duffie), Caroline" <<a href="mailto:JudyC@si.edu" class="">JudyC@si.edu</a>><br class="">To: "<a href="mailto:adegenet-forum@lists.r-forge.r-project.org" class="">adegenet-forum@lists.r-forge.r-project.org</a>"<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span><<a href="mailto:adegenet-forum@lists.r-forge.r-project.org" class="">adegenet-forum@lists.r-forge.r-project.org</a>><br class="">Subject: [adegenet-forum] newbie help: formatting xy data stored in<br class=""><span class="Apple-tab-span" style="white-space:pre"> </span>genind object for use in a sPCA<br class="">Message-ID: <<a href="mailto:66466C5A-F609-46E1-9DCD-3DE3387BA55C@si.edu" class="">66466C5A-F609-46E1-9DCD-3DE3387BA55C@si.edu</a>><br class="">Content-Type: text/plain; charset="utf-8"<br class=""><br class="">Dear Adegenet forum,<br class=""><br class="">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.<br class=""><br class="">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?<br class=""><br class="">Many thanks in advance for help.<br class="">Caroline<br class=""><br class="">------------------------------------------------------<br class=""><br class=""><blockquote type="cite" class="">mydata <- read.structure("~/Documents/Trochilus/second_chapter/Analysis/structure/input/GBS_all_pop_pheno.stru",<br class=""></blockquote>+ n.ind=158,<br class="">+ n.loc=6451,<br class="">+ onerowperin=TRUE,<br class="">+ col.lab=1,<br class="">+ col.pop=2,<br class="">+ col.others=3:8,<br class="">+ row.marknames=0,<br class="">+ ask=FALSE,<br class="">+ )<br class=""><br class=""> Converting data from a STRUCTURE .stru file to a genind object...<br class=""><br class=""><blockquote type="cite" class="">mydata@other<br class=""></blockquote>$X<br class=""> [,1] [,2] [,3] [,4] [,5] [,6]<br class="">1 "female" "black" "1" "3.72" "18.02911667" "-76.3886"<br class="">2 "female" "black" "1" "3.55" "18.02911667" "-76.3886"<br class="">3 "male" "black" "1" "3.97" "18.02953333" "-76.38783333"<br class="">4 "male" "black" "1" "3.55" "18.0337" "-76.38993333"<br class="">5 "female" "black" "1" "3.735" "18.0337" "-76.38993333"<br class="">6 "male" "black" "1" "3.95" "18.0295" "-76.38831667"<br class="">7 "male" "black" "1" "3.99" "18.02953333" "-76.38783333"<br class=""><br class="">Caroline D. Judy<br class="">PhD Candidate (LSU)<br class="">Peter Buck Predoctoral Fellow (NMNH)<br class="">email: <a href="mailto:judyc@si.edu" class="">judyc@si.edu</a><<a href="mailto:judyc@si.edu" class="">mailto:judyc@si.edu</a>><br class=""><br class=""><br class=""><br class="">-------------- next part --------------<br class="">An HTML attachment was scrubbed...<br class="">URL: <<a href="http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20171103/ae25fd0e/attachment-0001.html" class="">http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20171103/ae25fd0e/attachment-0001.html</a>><br class=""><br class="">------------------------------<br class=""><br class="">_______________________________________________<br class="">adegenet-forum mailing list<br class=""><a href="mailto:adegenet-forum@lists.r-forge.r-project.org" class="">adegenet-forum@lists.r-forge.r-project.org</a><br class="">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum<br class=""><br class="">End of adegenet-forum Digest, Vol 111, Issue 3<br class="">**********************************************<br class=""></div></div></blockquote></div><br class=""></div></div></body></html>