-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
55 lines (43 loc) · 1.07 KB
/
index.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
---
title: "Virome..."
author: "Author Names"
date: "2019-03-29"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
library(tidyverse)
```
## Import
```{r}
phage_counts <- read_csv("data/phage_counts.csv")
```
## Summarise
```{r}
phage_counts <- phage_counts %>%
group_by(subject, arm, timepoint, parent_tax_id) %>%
count()
```
Number of unique taxa per patient and timepoint.
```{r}
tax_per_subj <- phage_counts %>%
group_by(subject, arm, timepoint) %>%
summarise(n_tax = n_distinct(parent_tax_id))
```
Average number of taxa per arm and timepoint
```{r}
tax_per_subj %>%
group_by(arm, timepoint) %>%
summarise(n_tax = mean(n_tax))
```
Plot mean number of taxa per arm and timepoint:
```{r}
pd <- position_dodge(0.1)
tax_per_subj %>%
ggplot(aes(x = timepoint, y = n_tax, color = arm)) +
stat_summary(fun.data = mean_sdl, fun.args = list(mult = 1), position = pd) +
stat_summary(fun.y = mean, geom = "line", position = pd) +
labs(x = "Time, months", y = "Number of parent taxa")
```