microbiome / mia

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

getCrossAssociation outputs #651

Open antagomir opened 2 days ago

antagomir commented 2 days ago

This issues suggests finding a way to provide user friendly output tables.

Let us run cross-association:

data(HintikkaXOData)
mae <- HintikkaXOData
mae[[1]] <- mae[[1]][1:20, 1:10]
mae[[2]] <- mae[[2]][1:20, 1:10]
mae[[1]] <- mae[[1]][rowSds(assay(mae[[1]])) > 0, ]
mae[[1]] <- transformAssay(mae[[1]], method = "rclr")
result <- getCrossAssociation(mae, method = "pearson", assay.type2 = "nmr", test.signif=TRUE)
head(result, 5)

This generates the following table:

               Var1     Var2         cor         pval        p_adj

CVJT01000011.50.2173 Butyrate -0.15394918 6.711047e-01 0.9882135995 AYSG01000002.292.2076 Butyrate -0.17674170 6.252300e-01 0.9882135995 CCPS01000022.154.1916 Butyrate 0.43730668 2.062956e-01 0.9882135995 EU622687.1.1587 Butyrate 0.06046832 8.682081e-01 0.9882135995 KY646024.1.1591 Butyrate 0.96598301 5.622406e-06 0.0002783091 ...

Now, this is long format of the associations. Also wide format is possible with mode="matrix". However, that could be obtained separately for the different columns only.

When preparing material for publication, we sometimes want to show the effect size and FDR in the same table, like effect sizes first, then FDR in parentheses:

  X                    Y       

A 1.5 (0.05) 0.9 (0.001) B 0 (0.8) 0.3 (0.1)

Ideally, there is function (already in some package?) that allows one to merge the effect sizes and p-values into a single table presentation like this? If not, we could think about providing such utility. Simple but pragmatic. It probably should be an independent function, rather than one more option in the already complex getCrossAssociation function.

TuomasBorman commented 1 day ago

If there is existing package that works similarly to stats::cor (takes matrix as input and outputs similar output), then this should be already possible with association.fun parameter --> should be checked

res <- getCrossAssociation(mae, method = "pearson", assay.type2 = "nmr", association.fun = stats::cor)