microbiome / mia

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

get vs. add #535

Open antagomir opened 2 months ago

antagomir commented 2 months ago

Regarding the latest developments in addAlpha() in #460 I realized that we could also need getAlpha() as an exported function.

For instance in altExp mechanism one might like to retrieve the alpha diversity estimates from altExp but often wants store them in the main tse object where most other sample data is stored.

It would then be more clear to do obtain the values with getAlpha(altExp(tse)) and then assign them manually to colData(tse), like:

colData(tse) <- cbind(colData(tse), getAlpha(altExp(tse, "myaltexp"), index=c("shannon", "faith")))

The other option would be to do addAlpha()

indices <- c("shannon", "faith")
colData(tse) <- cbind(colData(tse), colData(addAlpha(altExp(tse, "myaltexp"), index=indices))[, indices])

or something like..

tse <- addAlpha(altExp(tse, "myaltexp"), index=indices), altexp=NULL)

I think the first option is the most clear for the user.

Essentially, this is a suggestion to reconsider that for most add* functions we would have the corresponding get* function. This is intuitive, and has clear uses at least with altExps.