tpq / amalgam

[OFFICIAL] [CoDA] An R package to amalgamate compositions into lower dimensions using genetic algorithms
5 stars 2 forks source link

Question about making amalgam plots #1

Open Marcel-TK opened 3 years ago

Marcel-TK commented 3 years ago

Dear Dr Quinn, I am using your package, amalgam to analyze microbiome data and really would like to thank you for making it easy to run. However I would love if possible that you provide guidance for the interpretation of the output (https://github.com/Marcel-TK/Caecilians-microbiome-analysis/blob/main/plot_amalgam_Cante_j.pdf. I have read the original article of amalgam and visited the github repository of the package but still have some questions unanswered. First, do we know what are the group of variables at each corner of the simplex (var1, var2 and var3)? Second is there a way to tell on the plot which samples are yellow and which ones are purple ? Third, How can one replicate figure 3 in the supplement material; more generally can one extract the results and customize the plots ? These are some of the questions that answering would help me understand my results and describe them as well.

tpq commented 3 years ago

Hello Marcel,

Thanks for your interest in the package! I'll try to answer these questions one at a time,

First, do we know what are the group of variables at each corner of the simplex (var1, var2 and var3)?

The figure is intended to serve as a "dashboard" to monitor the progress and results of the genetic algorithm. I recommend you extract the data from the object to determine which variables are in the corners (discussed below).

Second is there a way to tell on the plot which samples are yellow and which ones are purple ?

My answer here is similar to the first -- it is perhaps easiest to extract the data from the object and inspect manually to determine which samples are which (discussed below).

Third, How can one replicate figure 3 in the supplement material; more generally can one extract the results and customize the plots ?

The answer to all 3 questions are within the amalgam object. You can look at what meta-data is saved using the str function:

library(amalgam)
x <- randAcomp(100, 10)
A <- amalgam(x, n.amalgams = 3)
str(A)

What you want is the data stored in the $amalgams slot, which you can access via:

A$amalgams

A boxplot of this will get you something resembling Supplemental Figure 3:

boxplot(A$amalgams)

These data are also used to produce ilr-PCA plots. A non-ggplot2 version would like:

library(compositions)
A_ilr <- ilr(A$amalgams)
pca <- prcomp(A_ilr)$x
plot(pca[,1], pca[,2])

But of course you can customize however you'd like!

Marcel-TK commented 3 years ago

Hi Thom, Thank you for providing these answers, I find them useful and I can now interact with the amalgam output the way I wanted.