-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathScatter plot_from_funguild.r
33 lines (27 loc) · 1.44 KB
/
Scatter plot_from_funguild.r
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
library(tidyverse)
library (dplyr)
setwd("~/R/Analysis/1_Test") # Change
DESIGN <- read.csv("experimental_design.csv",header=T) # Change
setwd("~/R/Analysis/1_Test/ITS") # Change
funguild.table <- read.csv(file="rarefied_ASV_table_funguild.guild.csv",row.names = 1)
ASV <- funguild.table [,1:(ncol(funguild.table)-10)]
guild <- funguild.table [,(ncol(funguild.table)-9):ncol(funguild.table)]
percent <- ASV / mean(colSums(ASV)) *100
aggregated <- aggregate(percent, by=list(guild$Guild),FUN = sum,na.rm=F) # Change "Guild" --> "Trophic.Mode"if needed
row.names(aggregated)<-aggregated[,1]
aggregated <- aggregated[,-1]
aggregated <- data.frame(aggregated)
rows <- grep ("Ectomycorrhizal", rownames (aggregated)) # Change "Ectomycorrhizal" if needed
subset <- aggregated[rows,]
subset.t <- t(subset)
data <- data.frame(rowSums (subset.t))
colnames (data) [1] <- "Ectomycorrhizal" # Change "Ectomycorrhizal" if needed
data <- cbind (data, DESIGN)
ggplot(data)+
geom_point(aes(x=Factor1, y=Ectomycorrhizal, color=Group))+ # Change
geom_smooth(method="lm", aes(x=Factor1, y=Ectomycorrhizal, color=Group))+ # Change
# scale_fill_manual(values = c("#C77CFF","#7CAE00","#00BFC4","#F8766D"))+ # if you want to change the colors
theme_classic()+
theme(text=element_text(size=14,color="black"),axis.text=element_text(size=12,color="black"))+
# labs (y="",x="") # if you want to change the axis titles
ggsave("Plot_Ectomycorrhizal.png")