-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding debug rule, automated coverage estimation for plotting
- Loading branch information
1 parent
2e23758
commit 5d2f16a
Showing
8 changed files
with
316 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,3 +49,4 @@ rule bwamem2_mem_samtools_sort: | |
-@ {threads} \ | ||
- > {output} | ||
''' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
rule megadepth_bam_to_bigwig: | ||
''' | ||
https://github.com/ChristopherWilks/megadepth | ||
''' | ||
input: | ||
rules.bwamem2_mem_samtools_sort.output | ||
output: | ||
config['output'] + '/megadepth/{sample}/{region}.all.bw' | ||
threads: | ||
1 | ||
resources: | ||
mem_mb=lambda wildcards, attempt: attempt * config['default']['mem_mb'], | ||
time=lambda wildcards, attempt: attempt * config['default']['time'] | ||
container: | ||
'docker://davidebolo1993/cosigt_workflow:latest' | ||
benchmark: | ||
'benchmarks/{sample}.{region}.megadepth_bam_to_bigwig.benchmark.txt' | ||
params: | ||
prefix=config['output'] + '/megadepth/{sample}/{region} | ||
shell: | ||
''' | ||
megadepth \ | ||
--bigwig \ | ||
--prefix {params.prefix} \ | ||
{input} | ||
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/Rscript | ||
|
||
args <- commandArgs(trailingOnly = TRUE) | ||
|
||
library(rtracklayer) | ||
library(ggplot2) | ||
|
||
files<-sort(list.files(args[1], pattern="*.all.bw", full.names=T,recursive=T)) | ||
|
||
for (f in files) { | ||
|
||
name<-basename(dirname(f)) | ||
bw <- import.bw(f) | ||
df<- data.frame(bw) | ||
p<-ggplot(df, aes(x=start, y=score, group=seqnames)) + | ||
geom_point(show.legend=F) + | ||
geom_smooth(show.legend=F) + | ||
facet_wrap(~seqnames, ncol=5, scales="free_x") + | ||
theme_linedraw() | ||
ggsave(paste0(f,".pdf"),width=20, height=20) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#!/usr/bin/Rscript | ||
|
||
args <- commandArgs(trailingOnly = TRUE) | ||
|
||
library(ggplot2) | ||
library(gggenes) | ||
library(rjson) | ||
|
||
x <- data.table::fread(args[1]) | ||
y <- fromJSON(file=args[2]) | ||
reference<-args[3] | ||
|
||
if (!(reference %in% x$molecule)) { | ||
|
||
x$strand<-abs(x$strand-1) | ||
|
||
} | ||
|
||
x$old_label<-x$molecule | ||
x$molecule<-gsub("_inv", "", x$molecule) | ||
c<-c() | ||
|
||
for (i in c(1:nrow(x))) { | ||
|
||
if (x$molecule[i] %in% names(y)) { | ||
|
||
c<-c(c, y[[x$molecule[i]]]) | ||
|
||
} else { | ||
|
||
c<-c(c, "reference") | ||
} | ||
|
||
} | ||
|
||
x$c<-c | ||
x<-x[order(c),] | ||
x<-subset(x, c != "reference") | ||
|
||
x$ymin<-0 | ||
x$ymax<-0 | ||
x$molecule<-as.numeric(factor(x$molecule, levels=unique(x$molecule))) | ||
|
||
for (cl in unique(x$c)) { | ||
|
||
s<-subset(x, (c == cl)) | ||
first<-as.numeric(head(s,1)$molecule)-0.4 | ||
last<-as.numeric(tail(s,1)$molecule)+0.4 | ||
x[which(x$c == cl),]$ymin<-first | ||
x[which(x$c == cl),]$ymax<-last | ||
|
||
} | ||
|
||
p<-ggplot(x, aes(xmin=start, xmax=end, y=molecule, fill=gene, forward=strand, label=gene)) + | ||
geom_gene_arrow(arrowhead_height = unit(3, "mm"), arrowhead_width = unit(1, "mm"), show.legend=FALSE) + | ||
scale_fill_brewer(palette = "Set3") + | ||
geom_rect(data= data.frame(ymin=unique(x$ymin),ymax=unique(x$ymax),cluster=unique(x$c)), inherit.aes = FALSE, mapping=aes(xmin = -Inf, xmax = +Inf, ymin = ymin, ymax = ymax, color = cluster), alpha=0.4, show.legend=TRUE, linewidth=1, fill=NA) + | ||
#scale_color_brewer(palette = "Dark2") + | ||
geom_gene_label(align = "right") + | ||
theme_genes() + | ||
labs(y="haplotype") + | ||
scale_y_continuous(breaks=c(1:length(unique(x$old_label))), labels=unique(x$old_label))+ | ||
guides(fill = "none") | ||
|
||
ggsave(paste0(args[3], ".pdf"), height=20, width=20) |