KaiHsiangHu / iNEXT.3D

Interpolation and Extrapolation for three dimensions of biodiversity
0 stars 2 forks source link

Doubt - AO3D() parameters #2

Closed FelipeMSD closed 1 year ago

FelipeMSD commented 1 year ago

Dear all,

I am trying to run the following command to calculate PD (q=2) for just one sample (df = vector [1:1264]):

iNEXT.3D::AO3D(data=df, diversity = "PD", q = c(2), datatype = "abundance", nboot = 5, conf = 0.95, nT = NULL, method = c("Asymptotic"), PDtree = pruned_tree, PDreftime = NULL, PDtype = "meanPD")

However I keep having the following message error "Error in est[, i] : incorrect number of dimensions", that does not happen when I use command:

iNEXT.3D::estimate3D(data=df_deep, diversity = "PD", q = 2, datatype = "abundance", base = "coverage", level = 0.99, nboot = 5, conf = 0.95, PDtree = pruned_tree, PDreftime = NULL, PDtype = "meanPD")

Thank you very much in advance for your attention, Felipe

KaiHsiangHu commented 1 year ago

Dear Felipe,

We are so glad and appreciate about your valuable advice. I have modified the error which comes from the 'AO3D' because of the use of 'sapply' when length of order 'q' is one. Please re-download the package 'iNEXT.3D' form my github or Anne Chao's.

Concerning to your questions:

  1. Yes, it happens when q is only a specified value. Now it has no problem.

  2. default 'q=seq(0, 2, 0.2)' means it will compute diversity for q = 0, 0.2, 0.4, 0.6..., 1, 1.2, ...., 1.8, 2. When q approaches zero, it will give more weight to rare species. When q approaches two (or large), it will give more weight to abundant species. The reason why we define default as 'q=seq(0, 2, 0.2)' is that we can use the output from 'AO3D' to match 'ggAO3D' which visualize the q-profile. (by ggplot)

  3. If you want to compute asymptotic PD value, then you can use 'AO3D' to compute asymptotic PD value with q = 2, now. Another suggestions is that you can use 'iNEXT3D' and 'ggiNEXT3D' to visualize the rarefaction and extrapolation of phylogenetic diversity with q = 2.

Thank you for your support about our lab's developed software. Best regards K.-H. Hu

FelipeMSD commented 1 year ago

Dear Dr. Hu,

Firstly, thank you very much for your prompt response! I have downloaded the package again but the problem persists... Do you know if there is something I can do to check whether I downloaded the new version without the error? I used remotes::install_github("KaiHsiangHu/iNEXT.3D")

KaiHsiangHu commented 1 year ago

Dear Felipe,

Can you try the following code to see whether there are still an error?

data(dunes)
data <- dunes$data
tree <- dunes$tree
out2 <- AO3D(data, diversity = 'PD', q = 2, datatype = "abundance", nboot = 30, PDtree = tree)
out2

If yes, then I think the version still un-updated.

I usually use the following code to update package after I delete old version: (I think it is the same as yours)

library(devtools)
install_github('KaiHsiangHu/iNEXT.3D')    ## And then press "Enter" to ignore other packages updated

If the package is the newest, then it will show

Skipping install of 'iNEXT.3D' from a github remote, the SHA1 (f3b6f80a) has not changed since last install. Use force = TRUE to force installation

Please try it again, thanks.
Hope to hear good news from you.

Best regards K.-H. Hu

FelipeMSD commented 1 year ago

Dear Dr. Hu,

I ran this code an it worked... I'll try few more tests with my data to see what's going on.

FelipeMSD commented 1 year ago

Now it's working :)

Thank you very much!

FelipeMSD commented 1 year ago

Dear Kai-Hsiang,

I have managed to use iNEXT.3D to calculate the phylogenetic diversity (qPD with q=2) of my microbiome samples after trimming, removing host reads and removing very low abundant taxa (<0.01%) and as it seems there is a negative correlation between the log10(sample depth before alpha diversity calculation) and qPD (plot below), people are arguing the it would be better for me to just rarefy my data instead of using the asymptotic method. What is your view about it? Because I understand the asymptotic value should overcome the biases created by just rarefying, right? Note: As I’m working with metagenomic data, “sample depth” here is the number of reads per sample.

[cid:CA9676D1-30DB-448F-A67B-80710C6D9139]

    Spearman's rank correlation rho

data: x$logP and alpha_matrix_PD_all$qPD S = 230752406, p-value < 2.2e-16 alternative hypothesis: true rho is not equal to 0 sample estimates: rho -0.3358459

Thank you very much in advance for your attention.

Kind regards, Felipe

On 20 Feb 2023, at 17:49, KaiHsiangHu @.**@.>> wrote:

Dear Felipe,

Can you try the following code to see whether there are still an error?

data(dunes) data <- dunes$data tree <- dunes$tree out2 <- AO3D(data, diversity = 'PD', q = 2, datatype = "abundance", nboot = 30, PDtree = tree) out2

If yes, then I think the version still un-updated.

I usually use the following code to update package after I delete old version: (I think it is the same as yours)

library(devtools) install_github('KaiHsiangHu/iNEXT.3D') ## And then press "Enter" to ignore other packages updated

If the package is the newest, then it will show

Skipping install of 'iNEXT.3D' from a github remote, the SHA1 (f3b6f80https://urldefense.com/v3/__https://github.com/KaiHsiangHu/iNEXT.3D/commit/f3b6f80ac2396c77925a6aff60c90dcfa2ae9a5f__;!!D9dNQwwGXtA!TssRj9Oc0ChZNtepcaRpVENANcZ7wQKuwZR2XzRhCv9SM5iYEDM1bLfjiSXd88_48BCxkHeXNSzeaCz2ZuZl3fnXrwx6$) has not changed since last install. Use force = TRUE to force installation

Please try it again, thanks. Hope to hear good news from you.

Best regards K.-H. Hu

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/KaiHsiangHu/iNEXT.3D/issues/2*issuecomment-1437304734__;Iw!!D9dNQwwGXtA!TssRj9Oc0ChZNtepcaRpVENANcZ7wQKuwZR2XzRhCv9SM5iYEDM1bLfjiSXd88_48BCxkHeXNSzeaCz2ZuZl3aqKz56k$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AWBK35JZGAFUC333YWHIPWLWYOOBBANCNFSM6AAAAAAVBWELOI__;!!D9dNQwwGXtA!TssRj9Oc0ChZNtepcaRpVENANcZ7wQKuwZR2XzRhCv9SM5iYEDM1bLfjiSXd88_48BCxkHeXNSzeaCz2ZuZl3bfFUFsI$. You are receiving this because you authored the thread.Message ID: @.***>

KaiHsiangHu commented 1 year ago

Dear Felipe,

In my opinion, I think you can use asymptotic phylogenetic diversity with order q = 2.  Because hill phylogenetic diversity with order q = 2 focus on the abundant species which usually appears in the sampling data, the asymptotic diversity with order q = 2 is nearly unbiased estimator in statistic inference. 

Please refer to paper: http://chao.stat.nthu.edu.tw/wordpress/paper/102.pdf

If you rarefy the reference sample to a small sample size, I think the difference between multiple assemblages will decrease.  It may cause the Spearman's rank correlation test insignificant.

Thus, I prefer extrapolate the data than rarefy. You're right!

If you want to extrapolate the data to a specified sample coverage except 100%, you can use the function 'estimate3D' in package 'iNEXT.3D". ('asymptotic diversity' means diversity under sample coverage equal to 100%)

I think there is no problem to use the asymptotic diversity for testing. It is good to have significant test conclusion!!

I'm more curious that "sample depth" should be negative correlation to "qPD' or positive correlation in your domain knowledge, ha ha.

Thank you for your support about our lab's developed software. Best regards

K-H Hu

FelipeMSD commented 1 year ago

Dear Kai-Hsiang,

Thank you very much for your prompt response. I’ll take this into consideration and explain them on how coverage should provides better resolution in terms of alpha diversity.

Let me think on why this correlation might be happening...

Best regards, Felipe

On 1 Mar 2023, at 16:10, KaiHsiangHu @.**@.>> wrote:

Dear Felipe,

In my opinion, I think you can use asymptotic phylogenetic diversity with order q = 2. Because hill phylogenetic diversity with order q = 2 focus on the abundant species which usually appears in the sampling data, the asymptotic diversity with order q = 2 is nearly unbiased estimator in statistic inference.

Please refer to paper: http://chao.stat.nthu.edu.tw/wordpress/paper/102.pdfhttps://urldefense.com/v3/__http://chao.stat.nthu.edu.tw/wordpress/paper/102.pdf__;!!D9dNQwwGXtA!WRF8-OpRtMkPaM3QSbDYQzrIIz86eewxZLHi-v3pBECJduGFVoHgguM5OzzegovDs-a_MAqV2xReR9g7_0vazu_M6qpC$

If you rarefy the reference sample to a small sample size, I think the difference between multiple assemblages will decrease. It may cause the Spearman's rank correlation test insignificant.

Thus, I prefer extrapolate the data than rarefy. You're right!

If you want to extrapolate the data to a specified sample coverage except 100%, you can use the function 'estimate3D' in package 'iNEXT.3D". ('asymptotic diversity' means diversity under sample coverage equal to 100%)

I think there is no problem to use the asymptotic diversity for testing. It is good to have significant test conclusion!!

I'm more curious that "sample depth" should be negative correlation to "qPD' or positive correlation in your domain knowledge, ha ha.

Thank you for your support about our lab's developed software. Best regards

K-H Hu

— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/KaiHsiangHu/iNEXT.3D/issues/2*issuecomment-1450310833__;Iw!!D9dNQwwGXtA!WRF8-OpRtMkPaM3QSbDYQzrIIz86eewxZLHi-v3pBECJduGFVoHgguM5OzzegovDs-a_MAqV2xReR9g7_0vazsV6lYnv$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AWBK35P5ZAFBEBXQZV347F3WZ5RGFANCNFSM6AAAAAAVBWELOI__;!!D9dNQwwGXtA!WRF8-OpRtMkPaM3QSbDYQzrIIz86eewxZLHi-v3pBECJduGFVoHgguM5OzzegovDs-a_MAqV2xReR9g7_0vazvztHz9v$. You are receiving this because you modified the open/close state.Message ID: @.***>