-
Notifications
You must be signed in to change notification settings - Fork 0
/
12- Taxonomic abundance.Rmd
75 lines (64 loc) · 2.34 KB
/
12- Taxonomic abundance.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
---
title: "Taxonomic abundance"
author: "Marwa Tawfik"
date: "07 07 2023"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
# load libraries
library("microeco")
library("file2meco")
library("ggplot2")
```
```{r}
ps.prev <- readRDS("phyobjects/STEP 15/ps.prev.f.rds")
dataset <- phyloseq2meco(ps.prev)
#ps.prev.intes <- readRDS("phyobjects/STEP 15/ps.prev.intes.f.rds")
#dataset.intes <- phyloseq2meco(ps.prev.intes)
```
```{r}
# PHYLUM
t1 <- trans_abund$new(dataset = dataset, taxrank = "Phylum")
t1$plot_bar(facet = c("Region", "Regime"),
others_color = "black",
order_x = names(sort(unlist(dataset$taxa_abund$Phylum["k__Bacteria|p__Firmicutes", ])))) +
theme(axis.text.x = element_blank()) +
labs(x = "Samples")
# ggsave("figures/fig3a.tiff", height = 4, width = 15, units = "in", dpi = 300, compression = "lzw")
```
```{r}
t1 <- trans_abund$new(dataset = dataset, taxrank = "Phylum", groupmean = "Region_Regime")
t1$plot_bar(xtext_angle = 90,
others_color = "black")
#ggsave("figures/fig3b.tiff", height = 4, width = 15, units = "in", dpi = 300, compression = "lzw")
```
```{r}
# GENUS (family when genus NA)
# SELECTING those which have NA to replace them
na.genus <- is.na(tax_table(ps.prev)[,"Genus"])
# Replace them with full name consisting of Family and Genus
tax_table(ps.prev)[na.genus][,"Genus"] <- paste(tax_table(ps.prev)[na.genus][,"Family"],
tax_table(ps.prev)[na.genus][,"Genus"])
dataset <- phyloseq2meco(ps.prev)
```
```{r}
t1 <- trans_abund$new(dataset = dataset, taxrank = "Genus", ntaxa = 20)
t1$plot_bar(facet = c("Region", "Regime"),
others_color = "black",
order_x = names(sort(unlist(dataset$taxa_abund$Genus["k__Bacteria|p__Firmicutes|c__Clostridia|o__Oscillospirales|f__Ruminococcaceae|g__Ruminococcaceae NA", ])))) +
theme(axis.text.x = element_blank()) +
labs(x = "Samples")
#ggsave("figures/fig4a.tiff", height = 4, width = 15, units = "in", dpi = 300, compression = "lzw")
```
```{r}
t1 <- trans_abund$new(dataset = dataset, taxrank = "Genus", groupmean = "Region_Regime", ntaxa = 20)
t1$plot_bar(xtext_angle = 90,
others_color = "black")
ggsave("figures/fig4b.tiff", height = 4, width = 15, units = "in", dpi = 300, compression = "lzw")
```
```{r}
sessionInfo()
```