-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathplotting_correlations.R
60 lines (48 loc) · 2 KB
/
plotting_correlations.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
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
#--------------------------------------------------------------------------------------------
# HybPhyloMaker: visualize correlations among tree and alignment properties
# https://github.com/tomas-fer/HybPhyloMaker
# Taken from M. Borowiec GitHub (https://github.com/marekborowiec/good_genes)
# Modified for HybPhyloMaker
# v.1.6.0
# Tomas Fer, 2018
# tomas.fer@natur.cuni.cz
#--------------------------------------------------------------------------------------------
# disable scientific notation
options(scipen=999)
# install required libraries
# uncomment if you don't have these installed
#install.packages("data.table")
# load needed libraries
library("data.table")
#Read table with combined characteristics
gene_stats <- read.table("combined.txt", header=TRUE)
#names(gene_stats)
#select variables to plot
to_plot <-subset(gene_stats, select=c(Aln_length,Missing_perc,Prop_pars_inf,
GC_content,Aln_entropy,trimAl_sct,Bootstrap,Branch_length,
Clocklikeness,P_distance,Satur_slope,Satur_R_sq,
LBscore_SD))
panel.cor <- function(x, y, digits=2, prefix="", cex.cor)
{
usr <- par("usr"); on.exit(par(usr))
par(usr = c(0, 1, 0, 1))
r <- cor(x, y)
txt <- format(c(r, 0.123456789), digits=digits)[1]
txt <- paste(prefix, txt, sep="")
if(missing(cex.cor)) cex <- 0.99/strwidth(txt)
test <- cor.test(x,y)
# borrowed from printCoefmat
Signif <- symnum(test$p.value, corr = FALSE, na = FALSE,
cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1),
symbols = c("***", "**", "*", ".", " "))
text(0.5, 0.5, txt, cex = cex * abs(r))
text(.8, .8, Signif, cex=cex, col=2)
}
png(file="genes_corrs.png",width=20*300,height=16*300,res=300)
par(pch=20)
pairs(to_plot, lower.panel=panel.smooth, upper.panel=panel.cor,cex.labels=2)
dev.off()
pdf(file="genes_corrs.pdf",width=24,height=20)
par(pch=20)
pairs(to_plot, lower.panel=panel.smooth, upper.panel=panel.cor)
dev.off()