[R-sig-eco] PCA for composition data followed by RLQ
Johannes Björk
bjork@joh@nne@ @end|ng |rom gm@||@com
Tue Feb 22 08:09:13 CET 2022
What if you run
clr_data= compositions::clr(data+pseudocount) #add pseducount if data contains a lot of zeroes. However function performs clr-transformation on non-zeroes (what is called robust clr).
aitchison_distance = dist(clr_data, method=“euclidean”)
pca_data = dudi.pca(data.frame(aitchison_distance))
Cheers
Johannes
> On 22 Feb 2022, at 05:11, Terri Lacourse <tlacours using uvic.ca> wrote:
>
> Hi Diogo,
> I think you can also apply the Hellinger transformation to your table R data, and then use dudi.pca, no?
> But, yes, the rgr::clr function is what you are after. It will give you the centered log-ratio transformation proposed by Aitchison. Or you could try rgr::ilr. But neither are suitable if your data have many zeros.
>
> Cheers,
> Terri
>
>
>> On Feb 21, 2022, at 7:32 PM, Diogo B. Provete <dbprovete using gmail.com> wrote:
>>
>> Hi Terri,
>> thanks for the feedback. Yes, I meant exactly the transformations proposed by Aitchison. The point is my diet data (R) is expressed as the percentage of a given item found in bat faeces. So I have 5 variables (pollen, insects, fish etc) with varying percentages whose rows sum to 100.
>> As for the species composition matrix (L), yes, certainly the Hellinger transformation can be applied in this case, but I was more worried about how to treat the diet data before entering them in the RLQ itself. So, how can I calculate the log-ratios ? There's this function in rgr::clr, but I'm not entirely sure it's what I need.
>>
>> Best,
>> Diogo
>>
>> Em seg., 21 de fev. de 2022 às 23:11, Terri Lacourse <tlacours using uvic.ca <mailto:tlacours using uvic.ca>> escreveu:
>> Dear Diogo,
>>
>> I don’t see a way to run a “compositional PCA” in ade4. I presume you mean log-ratios as proposed by Aitchison? Could you determine the log-ratios first and then send that to the dudi matrix?
>>
>> Perhaps you could use Hellinger transformation instead for your compositional data. That is what I do, and then I set the RLQ environment in this way:
>>
>> data1_L <- dudi.coa(data1, scannf=F, nf=2) # these are Hellinger-transformed compositional data like your diet data
>> data2_R <- dudi.pca(data2, scannf=F, nf=2, row.w=data1_L$lw)
>> data3_Q <- dudi.pca(data3, scannf=F, nf=2, row.w=data1_L$cw)
>> rlq.output <- rlq(data2_R, data1_L, data3_Q, scannf=F, nf=2)
>>
>> Best wishes,
>> -Terri
>>
>> ~~~~~~~~~~~~~~~~~~~
>> Terri Lacourse
>> Associate Professor
>> Department of Biology
>> University of Victoria
>> Victoria, BC
>> Canada V8W 2Y2
>>
>> tlacours using uvic.ca <mailto:tlacours using uvic.ca>
>> ~~~~~~~~~~~~~~~~~~~
>>
>>
>>
>>>> On Feb 21, 2022, at 12:14 PM, Diogo B. Provete <dbprovete using gmail.com <mailto:dbprovete using gmail.com>> wrote:
>>>
>>> Dear members,
>>> I'm trying to run an RLQ analysis to test for a covariation between skull
>>> shape (set of eigenvectors) and diet composition for a set of bat species.
>>> The point is, the data for diet is expressed as percentage, with rows
>>> (species) summing to 100. Therefore, it's better treated as compositional
>>> data.
>>>
>>> I have already run a compositional PCA in the R package compositions, which
>>> returns an object of the class princomp. However, ade4::rlq only accepts
>>> dudi matrices. I don't know how to convert a princomp to a dudi object or
>>> perhaps run a compositional PCA in ade4. as.dudi seems not to be called
>>> directly by the user.
>>>
>>> Does anyone have any clue on how to do this?
>>>
>>> Thank you in advance,
>>> Diogo
>>>
>>> --
>>>
>>> Diogo B. Provete, PhD
>>>
>>> Assistant Professor
>>>
>>> Biodiversity Synthesis lab <http://diogoprovete.weebly.com/ <http://diogoprovete.weebly.com/>>
>>>
>>> Biosciences Institute | Federal University of Mato Grosso do Sul | Brazil
>>>
>>>
>>> Skype: diogoprovete
>>>
>>>
>>> Director of Graduate studies in Animal Biology
>>> <https://ppgbioanimal.ufms.br/ <https://ppgbioanimal.ufms.br/>>
>>> __
>>> Biodiversity & Conservation Section Editor at PeerJ
>>> Open Access Journals
>>> peerj.com/diogoprovete <http://peerj.com/diogoprovete> <https://peerj.com/diogoprovete/ <https://peerj.com/diogoprovete/>>
>>>
>>> Associate Editor: Austral Ecology
>>> <https://onlinelibrary.wiley.com/page/journal/14429993/homepage/editorialboard.html <https://onlinelibrary.wiley.com/page/journal/14429993/homepage/editorialboard.html>>
>>> | Amphibia-Reptilia
>>> <https://brill.com/view/journals/amre/amre-overview.xml <https://brill.com/view/journals/amre/amre-overview.xml>> | BMC Ecology and
>>> Evolution | Ecosphere
>>> <https://esajournals.onlinelibrary.wiley.com/hub/journal/21508925/editorial-board/editorial-board <https://esajournals.onlinelibrary.wiley.com/hub/journal/21508925/editorial-board/editorial-board>>
>>> | Ecology and Evolution | Frontiers in Ecology and the Environment |
>>> Journal of Biogeography | Journal of Herpetology
>>> <https://journalofherpetology.com/ <https://journalofherpetology.com/>>
>>>
>>> [[alternative HTML version deleted]]
>>>
>>> _______________________________________________
>>> R-sig-ecology mailing list
>>> R-sig-ecology using r-project.org <mailto:R-sig-ecology using r-project.org>
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology <https://stat.ethz.ch/mailman/listinfo/r-sig-ecology>
>>
>
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-ecology mailing list
> R-sig-ecology using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
More information about the R-sig-ecology
mailing list