-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmiaTime.Rmd
executable file
·117 lines (87 loc) · 2.52 KB
/
miaTime.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
title: "miaTime: Microbiome Time Series Analysis"
date: "`r Sys.Date()`"
package:
miaTime
output:
BiocStyle::html_document:
fig_height: 7
fig_width: 10
toc: yes
toc_depth: 2
number_sections: true
vignette: >
%\VignetteIndexEntry{miaTime}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
```{r}
#| label: setup
#| include: false
library(knitr)
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
cache = TRUE
)
```
## Introduction
`miaTime` is a package in the `r BiocStyle::Biocpkg("mia")` family, providing
tools for time series manipulation using the
`r BiocStyle::Biocpkg("TreeSummarizedExperiment")` data container.
## Installation
`miaTime` is hosted on Bioconductor, and can be installed using via
`BiocManager`.
```{r}
#| label: install
#| eval: false
BiocManager::install("miaTime")
```
## Load the package
Once installed, `miaTime` is made available in the usual way.
```{r}
#| label: load_package
library(miaTime)
```
## Divergence between time points
`miaTime` offers functions to calculate divergences. These can be calculated
based on samples and their corresponding base time point, e.g., first sample of
time series. Moreover, divergences can be calculated in rolling basis meaning
that a sample is compared to previous ith sample.
Divergences can be calculated with `get*Divergence()` functions. In the example
below, for each subject, we calculate the divergence of their samples by
comparing them to the first time point.
```{r}
#| label: base_divergence
data(hitchip1006)
tse <- hitchip1006
res <- getBaselineDivergence(
tse, time.col = "time", group = "sample", name = "baseline")
res |> head()
```
A more convenient and preferred approach is to store the values directly in
`colData` using the `get*Divergence()` functions. In the example below, we
calculate stepwise divergences with a lag of 1, meaning that for each sample,
the divergence is calculated by comparing it to the previous time point for
the same subject.
```{r}
#| label: time_divergence
tse <- addStepwiseDivergence(tse, time.col = "time")
colData(tse)
```
## Visualize time series
We can visualize time series data with `r BiocStyle::Biocpkg("miaViz")`. Below,
we visualize 2 most abundant taxa.
```{r}
#| label: plot_series
library(miaViz)
p <- plotSeries(tse, x = "time", y = getTop(tse, 5))
p
```
See [articles](https://microbiome.github.io/miaTime/articles/) for more detailed
example workflows.
## Session info
```{r}
#| label: session_info
sessionInfo()
```