Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe useful functions from syncomR #7

Open
microsud opened this issue Nov 21, 2021 · 14 comments
Open

Maybe useful functions from syncomR #7

microsud opened this issue Nov 21, 2021 · 14 comments
Assignees

Comments

@microsud
Copy link
Member

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
Copy link
Member

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
Copy link
Member

@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
Copy link
Member

@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
Copy link
Member Author

microsud commented Dec 7, 2021

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
Copy link
Member Author

microsud commented Dec 7, 2021

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
Copy link
Member

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
Copy link
Member Author

microsud commented Dec 7, 2021

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

@microsud
Copy link
Member Author

TSE data added to miaTime #39

@antagomir
Copy link
Member

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
Copy link
Member Author

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

@antagomir
Copy link
Member

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

@antagomir
Copy link
Member

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 antagomir assigned Daenarys8 and unassigned YagmurSimsekk Jul 9, 2024
@antagomir
Copy link
Member

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

@antagomir
Copy link
Member

@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..?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants