CmlMagneville / mFD

:package: A Computation of Functional Spaces and Functional Diversity Indices
https://cmlmagneville.github.io/mFD/
GNU General Public License v2.0
24 stars 5 forks source link

Questions about alpha.multidim and alpha.multidim.plot #22

Closed AlexArevalo1 closed 2 years ago

AlexArevalo1 commented 2 years ago

Hi everyone! I would like to know if exist any method to solve some doubts that I have as follow:

First, when I ran 'mFD::alpha.fd.multidim()', It appears a warning message saying:

Error in mFD::alpha.fd.multidim(sp_faxes_coord = sp_faxes_coord_sps[, : Number of species should strictly be higher than the number of axes to compute the convex hull. It is not the case for RBAC29. Remove this assemblage or decrease the number of functional axes. FRic can not be computed here.

To solve this, I had to decrease the number of funcional axes ( maxdim_pcoa = 2 ) and I reduced my assemblages (from 80 to 68 assemblages).

My question here is if there is no other alternative to avoid this problem?

Later, when I solved the warning message and I get the 100 % of my assemblages (i.e. ## basket_10 done 100%), can we run "plot_asb_nm = c("basket_1", "basket_5")," with two assemblages only? Can I not run with more than two assemblages, with the 10 assemblages, as shown in the mFd: General Workflow as example?

What other alternative could I do if I want to compare two groups? As example, 'basket_1 to 5' grouped as 'basket_red' and 'basket_6 to 10' as 'basket_black'. I think in this form I could compare all my assemblages using the argument "plot_asb_nm = c("basket_red", "basket_black"),"

Cheers,

Alexander Arévalo. PhD Candidate in Biology-Ecology (INPA)

CmlMagneville commented 2 years ago

Hi Alexander,

The first error message tells you that some of your assemblages don't have enough species to compute the FRic convex hulls. A solution is to remove these assemblages from your analysis as you did (to make it less time-consuming you can do this step before trying to compute FRic values): the number of species in each assemblage you keep should strictly be higher than the number of functional axes. Then, keep in mind that finding a good functional space in which indices can be computed, is a trade-off between finding a functional space with a good quality and, in your case, being able to compute indices for most of your assemblages. Decreasing the number of functional axes to 2 may not result in a functional space with a good quality (use quality.fspaces() function to see) that is to say that the deviation between trait-based distances and distances in the functional space may be important.

Then, with the alpha.multidim.plot() function, you can't plot more than two assemblages. If you want to plot more than two assemblages, you can use thebackground.plot() and fric.plot()functions (no tutorial about it yet but you can have a look at functions help files).

Lastly, if you want to gather your assemblages into bigger groups, you have to gather the assemblages from the beginning of the worklow. Instead of having one row = one assemblage in the species*assemblage dataframe, you will have one row = one group of assemblages.

Hope this helps!

Cheers,

Camille

AlexArevalo1 commented 2 years ago

Hi Camille, thank you so much for your answer! I ran the code taking out some assamblages and I get a best result. I worked with 3 functional axis only since my lowest quality metric is 'pcoa_3d 0.031 '. In the workflow example is 'pcoa_4d 0.040'. So, which defines the correct number of axis is quality.fspaces() function, right?

NOTE The space with the best quality has the lowest quality metric. Here, thanks to mad values, we can see that the 4D space is the best one. That is why the following of this tutorial will use this multidimensional space.

About the last question, I tried to gather my assemblages into bigger groups by: sps <- read.table("Sps_RLQ-mod.txt",header=TRUE,fill = TRUE,row.names=NULL) sps <- data.matrix(sps)

My dataframe example: row.names Ca_un Cu_pa Da_le Da_sp Di_ma Ei_ba Le_pa Le_wi Ma_am Ma_ne My_ac 1 SP 0 2 9 0 0 0 1 0 0 0 2 2 SP 0 1 0 1 0 0 0 0 1 0 1 ..... 42 Control 0 3 2 3 0 0 0 0 0 2 54 43 Control 0 5 1 0 1 0 0 0 0 0 6

I used row.names=NULL argument to can run the matrix.

  row.names Ca_un Cu_pa Da_le Da_sp Di_ma Ei_ba Le_pa Le_wi Ma_am Ma_ne My_ac

[1,] 2 0 2 9 0 0 0 1 0 0 0 2 [2,] 2 0 1 0 1 0 0 0 0 1 0 1 .... [42,] 1 0 3 2 3 0 0 0 0 0 2 54 [43,] 1 0 5 1 0 1 0 0 0 0 0 6

It was this the method that you suggested me?

But when I run mFD::alpha.fd.multidim(), I can't, because it appears the warning message:

Error in mFD::alpha.fd.multidim(sp_faxes_coord = sp_faxes_coord_sps[, : Mismatch between names in speciesweight and speciescoordinates matrix. Please check.

When it says 'speciesweight' is about the 'baskets_fruits_weights' matrix, and 'speciescoordinates' is sp_faxes_coord, right? What should be the mismatch?

I didn't try the other functions ( background.plot() and fric.plot()) yet but I will try.

Thanks for your help! I think this new package wonderfull for FD, but i'm still understanding.

Cheers!

Alexander Arévalo. PhD Candidate in Biology-Ecology (INPA)

CmlMagneville commented 2 years ago

Hi Alexander,

If your lowest quality metric is for 3 functional axis, then yes it is ok (otherwise as I said earlier, you have to chose between working in a space with a lower quality but being able to compute indices for more assemblages and less functional axes but more assemblages on which indices can be computed). Based on what you said I guess pcoa_3D is great to work with.

To gather your assemblages into bigger groups, I suggested using these bigger groups as rows in the assemblage * species matrix instead of having one row = one assemblage. I don't think you did that if I've understood clearly. With the mFD dataset, if I want to gather assemblages (baskets) into bigger groups for instance gathering baskets 1 from 5 in a group and baskets 6 to 10 in another group, then I will have 2 rows instead of 10.

The assemblage species matrix must have row names which are the names of the assemblages and column names which are the names of the species. Here, the message error says that the names of the species in the assemblage species matrix are not the same than the ones in the sp_faxes_coord. I don't know why it happened, check that the column names of your assemblages * species matrix are the same (and same order) as the row names of sp_faxes_coord. I guess that re-running the analysis step by step will remove the error message if you follow the general workflow.

Hope it helps!

Camille