Commit afa6a4ae authored by sgriep's avatar sgriep
Browse files

remove unneeded files and example tsv

parent ccffdf9a
# example-snakemake
example snakemake workflow for workflow repository
\ No newline at end of file
example snakemake workflow for workflow repository
~input.tsv~ may look like
```
sample reference fwd_pair rev_pair
DRR198805_c1e4 ecoli.fasta DRR198805_c1e4_R1_001.fastq.gz DRR198805_c1e4_R2_001.fastq.gz
DRR198805_c1e4.2 ecoli.fasta DRR198805_c1e4.2_R1_001.fastq.gz DRR198805_c1e4.2_R2_001.fastq.gz
DRR198805_c2e4 ecoli.fasta DRR198805_c2e4_R1_001.fastq.gz DRR198805_c2e4_R2_001.fastq.gz
ERR4147226_c1e4 ecoli.fasta ERR4147226_c1e4_R1_001.fastq.gz ERR4147226_c1e4_R2_001.fastq.gz
ERR4147226_c1e4.2 ecoli.fasta ERR4147226_c1e4.2_R1_001.fastq.gz ERR4147226_c1e4.2_R2_001.fastq.gz
ERR4147226_c1e4.3 ecoli.fasta ERR4147226_c1e4.3_R1_001.fastq.gz ERR4147226_c1e4.3_R2_001.fastq.gz
ERR4147226_c1e4.4 ecoli.fasta ERR4147226_c1e4.4_R1_001.fastq.gz ERR4147226_c1e4.4_R2_001.fastq.gz
ERR4147226_c2e4 ecoli.fasta ERR4147226_c2e4_R1_001.fastq.gz ERR4147226_c2e4_R2_001.fastq.gz
ERR4147226_c2e4.2 ecoli.fasta ERR4147226_c2e4.2_R1_001.fastq.gz ERR4147226_c2e4.2_R2_001.fastq.gz
```
sample reference fwd_pair rev_pair
DRR198805_c1e4 ecoli.fasta DRR198805_c1e4_R1_001.fastq.gz DRR198805_c1e4_R2_001.fastq.gz
#!/bin/bash
REF_FAI=$1
BINNED_REF=$2
BIN_SIZE=${3:-100000}
#for (binStart = start; binStart < (stop - binSize); binStart += binSize) {
awk -v "BS=${BIN_SIZE}" '
BEGIN {
binSize = BS;
binIdx = 0;
}
{
chr = $1;
start = 0;
stop = $2;
for (binStart = start; binStart <= stop; binStart += binSize) {
print chr"\t"binStart"\t"(binStart + binSize)"\tbin-"binIdx;
binIdx++;
}
}
' ${REF_FAI} > ${BINNED_REF}
#!/usr/bin/env Rscript
suppressPackageStartupMessages(require(optparse))
suppressPackageStartupMessages(require(ggplot2))
suppressPackageStartupMessages(require(viridis))
option_list = list(
make_option(c("-i", "--input"), action="store", default=NA, type='character', help="input filename"),
make_option(c("-g", "--genome"), action="store", default=NA, type='character', help="genome name to display in title"),
make_option(c("-b", "--binsize"), action="store", default=NA, type='character', help="size of bins, with unit (eg. 50 kb)"),
make_option(c("-o", "--output"), action="store", default=NA, type='character', help="output filename")
)
opt = parse_args(OptionParser(option_list=option_list))
#d <- read.table(opt$input, header=F, stringsAsFactor=T, col.names=c("chr", "start", "stop", "id", "mutations", "ref_base", "read_base", "check", "info"))
d <- read.table(opt$input, header=F, stringsAsFactor=T, col.names=c("chr", "position", "stop", "id", "mutations"))
#d$chr <- factor(d$chr, levels = c('YLS.canu_hybrid_1', 'YLS.canu_hybrid_2', 'YLS.canu_hybrid_3', 'YLS.canu_hybrid_4', 'YLS.canu_hybrid_5', 'YLS.canu_hybrid_6', 'YLS.canu_hybrid_7', 'YLS.canu_hybrid_8'))
#d$chr <- factor(d$chr, levels = c('chr1', 'chr2', 'chr3', 'chr4', 'chr5', 'chr6', 'chr7', 'chr8', 'chr9', 'chr10', 'chr11', 'chr12', 'chr13', 'chr14', 'chr15', 'chr16', 'chr17', 'chr18', 'chr19', 'chr20', 'chr21', 'chr22', 'chrX', 'chrY'))
d <- with(d, d[order(chr),])
if (!require(ggplot2)) install.packages('ggplot2')
library(ggplot2)
cnt_chr = length(unique(d$chr))
max_pos_chr = aggregate(stop ~ chr, data=d, max)
pdf(opt$output, width=7,height=1+0.2*cnt_chr)
p <- ggplot(data=d, aes(x=position, y=1)) +
facet_grid(chr ~ ., switch='y') +
geom_tile(aes(fill=mutations)) +
ggtitle(paste("SNPs in ", opt$genome, ", binsize=", opt$binsize, sep="")) +
#geom_rect(data=d, mapping=aes(xmin=x1, xmax=x2, ymin=y1, ymax=y2, fill=t), color="black", alpha=0.5) +
#geom_rect(data=d, mapping=aes(xmin=0, xmax=max_pos_chr[chr], ymin=0, ymax=1, fill=t), color="black", alpha=0.5) +
theme(
axis.title.y=element_blank(), #text("contig"),
axis.text.y=element_blank(),
axis.ticks.y=element_blank(),
strip.text.y = element_text(angle = 180)) +
theme(
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank()
#panel.border = element_rect(colour = "black", fill=NA, size=0.1)
) +
#scale_fill_gradient(low="white", high="black", breaks=seq(min(d$mutations),max(d$mutations),(max(d$mutations)-min(d$mutations))/4))
#scale_fill_gradientn(colors = c('darkorange1', 'darkmagenta', 'navyblue'), breaks=seq(min(d$mutations),max(d$mutations),(max(d$mutations)-min(d$mutations))/4))
scale_fill_viridis(direction=-1,breaks=seq(min(d$mutations),max(d$mutations),(max(d$mutations)-min(d$mutations))/4))
#scale_fill_gradientn(colors = c('darkorange1', 'darkmagenta', 'navyblue'), breaks=seq(0, 500, 125))
#scale_fill_gradientn(colours = rainbow(5), breaks=seq(min(d$mutations),max(d$mutations),(max(d$mutations)-min(d$mutations))/4))
#scale_colour_grey(breaks=seq(min(d$mutations),max(d$mutations),(max(d$mutations)-min(d$mutations))/4))
print(p)
dev.off()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment