3D PCOA plotting

327 views
Skip to first unread message

jlsr

unread,
Oct 22, 2020, 1:10:44 AM10/22/20
to dartR
Hello everyone,

I ran my data for PCoA and was able to generate a 2D diagram. I tried plotting it in 3d using the script gl.pcoa.plot.3d(pcoa, g, xaxis = 1, yaxis = 2, zaxis = 3), however, no diagram appeared. The following notes were on the console after running the line:

Starting gl.pcoa.plot.3d 
  Extracting coordinates of PCoA solution
  Plotting three specified axes
[1] 1.593161 1.259051 1.035970
Completed: gl.pcoa.plot.3d 
NULL

Is there any problem with my data?

Thank you very much.


Laurence

Bernd.Gruber

unread,
Oct 22, 2020, 1:43:32 AM10/22/20
to da...@googlegroups.com

Hi Laurence,

 

Sounds like there was a plot created following the output you stated.

 

So can you check if there is an additional window that popped up?

 

Also which system you are using?  As for the 3d plot to work you need quartz installed on Macs and rgl binaries installed on Linux. On Windows it should work out of the box (but an additional window will pop up).

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/a1a71482-f8c4-4e52-9b1b-382c0d3cffd8n%40googlegroups.com.

jlsr

unread,
Oct 22, 2020, 2:15:07 AM10/22/20
to dartR
Hello Dr. Bernd,

There's no pop-up window after the line was executed. Also, I already installed quartz. 

Thank you for answering my question.



Laurence

jlsr

unread,
Oct 22, 2020, 9:13:44 AM10/22/20
to dartR
Good day Dr. Bernd,

I was able to generate 3D PCoA. I forgot to restart the R and my computer after installing Quartz. I think that solved the issue. I have another concern regarding 3D PCoA. I am planning to incorporate the locations where my samples were collected and I was wondering if each location can be represented by a specific color in the 3D plot. I am not sure how to add the locations' row/column in the SNP and silico-DArT csv file and are there any additional script when constructing 3D PCoA with different colors.
This is the script I used for the PCoA:

pc <- gl.pcoa(i, nfactors = 5)
gl.pcoa.plot.3d(pc,i, title= "PCA", 
                xaxis=1, 
                yaxis=2, 
                zaxis=3,  
                shape="sphere", 
                radius=2, 
                legend="topright", 
                verbose=NULL)

Thank you very much.


Laurence

Bernd.Gruber

unread,
Oct 22, 2020, 8:17:50 PM10/22/20
to da...@googlegroups.com

Hi Laurence,

 

the 3d pcoa uses the population definition to do the 3d plot.

 

So you would need to redefine your population definition of your genlight object (called “I” in your example)

 

 

So something like

 

pop(i) <- factor that codes for each individual location.

 

 

Another way is to have the factor included in your metadata when you load your data (assuming it is dart data) via

 

gl.read.dart(“dartfile”, “metadatafile“)

 

you would need to add a column maybe called “location” to your metadata file that codes for the color of the individuals.

 

And then you could do:

 

 

pop(i) <- i@other$ind.metrics$location

 

 

And the final more hacking version is to have a look at the gl.pcoa.plot.3d function. There you can see that the function is mostly a wrapper around functions from the pca3d package. As you can see there, the plot command is at the end here:

 

 

   pca3d::pca3d(coords, shape = shape, radius = radius,

            group = row.names(glPca$scores), legend = legend,

            axe.titles = c(xlab, ylab, zlab))

 

 

and groupings are defined via the group argument.

 

Finally I just found an cool looking new github package that uses shaders to create 3d ggplot in case you want to dig down even deeper.

 

https://www.tylermw.com/3d-ggplots-with-rayshader/

 

 

Might be an addtion to the next version…

jlsr

unread,
Oct 22, 2020, 9:54:54 PM10/22/20
to dartR
Thank you Dr. Bernd! I will try this.


Laurence

Reply all
Reply to author
Forward
0 new messages