Skip to content

Instantly share code, notes, and snippets.

@iracooke
Last active July 14, 2018 21:02
Show Gist options
  • Save iracooke/6fb67a10e0174a843000f627c17bbfbd to your computer and use it in GitHub Desktop.
Save iracooke/6fb67a10e0174a843000f627c17bbfbd to your computer and use it in GitHub Desktop.
Sweep Plots
library(tidyverse)
sweep_detail_plot <- function(scaffold,xl,rl,gff,sf2_data){
anno_data <- gff %>%
filter(seqid==scaffold) %>%
mutate(geneid=str_extract(attributes,"m[^\\;]+"))
anno_data$type <- factor(anno_data$type)
ggplot(sf2_data,aes(x=location/1000000,y=LR)) +
geom_point() +
xlim(xl/1000000,rl/1000000) +
geom_segment(data=anno_data %>% filter(type=="gene"),size=3,aes(color=type,x=start/1e6,xend=end/1e6,y=-(10*as.numeric(type)+20),yend=-(10*as.numeric(type)+20))) + guides(fill=FALSE) +
theme_minimal() + xlab("Position Mb") + theme(legend.title = element_blank()) + theme(text= element_text(size=16))
}
aten_gff <- read_tsv("aten_0.1.maker_post_001.genes.gff",
col_names = c("seqid","source","type","start","end","score","strand","phase","attributes"))
sf2_data <- read_table2("sweepfinderdata.sf2")
sweep_detail_plot("sc0000029",xl=2.8e6,rl=3e6,aten_gff,sf2_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment