当前位置:网站首页>Microbial ecological data analysis - redundancy analysis
Microbial ecological data analysis - redundancy analysis
2022-06-21 06:02:00 【Silent voice】
Microbial ecological data analysis —— Redundancy analysis
sa=read.table("NRRDA.csv",header=T,row.names=1,sep=",")
env=read.table("NRenv.csv",header=T,sep=",",row.names=1)
name <- read.table("name.csv", header=F,sep=",",colClasses=c("character","character"))# Used to generate legend , Classify the samples
library(vegan)
decorana(sa)#DCA function , Used to decide whether to RDA perhaps CCA
# If DCA Before ordering 4 The maximum of axes exceeds 4, It is more appropriate to select unimodal model for sorting . If it's less than 3, The linear model is better (Lepx & Smilauer 2003). If it's between 3-4 Between , Both unimodal model and linear model are feasible
sam=rda(sa,env,center=T,scale=T)
plot(sam,scaling=3)#plot(gts.rda,display=c("sp","bp"),scaling=3)
# display=c("sp","bp") Show species and environmental factors . If quadrat and environmental factors are displayed , It can be expressed as display=c("si","bp"), If the species 、 Quadrat and environmental factors are displayed at the same time , You can set display=c("sp","si","bp").
library(ggplot2)
new=sam$CCA
samples<-data.frame(sample=row.names(new$u),RDA1=new$u[,1],RDA2=new$u[,2])
name=name$V2# Classified documents
species<-data.frame(spece=row.names(new$v),RDA1=new$v[,1],RDA2=new$v[,2])
envi<-data.frame(en=row.names(new$biplot),RDA1=new$biplot[,1],RDA2=new$biplot[,2])
rda1 =round(sam$CCA$eig[1]/sum(sam$CCA$eig)*100,2) # First axis label , Show the degree of explanation
rda2 =round(sam$CCA$eig[2]/sum(sam$CCA$eig)*100,2) # Second axis label , Show the degree of explanation
line_x = c(0,envi[1,2],0,envi[2,2],0,envi[3,2]) # Lines and ling_g The number is the same ,envi[line_g,2]
line_x
line_y = c(0,envi[1,3],0,envi[2,3],0,envi[3,3])
line_y
line_g = c("grazing","grazing","Tot bio","Tot bio","ND","ND")
line_g
line_data = data.frame(x=line_x,y=line_y,group=line_g)
line_data
# Start redrawing RDA chart
# Fill in the sample data , Respectively by RDA1,RDA2 by X,Y Axis , Different samples are distinguished by color
ggplot(data=samples,aes(RDA1,RDA2)) + geom_point(aes(color=sample),size=2)# The data used to generate the legend is sample, No samples!, Otherwise, it will prompt an error : Aesthetics must be either length 1 or the same as the data (6): colour, x, y
#geom_point(aes(color=name),size=2
# Populate microbial species data , Different species are distinguished graphically ,seq Increase the number of shapes
+ geom_point(data=species,aes(shape=spece),size=2) + scale_shape_manual(values=seq(0,15))+
# Fill in environmental factor data , Show directly
geom_text(data=envi,aes(label=en),color="blue") +
# add to 0 Scale vertical and horizontal lines
geom_hline(yintercept=0) + geom_vline(xintercept=0)+
# Add a straight line with an arrow whose origin points to the environment factor ,size The thickness of the straight line can be adjusted
geom_line(data=line_data,aes(x=x,y=y,group=group),color="green") +
geom_segment(data=line_data,aes(x=x,y=y,xend = line_data[,1], yend = line_data[,2],group=group),color="black",size=1.5,arrow=arrow(angle=35, length=unit(0.3, "cm"))) +
# Add horizontal and vertical axis labels
labs(title="RDA Plot",x=paste("RDA1 ",rda1," %"),y=paste("RDA2 ",rda2," %")) +
# Title font formatting
#theme(text=element_text(family="serif"))+
# Remove background colors and excess gridlines
theme_bw() + theme(panel.grid=element_blank())
# Be accomplished , Save as vector graph, etc
ggsave("NRRDA2.PDF")
#RDA More detailed analysis ,
summary(sam)
# Test the significance of environmental factors (Monte Carlo permutation test)
permutest(sam,permu=999) # permu=999 Is the number of permutation cycles
ef=envfit(sam,env,permu=999)# Significance test of each environmental factor
ef
I see that many students ask questions about the imported data format , I wrote a detailed ranking analysis article again , It was posted on the official account “ When scientific research is in progress ” On , Article title :R mapping -RDA Sorting analysis , There are screenshots of data format , You can scan the QR code and pay attention to view .
边栏推荐
- BGP - route announcement and reflector (explanation + configuration command)
- Kali shortcut keys and settings
- sqli-labs25
- Error running code generator file: the server time zone value ' й ��� ʱ ��‘ is unrecognized or represents more than one time
- Improved Object Categorization and Detection Using Comparative Object Similarity
- Research and Analysis on the current situation of China's wireless charger Market and forecast report on its development prospect
- Sub-Category Optimization for Multi-View Multi-Pose Object Detection
- [Prometheus] an optimization record of Prometheus Federation
- 应用在洗衣机触摸屏中的触摸芯片
- 新零售品牌“三只松鼠”遇挫,摆脱困境的两大方法
猜你喜欢

Eth Denver conference is a Web3 foam signal? See what investors and builders say respectively

Ironocr 2022.1.0 supports 127 national languages

Account1 不在 sudoers 文件中。此事将被报告。

398-哈希表(242.有效的字母异位词 & 349. 两个数组的交集 & 202. 快乐数)

Cross chain revelation: has your assets really been transferred in the process of cross chain?

对网页 ‘’为所欲为‘’ 之手动实现 csdn深色模式?

sqli-labs25

simple_ JS attack and defense world

Working principle of digital temperature sensor and analysis of temperature measurement principle

kali快捷键和设置方式
随机推荐
Picture steganography: Method 1
You have an error in your SQL syntax; check the manual that corresponds to your MYSQL server
BGP - route announcement and reflector (explanation + configuration command)
Leetcode刷题 ——— (4)字符串中的第一个唯一字符
代码生成器文件运行出错:The server time zone value ‘�й���ʱ��‘ is unrecognized or represents more than one time
lambda-stream
SSH copy ID batch - free script
代码中变量的重要性
用代码生成器 生成代码后复制完成,在网页上不显示模块
tf.compat.v1.get_default_graph
China video booth market status research analysis and development prospect forecast report (2022)
kali快捷键和设置方式
lambda-stream
攻防世界 php_rce
Discussion on the American ess audio DAC decoder chip es9023
TF. Auto Fonction de réserve
Detailed explanation of balanced binary tree is easy to understand
Implementation of industrial memory copy function
tf. AUTO_ Reuse effect
【Prometheus】Prometheus联邦的一次优化记录