Commit 06738b06 authored by Kosmas Hench's avatar Kosmas Hench

relabel -> new format

parent 79ce4b8c
get_anno_df_single_line <- function(searchLG,gfffile,
xrange,
genes_of_interest,
genes_of_sec_interest,
anno_rown=3){
gff_filter <- list(seqid=searchLG)
data <- as.data.frame(readGFF(gfffile,filter=gff_filter)) %>% mutate(Parent=as.character(Parent))#%>%
#rowwise() %>% mutate(Parent=ifelse(length(Parent)==0,ID,Parent))
mRNAs <- data %>% filter(type=='mRNA',end>xrange[1],start<xrange[2]) %>%
ungroup() %>% mutate(yl=row_number()%%anno_rown+2) %>% rowwise()%>%
mutate(checkStart =ifelse(start<xrange[1],-Inf,start),
checkEnd =ifelse(end>xrange[2],Inf,end),
ps=ifelse(strand=='-',checkEnd,checkStart),
pe=ifelse(strand=='-',checkStart,checkEnd),
labelx=mean(c(sort(c(xrange[1],ps))[2],
sort(c(xrange[2],pe))[1])),
window='bold(Gene)',
clr=ifelse(Parentgenename %in% genes_of_interest,"y",
ifelse(Parentgenename %in% genes_of_sec_interest,"z","x"))) %>%
select(-Parent);
names(mRNAs)[names(mRNAs)=='ID'] <- 'Parent'
exons <- data %>% filter(type=='exon',end>xrange[1],start<xrange[2]) %>%
merge(.,mRNAs %>% select(Parent,yl,clr),by='Parent',all.x=T) %>%
mutate(ps=ifelse(strand=='-',end,start),
pe=ifelse(strand=='-',start,end),
window='bold(Gene)')
return(list(mRNAs,exons))}
This diff is collapsed.
create_K_plot <- function(searchLG,gfffile,xr,searchgene,secondary_genes,searchsnp,muskID){
source('../../0_data/0_scripts/E1.functions.R');
source('../../0_data/0_scripts/E1.getFSTs.R')
source('../../0_data/0_scripts/E1.getGxP.R')
source('../../0_data/0_scripts/E1.getDXY.R')
source('../../0_data/0_scripts/F3.functions.R');
source('../../0_data/0_scripts/F3.getFSTs.R')
source('../../0_data/0_scripts/F3.getGxP.R')
source('../../0_data/0_scripts/F3.getDXY.R')
highclr <- '#3bb33b'
theme_set(theme_minimal(base_size = 6))
......@@ -87,24 +87,24 @@ create_K_plot <- function(searchLG,gfffile,xr,searchgene,secondary_genes,searchs
panel.border = element_blank()
);
if(muskID=='A'){
if(muskID=='a'){
p11$layers[[4]]$data$label <- c("italic(sox10)","italic(rnaseh2a)")
} else if(muskID=='B'){
} else if(muskID=='b'){
p11$layers[[4]]$data$label <- c("italic(casz1.3)","italic(casz1.2)","italic(casz1.1)")
} else if(muskID=='C'){
} else if(muskID=='c'){
p11$layers[[4]]$data$label <- c('italic(hoxc10a)',"italic(hoxc11a)","italic(hoxc12a)","italic(hoxc13a)","italic(calcoco1)")
}else if(muskID=='E'){
}else if(muskID=='e'){
p11$layers[[4]]$data$label <- c("italic(polr1d)","italic(ednrb)")
} else if(muskID=='F'){
} else if(muskID=='f'){
p11$layers[[4]]$data$label <- c("italic(foxd3)","italic(alg6)","italic(efcab7)")
} else if(muskID=='D'){
} else if(muskID=='d'){
p11$layers[[4]]$data$label <- c("italic(hcfc1)","italic(hcfc1[2])","italic(hcfc1[1])",'italic(paste(sws2a,"\u03B2"))',
'italic(paste(sws2a,"\u03B1"))',"italic(sw2b)","italic(lws)",
"italic(gnl3l)","italic(tfe3)","italic(mdfic2)","italic(cxxc1[3])",
"italic(cxxc1[1])",'italic(mbd1)','italic(ccdc120)')
}else if(muskID=='G'){
}else if(muskID=='g'){
p11$layers[[4]]$data$label <- c("italic(lgals3bpb)","italic(mpnd)","italic(sh3gl1)","italic(rorb)")
}else if(muskID=='H'){
}else if(muskID=='h'){
p11$layers[[4]]$data$label <- c("italic(alg2)","italic(sec61b)","italic(nr4a3)",
"italic(stx17)","italic(erp44)","italic(invs)")
}
......
se <- function(x){
x2 <- x[!is.na(x)]
return(sd(x2)/sqrt(length(x2)))}
trplot <- function(sel){
files <- c("global","boc","bel","hon","pue","nig","uni","nig-pue","nig-uni","pue-uni")
data <- read.csv(paste('../../2_output/08_popGen/07_LD/',files[sel],'-10000-bins.txt',sep=''),sep='\t')
message(files[sel])
s1=17620000;s2=19910000;s3=21960000;s4=22320000;
e2=20660000;e3=22460000;
stp=20000;
l1=500000;l2=750000;l3=500000;l4=500000
scling <- c(-s1,-s2+(l1+stp),-s3+(l1+l2+2*stp),-s4+(l1+l2+l3+(stp*3)))
dt <- data %>% mutate(miX = floor(Mx/10000),miY=floor(My/10000))
genes <- data.frame(start=c(17871610,20186151,22225149,22553187,22556763,22561894,22573388),
end=c(17873915,20347811,22228342,22555052,22559742,22566321,22575503),
sclr=c(1,2,3,4,4,4,4),
LG=c("LG09","LG12-1","LG12-2","LG17","LG17","LG17","LG17"),
name=c("sox10",'casz1',"hoxc13a","sws2a\u03B1","sws2a\u03B2","sws2b","lws"))
genes <- genes %>% mutate(Nx1 = (start+scling[sclr])/10000,Nx2 = (end+scling[sclr])/10000,
labPOS = (Nx1+Nx2)/2)
genes$labPOS[genes$name %in% c("sws2a\u03B1","sws2a\u03B2","sws2b","lws")] <- genes$labPOS[genes$name %in% c("sws2a\u03B1","sws2a\u03B2","sws2b","lws")]+c(-16,-1,12,20)
GZrS <- 40000;GZrS2 <- 20000; #gene zoom offset
BS <- c(-5,5,-4,3,-8,8,-20,-10,-6,5,7,16,17,22)*10000 # Backshifter for gene zoom
GZdf <- data.frame(x=c(genes$start[1],genes$end[1],genes$end[1]+GZrS+BS[1],genes$start[1]+GZrS+BS[2],genes$start[1],
genes$start[2],genes$end[2],genes$end[2]+GZrS+BS[3],genes$start[2]+GZrS+BS[4],genes$start[2],
genes$start[3],genes$end[3],genes$end[3]+GZrS+BS[5],genes$start[3]+GZrS+BS[6],genes$start[3],
genes$start[4],genes$end[4],genes$end[4]+GZrS+BS[7],genes$start[4]+GZrS+BS[8],genes$start[4],
genes$start[5],genes$end[5],genes$end[5]+GZrS+BS[9],genes$start[5]+GZrS+BS[10],genes$start[5],
genes$start[6],genes$end[6],genes$end[6]+GZrS+BS[11],genes$start[6]+GZrS+BS[12],genes$start[6],
genes$start[7],genes$end[7],genes$end[7]+GZrS+BS[13],genes$start[7]+GZrS+BS[14],genes$start[7])+GZrS2,
y=c(genes$start[1],genes$end[1],genes$end[1]-GZrS+BS[1],genes$start[1]-GZrS+BS[2],genes$start[1],
genes$start[2],genes$end[2],genes$end[2]-GZrS+BS[3],genes$start[2]-GZrS+BS[4],genes$start[2],
genes$start[3],genes$end[3],genes$end[3]-GZrS+BS[5],genes$start[3]-GZrS+BS[6],genes$start[3],
genes$start[4],genes$end[4],genes$end[4]-GZrS+BS[7],genes$start[4]-GZrS+BS[8],genes$start[4],
genes$start[5],genes$end[5],genes$end[5]-GZrS+BS[9],genes$start[5]-GZrS+BS[10],genes$start[5],
genes$start[6],genes$end[6],genes$end[6]-GZrS+BS[11],genes$start[6]-GZrS+BS[12],genes$start[6],
genes$start[7],genes$end[7],genes$end[7]-GZrS+BS[13],genes$start[7]-GZrS+BS[14],genes$start[7])-GZrS2,
grp=rep(letters[1:7],each=5)) %>%
mutate(sclr=rep(c(1,2,3,4,4,4,4),each=5),
Nx1 = (x+scling[sclr])/10000,
Nx2 = (y+scling[sclr])/10000)
clr = c(viridis::inferno(5)[c(1,1:5)])
Gcol <- '#3bb33b'
Zcol = rgb(.94,.94,.94)
DG <- rgb(.4,.4,.4)
LGoffset <- 15
GLABoffset <- 8
if(sel %in% c(1,8)){
rS <- 100000 # width of grey annotation band
zmRange <- data.frame(x=c(s1,s1+l1,s1+l1+rS,s1+rS,s1,
s2,s2+l2,s2+l2+rS,s2+rS,s2,
s3,s3+l3,s3+l3+rS,s3+rS,s3,
s4,s4+l4,s4+l4+rS,s4+rS,s4),
y=c(s1,s1+l1,s1+l1-rS,s1-rS,s1,
s2,s2+l2,s2+l2-rS,s2-rS,s2,
s3,s3+l3,s3+l3-rS,s3-rS,s3,
s4,s4+l4,s4+l4-rS,s4-rS,s4),
grp=rep(letters[1:4],each=5)) %>%
mutate(sclr=rep(1:4,each=5),
Nx1 = (x+scling[sclr])/10000-1,
Nx2 = (y+scling[sclr])/10000)
rS2 <- .75*rS
zmRange2 <- data.frame(x=c(s1,s1+l1,s1+l1+rS2,s1+rS2,s1,
s2,s2+l2,s2+l2+rS2,s2+rS2,s2,
s3,s3+l3,s3+l3+rS2,s3+rS2,s3,
s4,s4+l4,s4+l4+rS2,s4+rS2,s4),
y=c(s1,s1+l1,s1+l1-rS2,s1-rS2,s1,
s2,s2+l2,s2+l2-rS2,s2-rS2,s2,
s3,s3+l3,s3+l3-rS2,s3-rS2,s3,
s4,s4+l4,s4+l4-rS2,s4-rS2,s4),
grp=rep(letters[1:4],each=5)) %>%
mutate(sclr=rep(1:4,each=5),
Nx1 = (x+scling[sclr])/10000-1,
Nx2 = (y+scling[sclr])/10000)
rS3 <- .07*rS
zmRange3 <- data.frame(x=c(s1,s1+l1,s1+l1+rS3,s1+rS3,s1,
s2,s2+l2,s2+l2+rS3,s2+rS3,s2,
s3,s3+l3,s3+l3+rS3,s3+rS3,s3,
s4,s4+l4,s4+l4+rS3,s4+rS3,s4),
y=c(s1,s1+l1,s1+l1-rS3,s1-rS3,s1,
s2,s2+l2,s2+l2-rS3,s2-rS3,s2,
s3,s3+l3,s3+l3-rS3,s3-rS3,s3,
s4,s4+l4,s4+l4-rS3,s4-rS3,s4),
grp=rep(letters[1:4],each=5)) %>%
mutate(sclr=rep(1:4,each=5),
Nx1 = (x+scling[sclr])/10000-1,
Nx2 = (y+scling[sclr])/10000)
zmLab <- data.frame(x=c(s1+.5*l1,s2+.5*l2,s3+.5*l3,s4+.5*l4),
label=c('LG09 (a)','LG12 (b)','LG12 (c)','LG17 (d)')) %>%
mutate(sclr=1:4, Nx= (x+scling[sclr])/10000)
zmEND <- data.frame(x=c(s1,s1+l1,
s2,s2+l2,
s3,s3+l3,
s4,s4+l4)) %>%
mutate(sclr=rep(1:4,each=2),
Nx = ((x+scling[sclr])/10000)+rep(c(2.5,-4),4),
label=round((x/1000000),2))
textSCALE1 <- c(1.8,rep(NA,6),.7)
textSCALE2 <- c(2,rep(NA,6),1)
textSCALE3 <- c(3.5,rep(NA,6),1.75)
p1 <- ggplot(dt %>% filter(!is.na(Mval)),aes(fill=Mval))+
coord_equal()+
geom_polygon(inherit.aes = F,data=zmRange,
aes(x=Nx1+1,y=Nx2-1,group=grp),fill='lightgray')+
geom_polygon(inherit.aes = F,data=zmRange2,
aes(x=Nx1+11,y=Nx2-11,group=grp),fill=DG)+
geom_polygon(inherit.aes = F,data=zmRange3,
aes(x=Nx1+1.1,y=Nx2-1.1,group=grp),fill=DG)+
geom_polygon(inherit.aes = F,data=GZdf,
aes(x=Nx1,y=Nx2,group=grp),fill=Zcol)+
geom_segment(inherit.aes = F,data=genes,
aes(x=Nx1+1,y=Nx1-1,xend=Nx2+1,yend=Nx2-1),
col=Gcol,size=1.5)+
geom_tile(aes(x=miX,y=miY))+
geom_text(inherit.aes = F,data=zmEND,
aes(x=Nx+LGoffset,y=Nx-LGoffset,label=paste(label,'\n(Mb)')),
angle=45,size=textSCALE1[sel])+
geom_text(inherit.aes = F,data=genes,
aes(x=labPOS+GLABoffset,y=labPOS-GLABoffset,label=name),
angle=-45,fontface='italic',size=textSCALE2[sel])+
geom_text(inherit.aes = F,data=zmLab,
aes(x=Nx+LGoffset-.8,y=Nx-LGoffset+.8,label=label),
angle=-45,fontface='bold',size=textSCALE3[sel],col='white')+
scale_x_continuous(expand=c(0,0))+
scale_y_continuous(expand=c(0,0),
trans = 'reverse')+
scale_fill_gradientn(name=expression(bar(italic(r)^2)),colours=clr,
values=rescale(c(1,.5,.08,.03,.015,.01,0)),
limits=c(0,1),
guide = 'legend',breaks=c(0,.005,.01,.02,.03,.1,1))+
theme_void()+
theme(legend.position = c(.9,.75),
legend.direction = 'vertical')
} else {
p1 <- ggplot(dt %>% filter(!is.na(Mval)),aes(fill=Mval))+
coord_equal()+
geom_segment(inherit.aes = F,data=genes,
aes(x=Nx1+1.5,y=Nx1-1.5,xend=Nx2+1.5,yend=Nx2-1.5),
col=Gcol,size=1)+
geom_tile(aes(x=miX,y=miY))+
scale_x_continuous(expand=c(0,0))+
scale_y_continuous(expand=c(0,0),
trans = 'reverse')+
scale_fill_gradientn(name=expression(bar(r^2)),colours=clr,
values=rescale(c(1,.08,.03,.015,.01,0)),
limits=c(0,1),guide = 'legend',breaks=c(0,.005,.01,.02,.03,.1,1))+
theme_void()+
theme(legend.position = c(.7,.75),legend.direction = 'vertical')
}
return(p1)
}
\ No newline at end of file
create_K_plot <- function(searchLG,gfffile,xr,xr2,muskID){
source('../../0_data/0_scripts/S07.functions.R');
source('../../0_data/0_scripts/E1.getFSTs.R')
source('../../0_data/0_scripts/F3.getFSTs.R')
highclr <- '#3bb33b'
theme_set(theme_minimal(base_size = 5))
......
......@@ -139,7 +139,7 @@ trplot <- function(sel){
zmLab <- data.frame(x=c(s1+.5*lALL,s2+.5*lALL,s3+.5*lALL,s4+.5*lALL,
s5+.5*lALL,s6+.5*lALL,s7+.5*lALL,s8+.5*lALL),
label=c("LG4 (E)","LG08 (F)","LG08 (G)",'LG09 (A)','LG12 (B)','LG12 (C)','LG17 (D)',"LG20 (H)")) %>%
label=c("LG4 (e)","LG08 (f)","LG08 (g)",'LG09 (a)','LG12 (b)','LG12 (c)','LG17 (d)',"LG20 (h)")) %>%
mutate(sclr=1:8, Nx= (x+scling[sclr])/10000)
zmEND <- data.frame(x=c(s1,s1+lALL,
......
create_K_plot <- function(searchLG,gfffile,xr,searchgene,secondary_genes,searchsnp,muskID){
source('../../0_data/0_scripts/E1.functions.R');
source('../../0_data/0_scripts/E1.getFSTs.R')
source('../../0_data/0_scripts/E1.getGxP.R')
source('../../0_data/0_scripts/E1.getDXY.R')
source('../../0_data/0_scripts/F3.functions.R');
source('../../0_data/0_scripts/F3.getFSTs.R')
source('../../0_data/0_scripts/F3.getGxP.R')
source('../../0_data/0_scripts/F3.getDXY.R')
source('../../0_data/0_scripts/S15.getPI.R')
source('../../0_data/0_scripts/S15.getPIpw.R')
source('../../0_data/0_scripts/S15.getIHH12.R')
......
This diff is collapsed.
......@@ -49,7 +49,7 @@ library(marmap)
source("../../0_data/0_scripts/F1.functions.R")
```
### Fig. 1 a)
### Fig. 1 A)
First, we load the data sheet containing the sampling location as well as the population specifics for each sample and sub sample it to include only the samples included in the re-sequencing study.
......@@ -178,9 +178,9 @@ p1
```
</center>
### Fig. 1 b)
### Fig. 1 B)
Next we create the sub figure containing the *F~ST~* information (Fig. 1 b).
Next we create the sub figure containing the *F~ST~* information (Fig. 1 B).
We first read in the data and define the color palette.
```{r fstData, results='hide', message=FALSE, warning=FALSE}
......@@ -230,7 +230,7 @@ p5
```
</center>
### Fig. 1 c)
### Fig. 1 C)
The last sub figure contains the PCA output for each location.
For those, we define the color palette for hamlet species and read in the PCA data generated by `pcadapt`.
......@@ -374,7 +374,7 @@ F1 <- ggdraw()+
# annotations (subfigure labels)
draw_plot_label(x = c(.005,.005,.25),
y = c(.995,.42,.42),
label =letters[1:3])
label = LETTERS[1:3])
```
It is then exported using `ggsave()`.
......
......@@ -179,7 +179,7 @@ p1 <- ggplot()+
# Fst values
geom_point(data=data,aes(x=GPOS,y=WEIGHTED_FST,col=COL),size=.01)+
# labels for the outlier windows
geom_text(data=musks,aes(x=muskX,y=.65,label=musk))+
geom_text(data=musks,aes(x=muskX,y=.65,label=tolower(musk)))+
# vertical line separating sliding Fst from genome wide Fst
geom_vline(data = data.frame(x=567000000),aes(xintercept=x),col=annoclr,lwd=.2)+
# genome wide Fst
......
This diff is collapsed.
This diff is collapsed.
#!/usr/bin/env Rscript
library(grid)
library(gridSVG)
library(grImport2)
library(grConvert)
library(tidyverse)
library(rtracklayer)
library(hrbrthemes)
library(cowplot)
require(rtracklayer)
source('../../0_data/0_scripts/E1.functions.R');
source('../../0_data/0_scripts/E1.plot_fun.R')
p1 <- create_K_plot(searchLG = "LG09",gfffile = '../../1-output/09_gff_from_IKMB/HP.annotation.named.gff',xr = c(17800000,18000000),
searchgene = c("SOX10_1"),secondary_genes = c("RNASEH2A"),searchsnp = c(17871737,17872597,17873443),
muskID = 'A')
p2 <- create_K_plot(searchLG = "LG12",gfffile = '../../1-output/09_gff_from_IKMB/HP.annotation.named.gff',xr = c(20080000,20500000),
searchgene = c("Casz1_2"),secondary_genes = c(),searchsnp = c(20316944,20317120,20323661,20323670,20333895,20347263),
muskID = 'B')
p3 <- create_K_plot(searchLG = "LG12",gfffile = '../../1-output/09_gff_from_IKMB/HP.annotation.named.gff',xr = c(22100000,22350000),
searchgene = c("hoxc13a"),secondary_genes = c('hoxc10a',"hoxc11a","hoxc12a","calcoco1_1"),
searchsnp = c(),
muskID = 'C')
p4 <- create_K_plot(searchLG = "LG17",gfffile = '../../1-output/09_gff_from_IKMB/HP.annotation.named.gff',xr = c(22500000,22670000),
searchgene = c('LWS',"SWS2abeta","SWS2aalpha","SWS2b"),searchsnp = c(22553970,22561903,22566254),
secondary_genes = c("Hcfc1","HCFC1_2","HCFC1_1","GNL3L","TFE3_0","MDFIC2_1","CXXC1_3","CXXC1_1",'Mbd1','CCDC120'),
muskID = 'D')
legGrob <- gTree(children=gList(pictureGrob(readPicture("../../0_data/0_img/legend-pw-cairo.svg"))))
E1 <- plot_grid(NULL,NULL,NULL,NULL,
p1,NULL,p2,NULL,
NULL,NULL,NULL,NULL,
p3,NULL,p4,NULL,
NULL,NULL,NULL,NULL,
ncol=4,rel_heights = c(.03,1,.03,1,.1),rel_widths = c(1,.025,1,.02),
labels = c('a','','b','',
'','','','',
'c','','d','',
'','','','',
'','','',''),label_size = 10)+
draw_grob(legGrob, 0.1, 0, .8, 0.04)
#ggsave(plot = E1,filename = '../output/E1.pdf',
# width = 183,height = 155,units = 'mm',device = cairo_pdf)
ggsave(plot = E1,filename = '../output/E1.png',
width = 183,height = 155,dpi = 200,units = 'mm')
#ggsave('ranges_all_label.pdf',width = 183,height = 120,units = 'mm',device = cairo_pdf)
......@@ -200,9 +200,9 @@ F1 <- ggdraw()+
draw_grob(honGrob, 0.285+.09, 0.37, 0.042, 0.042)+
draw_grob(belGrob, 0.535+.09, 0.37, 0.042, 0.042)+
draw_grob(panGrob, 0.785+.09, 0.37, 0.042, 0.042)+
draw_plot_label(x = c(.005,.005,.25),
y = c(.995,.42,.42),
label =letters[1:3])
draw_plot_label(x = c(.001,.001,.25),
y = c(.99,.42,.42),
label =LETTERS[1:3])
#ggsave(plot = F1,filename = '../output/F1.pdf',width = 183,height = 145,units = 'mm',device = cairo_pdf)
ggsave(plot = F1,filename = '../output/F1.png',width = 183,height = 145,units = 'mm',dpi = 200)
......@@ -103,7 +103,7 @@ p1 <- ggplot()+
ymin=-Inf,ymax=Inf,fill=GROUP))+
geom_vline(data=data2,aes(xintercept=xmean),col=annoclr,lwd=.2)+
geom_point(data=data,aes(x=GPOS,y=WEIGHTED_FST,col=COL),size=.01)+
geom_text(data=musks,aes(x=muskX,y=.65,label=musk))+
geom_text(data=musks,aes(x=muskX,y=.65,label=tolower(musk)))+
geom_vline(data = data.frame(x=567000000),aes(xintercept=x),col=annoclr,lwd=.2)+
geom_rect(data=gwFST,aes(xmin=570*10^6,xmax=573*10^6,ymin=0,ymax=gwFST*secScale))+
scale_y_continuous(name = yl,limits=c(-.03,.83),breaks=0:4*0.2,labels = c(0,'',0.4,'',0.8),
......
#!/usr/bin/env Rscript
library(tidyverse)
library(scales)
library(cowplot)
library(grid)
library(gridSVG)
library(grImport2)
source('../../0_data/0_scripts/F3.functions.R')
plts <- list()
for(k in 1:7){
plts[[k]] <- trplot(k)
}
tN <- theme(legend.position = 'none')
pG1 <- ggplotGrob(plts[[1]]+tN)
pG2 <- ggplotGrob(plts[[2]]+tN)
pG3 <- ggplotGrob(plts[[3]]+tN)
pG4 <- ggplotGrob(plts[[4]]+tN)
pG5 <- ggplotGrob(plts[[5]]+tN)
pG6 <- ggplotGrob(plts[[6]]+tN)
pG7 <- ggplotGrob(plts[[7]]+tN)
pGr1 <- editGrob(pG1, vp=viewport(x=0.5, y=0.91, angle=45,width = .7), name="pG1")
pGr2 <- editGrob(pG2, vp=viewport(x=0.25, y=0.535, angle=45,width = .28), name="pG2")
pGr3 <- editGrob(pG3, vp=viewport(x=0.25, y=0.352, angle=45,width = .28), name="pG3")
pGr4 <- editGrob(pG4, vp=viewport(x=0.25, y=0.17, angle=45,width = .28), name="pG4")
pGr5 <- editGrob(pG5, vp=viewport(x=0.75, y=0.535, angle=45,width = .28), name="pG5")
pGr6 <- editGrob(pG6, vp=viewport(x=0.75, y=0.352, angle=45,width = .28), name="pG5")
pGr7 <- editGrob(pG7, vp=viewport(x=0.75, y=0.17, angle=45,width = .28), name="pG5")
source('../../0_data/0_scripts/F3.genomeWide_box.R')
source('../../0_data/0_scripts/F3.peakArea_box.R')
pGRAD <- ggplot(data = data.frame(x=c(0,1,-1,0),
y=c(0,15,15,0)),
aes(x,y))+geom_polygon(fill='lightgray')+coord_equal()+theme_void()
nigGrob <- gTree(children=gList(pictureGrob(readPicture("../../0_data/0_img/nigricans-cairo.svg"))))
pueGrob <- gTree(children=gList(pictureGrob(readPicture("../../0_data/0_img/puella-cairo.svg"))))
uniGrob <- gTree(children=gList(pictureGrob(readPicture("../../0_data/0_img/unicolor-cairo.svg"))))
belGrob <- gTree(children=gList(pictureGrob(readPicture("../../0_data/0_img/belize-cairo.svg"))))
honGrob <- gTree(children=gList(pictureGrob(readPicture("../../0_data/0_img/honduras-cairo.svg"))))
panGrob <- gTree(children=gList(pictureGrob(readPicture("../../0_data/0_img/panama-cairo.svg"))))
globGrob <- gTree(children=gList(pictureGrob(readPicture("../../0_data/0_img/caribbean-cairo.svg"))))
leg <- get_legend(plts[[1]]+theme(legend.direction = 'horizontal')+ guides(fill = guide_legend(nrow=1)))
sY <- .035;
sX <- -.03;
F3 <- ggdraw(pGr1)+
draw_plot(pBOX,-.1,.54,.45,.21)+
draw_plot(boxGenes,.65,.54,.45,.21)+
draw_plot(pGRAD,.307,-.018,.16,.53)+
draw_grob(pGr2,0,0,1,1)+
draw_grob(leg,-.33,.22,1,1)+
draw_grob(pGr3,0,0,1,1)+
draw_grob(pGr4,0,0,1,1)+
draw_grob(pGr5,0,0,1,1)+
draw_grob(pGr6,0,0,1,1)+
draw_grob(pGr7,0,0,1,1)+
draw_grob(nigGrob, 0.85, 0.38, 0.12, 0.095)+
draw_grob(pueGrob, 0.85, 0.2, 0.12, 0.095)+
draw_grob(uniGrob, 0.85, 0, 0.12, 0.095)+
draw_grob(panGrob, 0.35+sX+.01, 0.37+sY, 0.12, 0.045)+
draw_grob(belGrob, 0.35+sX+.01, 0.19+sY, 0.12, 0.045)+
draw_grob(honGrob, 0.35+sX, 0+sY, 0.14, 0.045)+
draw_grob(globGrob, 0.06, .925, 0.08, 0.08)+
draw_plot_label(letters[1:5],
x = c(rep(0.01,2),.87,0.01,.54),
y=c(.99,.81,.81,.57,.57),
size = 14)
ggsave(plot = F3,filename = '../output/F3.png',width = 183,height = 235,units = 'mm',dpi = 150)
library(grConvert)
library(tidyverse)
library(rtracklayer)
library(hrbrthemes)
library(cowplot)
require(rtracklayer)
source('../../0_data/0_scripts/F3.functions.R');
source('../../0_data/0_scripts/F3.plot_fun.R')
p1 <- create_K_plot(searchLG = "LG09",gfffile = '../../1-output/09_gff_from_IKMB/HP.annotation.named.gff',xr = c(17800000,18000000),
searchgene = c("SOX10_1"),secondary_genes = c("RNASEH2A"),searchsnp = c(17871737,17872597,17873443),
muskID = 'a')
p2 <- create_K_plot(searchLG = "LG12",gfffile = '../../1-output/09_gff_from_IKMB/HP.annotation.named.gff',xr = c(20080000,20500000),
searchgene = c("Casz1_2"),secondary_genes = c(),searchsnp = c(20316944,20317120,20323661,20323670,20333895,20347263),
muskID = 'b')
p3 <- create_K_plot(searchLG = "LG12",gfffile = '../../1-output/09_gff_from_IKMB/HP.annotation.named.gff',xr = c(22100000,22350000),
searchgene = c("hoxc13a"),secondary_genes = c('hoxc10a',"hoxc11a","hoxc12a","calcoco1_1"),
searchsnp = c(),
muskID = 'c')
p4 <- create_K_plot(searchLG = "LG17",gfffile = '../../1-output/09_gff_from_IKMB/HP.annotation.named.gff',xr = c(22500000,22670000),
searchgene = c('LWS',"SWS2abeta","SWS2aalpha","SWS2b"),searchsnp = c(22553970,22561903,22566254),
secondary_genes = c("Hcfc1","HCFC1_2","HCFC1_1","GNL3L","TFE3_0","MDFIC2_1","CXXC1_3","CXXC1_1",'Mbd1','CCDC120'),
muskID = 'd')
legGrob <- gTree(children=gList(pictureGrob(readPicture("../../0_data/0_img/legend-pw-cairo.svg"))))
F3 <- plot_grid(NULL,NULL,NULL,NULL,
p1,NULL,p2,NULL,
NULL,NULL,NULL,NULL,
p3,NULL,p4,NULL,
NULL,NULL,NULL,NULL,
ncol=4,rel_heights = c(.03,1,.03,1,.1),rel_widths = c(1,.025,1,.02),
labels = c('A','','B','',
'','','','',
'C','','D','',
'','','','',
'','','',''),label_size = 10)+
draw_grob(legGrob, 0.1, 0, .8, 0.04)
#ggsave(plot = F3,filename = '../output/F3.pdf',
# width = 183,height = 155,units = 'mm',device = cairo_pdf)
ggsave(plot = F3,filename = '../output/F3.png',
width = 183,height = 155,dpi = 200,units = 'mm')
#!/usr/bin/env Rscript
library(tidyverse)
library(scales)
library(cowplot)
library(grid)
library(gridSVG)
library(grImport2)
source('../../0_data/0_scripts/F4.functions.R')
plts <- list()
for(k in 1:7){
plts[[k]] <- trplot(k)
}
tN <- theme(legend.position = 'none')
pG1 <- ggplotGrob(plts[[1]]+tN)
pG2 <- ggplotGrob(plts[[2]]+tN)
pG3 <- ggplotGrob(plts[[3]]+tN)
pG4 <- ggplotGrob(plts[[4]]+tN)
pG5 <- ggplotGrob(plts[[5]]+tN)
pG6 <- ggplotGrob(plts[[6]]+tN)
pG7 <- ggplotGrob(plts[[7]]+tN)
pGr1 <- editGrob(pG1, vp=viewport(x=0.5, y=0.91, angle=45,width = .7), name="pG1")
pGr2 <- editGrob(pG2, vp=viewport(x=0.25, y=0.535, angle=45,width = .28), name="pG2")
pGr3 <- editGrob(pG3, vp=viewport(x=0.25, y=0.352, angle=45,width = .28), name="pG3")
pGr4 <- editGrob(pG4, vp=viewport(x=0.25, y=0.17, angle=45,width = .28), name="pG4")
pGr5 <- editGrob(pG5, vp=viewport(x=0.75, y=0.535, angle=45,width = .28), name="pG5")
pGr6 <- editGrob(pG6, vp=viewport(x=0.75, y=0.352, angle=45,width = .28), name="pG5")
pGr7 <- editGrob(pG7, vp=viewport(x=0.75, y=0.17, angle=45,width = .28), name="pG5")
source('../../0_data/0_scripts/F4.genomeWide_box.R')
source('../../0_data/0_scripts/F4.peakArea_box.R')
pGRAD <- ggplot(data = data.frame(x=c(0,1,-1,0),
y=c(0,15,15,0)),
aes(x,y))+geom_polygon(fill='lightgray')+coord_equal()+theme_void()
nigGrob <- gTree(children=gList(pictureGrob(readPicture("../../0_data/0_img/nigricans-cairo.svg"))))
pueGrob <- gTree(children=gList(pictureGrob(readPicture("../../0_data/0_img/puella-cairo.svg"))))
uniGrob <- gTree(children=gList(pictureGrob(readPicture("../../0_data/0_img/unicolor-cairo.svg"))))
belGrob <- gTree(children=gList(pictureGrob(readPicture("../../0_data/0_img/belize-cairo.svg"))))
honGrob <- gTree(children=gList(pictureGrob(readPicture("../../0_data/0_img/honduras-cairo.svg"))))
panGrob <- gTree(children=gList(pictureGrob(readPicture("../../0_data/0_img/panama-cairo.svg"))))
globGrob <- gTree(children=gList(pictureGrob(readPicture("../../0_data/0_img/caribbean-cairo.svg"))))
leg <- get_legend(plts[[1]]+theme(legend.direction = 'horizontal')+ guides(fill = guide_legend(nrow=1)))
sY <- .035;
sX <- -.03;
F4 <- ggdraw(pGr1)+
draw_plot(pBOX,-.1,.54,.45,.21)+
draw_plot(boxGenes,.65,.54,.45,.21)+
draw_plot(pGRAD,.307,-.018,.16,.53)+
draw_grob(pGr2,0,0,1,1)+
draw_grob(leg,-.33,.22,1,1)+
draw_grob(pGr3,0,0,1,1)+
draw_grob(pGr4,0,0,1,1)+
draw_grob(pGr5,0,0,1,1)+
draw_grob(pGr6,0,0,1,1)+
draw_grob(pGr7,0,0,1,1)+
draw_grob(nigGrob, 0.85, 0.38, 0.12, 0.095)+
draw_grob(pueGrob, 0.85, 0.2, 0.12, 0.095)+
draw_grob(uniGrob, 0.85, 0, 0.12, 0.095)+
draw_grob(panGrob, 0.35+sX+.01, 0.37+sY, 0.12, 0.045)+
draw_grob(belGrob, 0.35+sX+.01, 0.19+sY, 0.12, 0.045)+
draw_grob(honGrob, 0.35+sX, 0+sY, 0.14, 0.045)+
draw_grob(globGrob, 0.06, .925, 0.08, 0.08)+
draw_plot_label(LETTERS[1:5],
x = c(rep(0.01,2),.87,0.01,.54),
y=c(.99,.81,.81,.57,.57),
size = 14)
ggsave(plot = F4,filename = '../output/F4.png',width = 183,height = 235,units = 'mm',dpi = 150)
......@@ -66,7 +66,7 @@ cp1 <- plot_grid(pbel+theme(legend.position = 'none'),p1,
phon+theme(legend.position = 'none'),p2,
pboc+theme(legend.position = 'none'),p3,
ncol = 2,rel_heights = c(1,1,1),
rel_widths = c(0.65,0.35),labels=c('a','b',rep('',4)),label_size = 10);
rel_widths = c(0.65,0.35),labels=c('A','B',rep('',4)),label_size = 10);