microeco icon indicating copy to clipboard operation
microeco copied to clipboard

trans_beta class

Open patrickDsal opened this issue 2 years ago • 15 comments

hey,

I have two issues regarding trans_beta class. In the newest version of microeco, I noticed that the cal_manova_set function doesn't produce the correct outcome anymore. I switched back to version 0.7.0 and it works again. Potentially something to do with the adonis/adonis2 packages?

Example: In 0.7.0: t1$cal_manova(cal_manova_set = "Variable1+Variable2+Variable3 " , permutations = 999) Results in: t1$res_manova$aov.tab Terms added sequentially (first to last)

                    Df SumsOfSqs           MeanSqs F.Model      R2 Pr(>F)    

Variable1 3 0.3658 0.12195 1.3083 0.02674 0.1709
Variable2 3 1.2826 0.42754 4.5868 0.09375 0.0001 *** Variable3 17 3.4576 0.20339 2.1820 0.25272 0.0001 *** Residuals 92 8.5753 0.09321 0.62679
Total 115 13.6813 1.00000

In 0.7.5 t1$cal_manova(cal_manova_set = "Variable1+Variable2+Variable3 " , permutations = 999) Results in: t1$res_manova$aov.tab NULL ; since results are now stored in t1$res_manova... However, t1$res_manova just produces a result of the group that was specified in trans_beta class at the beginning

Variable2 3 1.2826 0.42754 4.5868 0.09375 0.0001 ***

...

The second issue is a request. Is it possible to just plot group centroids in plot_ordination? Sometimes I have too many samples/data points and the plots get messy !?

patrickDsal avatar Apr 29 '22 13:04 patrickDsal

Hi @patrickDsal

Yes. You are correct. This is a bug. Thank you very much. I overlooked the ifelse logic in the function, leading to a cover of other option when using cal_manova_set. I have fixed this. You can reinstall the development v0.8.0 in the github or use a temporary solution by adding cal_manova_all = FALSE, like: t1$cal_manova(cal_manova_set = "Group + Type", cal_manova_all = FALSE) From v0.7.5, the adonis2 is used instead of adonis as the adonis in vegan will be deprecated in the further release. So I suggest you use the development v0.8 in github, which will be released in the coming several days. Now, in the function cal_manova, I choose to use one parameter manova_all to control overall test or paired test; manova_set for specified set and this parameter has the priority to run. This can make the function easier to use. If you have better suggestion, please feel free to tell me. Thanks again for your finding on this bug.

Best Chi

ChiLiubio avatar Apr 30 '22 05:04 ChiLiubio

I will try to find out the solution on your suggestion of ploting group centroids for ordination.

ChiLiubio avatar Apr 30 '22 05:04 ChiLiubio

Thank you very much :)

patrickDsal avatar May 01 '22 13:05 patrickDsal

Hey, sry me again! Even with 0.8.0 it's not working. I switched back to an older version of the package but that's now completely messed up. When I try to look at the manova output, R goes into a loop and crashes :(

patrickDsal avatar May 06 '22 16:05 patrickDsal

Could you please send me your microtable dataset and your script to repeat this?

ChiLiubio avatar May 07 '22 00:05 ChiLiubio

It's fixed. It was my mistake! Apologies!

However, I noticed something else in the trans_env class. t1$cal_ordination(method = "dbRDA", use_measure = "bray") --> this line works

t1$trans_ordination(adjust_arrow_length = TRUE) produces an error: Error in ref[, 1]^2 : non-numeric argument to binary operator --> I checked my env file. All data is numeric so that's not it.

If I run: t1$trans_ordination() --> it works but then when I plot the graph via t1$plot_ordination(plot_color = "Group") --> the plot shows only the env arrows but not the samples.

Maybe it's my bad again and I am missing something...

In addition: Is it possible to include the R2 value for each tested env variable in order to determine it's impact value?

patrickDsal avatar May 07 '22 13:05 patrickDsal

Hi. Please use cal_ordination_envsquare function for the R2. If t1$trans_ordination(adjust_arrow_length = TRUE) still produces an error, please save your t1 object and send it to me to check it.

ChiLiubio avatar May 08 '22 02:05 ChiLiubio

Hi! Zip file is attached... RDA is working fine. But dbRDA produces the error mentioned above.

dbRDA_problem.zip

patrickDsal avatar May 09 '22 12:05 patrickDsal

Weird! I did not find the error when run t1$trans_ordination(adjust_arrow_length = TRUE, min_perc_env = 0.1, max_perc_env = 1) and the following ploting.

ChiLiubio avatar May 09 '22 14:05 ChiLiubio

I reinstalled R and updated all packages, still the same!

Error in ref[, 1]^2 : non-numeric argument to binary operator In addition: Warning message: In scrs$biplot <- scores(res_ordination, choices = c(1, 2), "bp", : Coercing LHS to a list

patrickDsal avatar May 09 '22 14:05 patrickDsal

Hi Patrick,

I came across then same issue, have you managed to find a solution it?

I get this:

t1$cal_ordination(method = "dbRDA", use_measure = "wei_unifrac") Use wei_unifrac in dataset$beta_diversity for dbRDA ... The original ordination result is stored in object$res_ordination ... The R2 is stored in object$res_ordination_R2 ... The terms anova result is stored in object$res_ordination_terms ... The axis anova result is stored in object$res_ordination_axis ... t1$trans_ordination(adjust_arrow_length = TRUE) The result list is stored in object$res_ordination_trans ... Warning messages: 1: In scrs$biplot <- scores(res_ordination, choices = c(1, 2), "bp", : Coercing LHS to a list 2: In Ops.factor(ref[, 1], 2) : ‘^’ not meaningful for factors 3: In Ops.factor(ref[, 2], 2) : ‘^’ not meaningful for factors

Cheers, Natali

NataliHB avatar Aug 03 '22 03:08 NataliHB

Hey Natali,

 

sry, but I did not.

I ended up writing my own script for dbRDA using the vegan package.

 

Best

Patrick

   

Gesendet: Mittwoch, 03. August 2022 um 05:55 Uhr Von: "NataliHB" @.> An: "ChiLiubio/microeco" @.> Cc: "patrickDsal" @.>, "Mention" @.> Betreff: Re: [ChiLiubio/microeco] trans_beta class (Issue #103)

 

Hi Patrick,

I came across then same issue, have you managed to find a solution it?

Cheers, Natali

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

patrickDsal avatar Aug 03 '22 10:08 patrickDsal

Thank you Patrick, I think I'll vegan as well.

NataliHB avatar Aug 03 '22 13:08 NataliHB

I will try to find out the solution on your suggestion of ploting group centroids for ordination.

Hi, Is there any update about this?

Thanks

ilksentpc avatar Jul 08 '24 17:07 ilksentpc

Hi. Do you mean only plotting the group centroids instead of sample points? If so, we can first merge samples into one for each group and then perform the following analysis.

d1 <- dataset$merge_samples("Type")

ChiLiubio avatar Jul 09 '24 02:07 ChiLiubio