microbiome / miaTime

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

Calculate beta diversity between samples at the interval of n time steps #13

Closed antagomir closed 2 years ago

antagomir commented 2 years ago

Time series analyses often measure dissimilarity (beta distance) between consecutive time steps, within n=1, 2, 3, or more steps

In this case, beta diversity needs to be calculated between all the given sample, and the other sample that precedes it n steps in time. We are here referring to time steps because the interval is not always uniform.

Suggestion let's implement a function that calculates beta diversity in time series between samples that have time difference of n time steps. Also calculate information of the difference in actual time between those same time steps.

Return the result as a data.frame; default field names could be timedivergence_n and timedifference_n where n is replaced with the time step interval (1,2,3...). The resulting dataframe has one dissimilarity per sample; and the first n samples will have NAs for obvious reason that they do not have preceding samples n steps before them in the time series.

In addition, show in the examples how that can be added to colData.

The dissimilarity calculation must have access to all beta diversity measures available in mia. Start with mia::calculateDistance, later add calculateJSD and calculateUnifrac as options if possible.

Suitable function name (to start with at least): getTimeDivergence.

antagomir commented 2 years ago

Solved by #16