microbiome / miaTime

Microbiome time series analysis
https://microbiome.github.io/miaTime/
Artistic License 2.0
5 stars 4 forks source link

Maybe useful functions from syncomR #7

Open microsud opened 2 years ago

microsud commented 2 years ago

I created some functions to analyse in-vitro synthetic communities. https://github.com/microsud/syncomR. These include some functions for longitudinal data analysis and visualization. Codes (not the best skills here) and data are tailored and bundled as R pkg for my manuscript (under review). Some of these functions may be expanded to miaTime.

antagomir commented 2 years ago

Whoever is the fastest, could try and make a PR out of the relevant ones. @microsud you are the best expert with these, if it is possible to make for instance one issue (and subsequent PR) per relevant functionality, including the details, that might help to keep things organized.

YagmurSimsekk commented 2 years ago

@microsud Thank you so much! I have found some functionalities that can be used for miaTime, but there is a problem occurring due to dependencies in the package. ERROR: dependency 'edgeR' is not available for package 'syncomR' That's why I couldn't run the examples but taxa_time_table ,temporal_diversity , temporal_turnover functions can be suitable.

antagomir commented 2 years ago

@microsud could you propose one or two functions to start with (but no visualization functions at this stage)? We could have a closer look on how to add those to miaTime.

microsud commented 2 years ago

Yes. we can start with https://github.com/microsud/syncomR/blob/master/R/short_term_change.R without the plotting step. This function essentially calculates the change in abundance over time for a microbe by abundancet2/ abundancet1 . I think it can be further improved as we start building this. ref: Macroecological dynamics of gut microbiota

microsud commented 2 years ago

edgeR

You can try installing these before installing syncomR

if (!requireNamespace("BiocManager", quietly = TRUE))
    install.packages("BiocManager")

BiocManager::install("edgeR")

# Seqtime 
library(devtools)  
install_github("hallucigenia-sparsa/seqtime")  
library(seqtime)  

I think converting the test data in synComR into miaTime test data would be useful, specifically the SyncomFiltData as phyloseq object can be easily converted to TreeSE. It has species-level abundances in artificial in-vitro gut sampled ~20 days with ~3samples/day with various perturbations (article under review).

antagomir commented 2 years ago

Very good for the demo data. Perhaps a separate issue could be opened about that one?

The abundance2/abundance1 thing: how about calculating this for all taxa at once? Implementation-wise it might be almost easier than doing it for a single taxa.

microsud commented 2 years ago

The function returns it for all taxa at once. Improvements to speed and code can be made for speed and efficiency.

microsud commented 2 years ago

TSE data added to miaTime #39

antagomir commented 2 years ago

The functions still to be added, if I collect correctly from the thread above.

@YagmurSimsekk do you have any additional comments regarding the new functions if you had a look already?

microsud commented 2 years ago

Yup the function is not added. Once I have the codes ready, will create a new PR.

antagomir commented 2 years ago

Great, there seemed to be potentially multiple relevant functions. Let us keep in mind! We can keep this open until that new PR.

antagomir commented 2 years ago

SyncomR has three options. Compared to starting Composition i.e. divergence, compared to each consecutive time point i.e. succession and compared to last sample i.e. convergence.

antagomir commented 2 months ago

@Daenarys8 you could see if some of the syncomR functions could be translated to miaTime or miaViz

antagomir commented 1 month ago

@Daenarys8 if you work on short_term_change, I have the following suggestions:

We would probably like to have both x-y and x/y differences available for time series. Both might be needed.

These are also sufficient. The logarithmic versions could be derived from them and in normally expected use cases one will not do log(x)/log(y), we only need x-y, x/y ,log(x)-log(y).

However, x/y = exp(log(x/y)) = exp(log(x) - log(y)). This can be calculated for logarithmized data with the "-" operation:

shortTermChange(tse, assay.type="counts") -> x-y shortTermChange(tse, assay.type="log") -> log(x) - log(y) -> exp() -> x/y

So perhaps we could start by just having this function with the "-" operation because everything else that is usually needed can be derived from it?

First, try to check if such functionality is already available in some R package, there are really many R packages for time series and we would like to avoid overlapping work. I think there are R functions for calculating step-wise differences for univariate time series. Those could be used.

The planned functionality is univariate, but very closely related to the multivariate functions getStepwiseDivergence() and getBaselineDivergence() in miaTime.

In what data element you were planning to store the output from this function? colData, altExp, assay..?