Ka(dN)
代表每非同義位點(diǎn)的堿基替代數(shù)磅崭,而Ks(dS)
則代表每同義位點(diǎn)的堿基替代數(shù)畅姊,Ka/Ks
的比值常用于判斷某個(gè)蛋白編碼基因是否受到選擇壓力的作用透揣。一般認(rèn)為板乙,當(dāng)Ka/Ks>1
時(shí)砸脊,則認(rèn)為有正選擇效應(yīng)
具篇。當(dāng)Ka/Ks=1
時(shí),則認(rèn)為存在中性選擇
凌埂。當(dāng)Ka/Ks<1
時(shí)驱显,則認(rèn)為有純化選擇
的作用。常用的選擇壓力Ka/Ks的計(jì)算工具有PAML包中的yn00
程序瞳抓,或KaKs_calculator
等軟件埃疫。Ks密度曲線分布圖常用于判斷某一物種在長期的進(jìn)化過程中是否發(fā)生了基因組加倍事件,根據(jù)密度曲線對應(yīng)峰值的Ks值以及該物種核苷酸堿基的替代速率孩哑,可以大致計(jì)算出該物種發(fā)生加倍的進(jìn)化時(shí)間栓霜。
加載所需R包
rm(list=ls())
library(ggplot2)
library(reshape2)
設(shè)置工作路徑并加載數(shù)據(jù)
setwd("/Users/Davey/Desktop")
data <- read.table("test_ks.txt",header = T,sep="\t")
data <- melt(data,variable.name="Species",value.name = "Ks")
#去除缺失的行
data = na.omit(data)
head(data)
## Species Ks
## 1 SpeciesA_SpeciesB 0.0915
## 2 SpeciesA_SpeciesB 0.2535
## 3 SpeciesA_SpeciesB 0.0386
## 4 SpeciesA_SpeciesB 0.1385
## 5 SpeciesA_SpeciesB 0.1125
## 6 SpeciesA_SpeciesB 0.1960
使用ggplot2繪圖
p1 <- ggplot(data,aes(Ks,fill=Species,color=Species,alpha=0.8)) +`
geom_density() + xlim(0,1) + theme_classic() + geom_rug() +
guides(alpha=FALSE) +
theme(axis.title = element_text(size=16),axis.text=element_text(size=16),legend.position = "top")
p1
#ggsave("Ks_plot.png",p1)
ggsave("Ks_plot.pdf",p1)
image
p2 <- ggplot(data,aes(Ks,color=Species)) +
geom_line(stat="density") + xlim(0,1) + theme_bw() +
theme(axis.title = element_text(size=16),axis.text=element_text(size=16))
p2
image
p3 <- ggplot(data,aes(Ks,fill=Species,color=Species)) +
geom_histogram(bins=100) + geom_rug() +
xlim(0,1) + theme_bw() +
theme(axis.title = element_text(size=16),axis.text=element_text(size=16))
p3
image
p4 <- ggplot(data,aes(Ks,..density..,fill=Species)) +
geom_histogram(bins=100) + geom_line(stat="density") +
xlim(0,1) + theme_bw() + facet_grid(Species~.) +
theme(axis.title = element_text(size=16),axis.text=element_text(size=16))
p4
image
sessionInfo()
## R version 3.5.1 (2018-07-02)
## Platform: x86_64-apple-darwin15.6.0 (64-bit)
## Running under: OS X El Capitan 10.11.3
##
## Matrix products: default
## BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRlapack.dylib
##
## locale:
## [1] zh_CN.UTF-8/zh_CN.UTF-8/zh_CN.UTF-8/C/zh_CN.UTF-8/zh_CN.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] ggpubr_0.1.7.999 magrittr_1.5 reshape2_1.4.3 ggplot2_3.0.0
##
## loaded via a namespace (and not attached):
## [1] Rcpp_0.12.18 rstudioapi_0.7 bindr_0.1.1 knitr_1.20
## [5] tidyselect_0.2.4 munsell_0.5.0 colorspace_1.3-2 R6_2.2.2
## [9] rlang_0.2.2 stringr_1.3.1 plyr_1.8.4 dplyr_0.7.6
## [13] tools_3.5.1 grid_3.5.1 gtable_0.2.0 withr_2.1.2
## [17] htmltools_0.3.6 assertthat_0.2.0 yaml_2.2.0 lazyeval_0.2.1
## [21] rprojroot_1.3-2 digest_0.6.16 tibble_1.4.2 crayon_1.3.4
## [25] bindrcpp_0.2.2 purrr_0.2.5 glue_1.3.0 evaluate_0.11
## [29] rmarkdown_1.10 labeling_0.3 stringi_1.2.4 compiler_3.5.1
## [33] pillar_1.3.0 scales_1.0.0 backports_1.1.2 pkgconfig_2.0.2