JuliaEarth / CoDa.jl

Compositional data analysis in Julia
MIT License
60 stars 8 forks source link

Compatibility with Biplot.jl for PCA analysis #41

Closed Iddingsite closed 11 months ago

Iddingsite commented 11 months ago

Hi!

I am trying to play around with this package in the ultimate goal to make a biplot after my log-ratio transformation. Biplot.jl is listed as a potential candidate to make the plotting part but I am struggling to make the link with the 2 packages. And I would also like to understand the benefit to work with CoDaArray compared to a Table from TableTransforms.jl (both packages are new for me). Is CoDaArray kinda useful only if I want to use operations on them?

Here is what I tried with a simple MWE:

table = (SiO2=[0.728,0.725,], TiO2=[0.005,0.005], Al2O3=[0.143, 0.145], Fe2O3=[0.032, 0.032], MnO=[0.001, 0.001], MgO=[0.010, 0.010], CaO=[0.018, 0.022], Na2O=[0.032, 0.034], K2O=[0.003, 0.027])

ctable = compose(table)

table_clr = ctable.coda |> CLR()
# or ctable_clr = clr.(ctable.coda)?

So at the end I am using TableTransforms.jl syntax. Which mean that I could also do a PCA which should be compatible with Biplot.jl?

table_clr_PCA = table_clr |> PCA()

But looking at the exemple on Biplot.jl, it seems to me that it is doing the transformation under the hood before the plotting. So I am a bit confused to what I should give Biplot.jl.

Don't hesitate to tell me if I should more ask the question on TableTransforms.jl or Biplot.jl!

juliohm commented 11 months ago

The Biplots.jl package allows different projections (see the option kind). In that sense it requires a table with compositional data. There are various adjustments in the biplots paper that are not straightforward to implement with a simple call to CLR() followed by PCA() followed by the plot recipe. Also, the current implementation doesn't require CoDa.jl as a dependency in case people are only interested in biplots of non compositional data.

Prefer the table interface as it has more transforms such as Remainder, Closure, etc which are useful for compositional data.

Also, take a look at the Geospatial Data Science with Julia book to learn more about these transforms in general: https://juliaearth.github.io/geospatial-data-science-with-julia

Feel free to reach out on Zulip with more questions. The #geostats.jl channel would be an option given that CoDa.jl is one of its submodules.

Em ter., 28 de nov. de 2023 06:46, Hugo Dominguez @.***> escreveu:

Hi!

I am trying to play around with this package in the ultimate goal to make a biplot after my log-ratio transformation. Biplot.jl is listed as a potential candidate to make the plotting part but I am struggling to make the link with the 2 packages. And I would also like to understand the benefit to work with CoDaArray compared to a Table from TableTransforms.jl (both packages are new for me). Is CoDaArray kinda useful only if I want to use operations on them?

Here is what I tried with a simple MWE:

table = (SiO2=[0.728,0.725,], TiO2=[0.005,0.005], Al2O3=[0.143, 0.145], Fe2O3=[0.032, 0.032], MnO=[0.001, 0.001], MgO=[0.010, 0.010], CaO=[0.018, 0.022], Na2O=[0.032, 0.034], K2O=[0.003, 0.027])

ctable = compose(table)

table_clr = ctable.coda |> CLR()

or ctable_clr = clr.(ctable.coda)?

So at the end I am using TableTransforms.jl syntax. Which mean that I could also do a PCA which should be compatible with Biplot.jl?

table_clr_PCA = table_clr |> PCA()

But looking at the exemple on Biplot.jl, it seems to me that it is doing the transformation under the hood before the plotting. So I am a bit confused to what I should give Biplot.jl.

Don't hesitate to tell me if I should more ask the question on TableTransforms.jl or Biplot.jl!

— Reply to this email directly, view it on GitHub https://github.com/JuliaEarth/CoDa.jl/issues/41, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZQW3LIT7I3TLJKN2UGB2DYGWXHLAVCNFSM6AAAAAA75OG7QWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGAYTIMBUGA4TINQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Iddingsite commented 11 months ago

Hey, thx a lot for the quick answer. I will look into all of that!