-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #218 from uclahs-cds/sfitz-plot-intersections
Sfitz plot intersections
- Loading branch information
Showing
9 changed files
with
127 additions
and
11 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
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,23 @@ | ||
ARG MINIFORGE_VERSION=22.9.0-2 | ||
ARG UBUNTU_VERSION=20.04 | ||
|
||
FROM condaforge/mambaforge:${MINIFORGE_VERSION} AS builder | ||
|
||
RUN mamba create -qy -p /usr/local \ | ||
'r-base>=4.2.1' \ | ||
r-argparse \ | ||
r-VennDiagram | ||
|
||
# Copy from builder into final image | ||
FROM ubuntu:${UBUNTU_VERSION} AS final | ||
COPY --from=builder /usr/local /usr/local | ||
|
||
# Add a new user/group called bldocker | ||
RUN groupadd -g 500001 bldocker \ | ||
&& useradd -r -u 500001 -g bldocker bldocker | ||
|
||
# Change the default user to bldocker from root | ||
USER bldocker | ||
|
||
LABEL maintainer="Sorel Fitz-Gibbon <sfitzgibbon@mednet.ucla.edu>" | ||
LABEL org.opencontainers.image.source=https://github.com/uclahs-cds/call-ssnv-r |
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
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,50 @@ | ||
# Script to plot a Venn diagram of shared variants from the different SNV calling algorithms, using the output of BCFtools isec | ||
# Initial commit: Sorel Fitz-Gibbon 2023-06-29 | ||
# Input: | ||
# -i, --isec_dir: The directory containing the output from BCFtools intersect | ||
# -d, --dataset: The dataset ID passed from nextflow | ||
# Output: | ||
# - A Venn diagram of shared variant counts from the BCFtools intersection of the VCF files | ||
|
||
## Setup the environment ########################################################################### | ||
library('argparse'); | ||
library('VennDiagram'); | ||
|
||
## Parse the arguments ############################################################################# | ||
parser <- ArgumentParser(); | ||
parser$add_argument('-i', '--isec_dir', help = 'The directory containing the output from BCFtools intersect', type = 'character'); | ||
parser$add_argument('-o', '--outfile', help = 'Output filename', type = 'character'); | ||
args <- parser$parse_args(); | ||
|
||
## Function: plot venn diagram ##################################################################### | ||
plot.venn <- function(tool.variants, outfile) { | ||
VennDiagram::venn.diagram( | ||
tool.variants.ordered, | ||
filename = outfile, | ||
fill = c('orange', 'red', 'green', 'blue'), | ||
lty = 'dashed', | ||
cex = 1, | ||
cat.cex = 0.8, | ||
cat.col = 'black' | ||
); | ||
} | ||
|
||
### Main ########################################################################################### | ||
# Get intersection counts from BCFtools isec output and format for plotting | ||
algorithms <- readLines(paste0(args$isec_dir,'/README.txt')); | ||
algorithms <- algorithms[grep(paste0('^', args$isec_dir), algorithms)]; | ||
algorithms <- gsub(paste0(args$isec_dir,'.*\t'), '', algorithms); | ||
algorithms <- gsub('-.*', '', algorithms); | ||
sites <- read.table(paste0(args$isec_dir,'/sites.txt'), header = FALSE, colClasses = 'character'); | ||
split.col <- strsplit(as.character(sites$V5), ''); | ||
sites$col1 <- sapply(split.col, '[', 1); | ||
sites$col2 <- sapply(split.col, '[', 2); | ||
sites$col3 <- sapply(split.col, '[', 3); | ||
sites$col4 <- sapply(split.col, '[', 4); | ||
sites$V5 <- NULL; | ||
header <- c('chrom', 'pos', 'ref', 'alt', algorithms); | ||
colnames(sites) <- header | ||
variants <- paste(sites$chrom, sites$pos, sep = '_'); | ||
tool.variants <- lapply(sites[, algorithms], function(x) variants[x == 1]) | ||
tool.variants.ordered <- tool.variants[order(lengths(tool.variants), decreasing = TRUE)]; | ||
plot.venn(tool.variants.ordered, args$outfile); |
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