microbiome / mia

Microbiome analysis
https://microbiome.github.io/mia/
Artistic License 2.0
48 stars 28 forks source link

issue with estimateDiversity #334

Closed marcelladane closed 2 months ago

marcelladane commented 1 year ago

Hello, I previously ran mia (version 1.2.7) and had no issue when running the function estimateDiversity from a tse construct using biom file. Note that I followed the tutorial https://microbiome.github.io/OMA/containers.html#s-workflow (session 2.3.2.1), and I used my own files and also the exact files from the tutorial, to be sure wasn't any flaw on my own data.

Now I updated to the latest version of mia (1.7.4) and when I try to run the same function, I got the following error:

Error in method(object) : 
The object should include at least 4 columns:
nodeLab, nodeLab_alias, nodeNum, isLeaf 
The nodeLab_alias column should be character 
The nodeNum column should be numeric 
The isLeaf column should be logical

but when I check the links , they are ok:

rowLinks(tse)
LinkDataFrame with 151 rows and 5 columns
        nodeLab   nodeNum nodeLab_alias    isLeaf   whichTree
    <character> <integer>   <character> <logical> <character>
1       1726470        34      alias_34      TRUE       phylo
2       1726471        39      alias_39      TRUE       phylo
3      17264731        14      alias_14      TRUE       phylo
4      17264726        30      alias_30      TRUE       phylo
5       1726472         9       alias_9      TRUE       phylo
...         ...       ...           ...       ...         ...

Can you please help me? Thank you. Note, my R version is "R version 4.1.2 (2021-11-01)"

antagomir commented 1 year ago

I am not sure where you need rowLinks here.

Can you show the output of tse (it prints summary info for your TreeSE data object).

You could also show the command that gives the error, then it is easier to comment.

marcelladane commented 1 year ago

ok, here is the output of tse

class: TreeSummarizedExperiment 
dim: 151 27 
metadata(0):
assays(3): counts relabundance clr
rownames(151): 1726470 1726471 ... 17264756 17264757
rowData names(6): Kingdom Phylum ... Family Genus
colnames(27): A110 A12 ... A35 A38
colData names(4): patient_status cohort patient_status_vs_cohort sample_name
reducedDimNames(0):
mainExpName: NULL
altExpNames(0):
rowLinks: a LinkDataFrame (151 rows)
rowTree: 1 phylo tree(s) (151 leaves)
colLinks: NULL
colTree: NULL

Then I ran transformation tse <- transformCounts(tse, method = "relabundance")

After that, when moving to alpha diversity I ran:

{r alpha diversity}
index <- c("shannon","gini_simpson","inverse_simpson", "coverage", "fisher", "faith",  "log_modulo_skewness")
tse <- estimateDiversity(tse, index = index)

And got the error:

Error in method(object) : 
The object should include at least 4 columns:
nodeLab, nodeLab_alias, nodeNum, isLeaf 
The nodeLab_alias column should be character 
The nodeNum column should be numeric 
The isLeaf column should be logical
antagomir commented 1 year ago

Ok. Can you try without Faith index, and then only with Faith index? I am wondering if Faith is causing the error.

Do you have a rowTree?

marcelladane commented 1 year ago

You were correct. It was the Faith index. Can you please explain why it caused this error? I am curious now. =)

antagomir commented 1 year ago

I do not know yet. Might depend on the rowTree and it includes some error. The data has to be cleaned up first.

Could you post the output of rowTree(tse) and also the command that you used to add the tree in the TreeSE object?

antagomir commented 1 year ago

Faith index is the only alpha diversity index (from your list) that utilizes the tree information.

marcelladane commented 1 year ago

Gonna do after the holidays. =) Happy holidays.

antagomir commented 6 months ago

Make sure that this works - if the object does not have tree, then Faith diversity should not be calculated. A warning can be thrown instead.