Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sfitz fix plot venn bug #232

Merged
merged 5 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [7.0.0-rc.1] - 2023-08-28

### Changed
- Update plot-venn.R to work with all numbers of algorithms greater than two

### Added
- Add compression of `SomaticSniper` `bam-readcount` output and move to `intermediate` directory
- Add `ncbi_build` parameter
Expand Down
30 changes: 19 additions & 11 deletions r-scripts/plot-venn.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@ parser$add_argument('-s', '--isec_sites', help = 'The sites.txt file from BCFtoo
parser$add_argument('-o', '--outfile', help = 'Output filename', type = 'character');
args <- parser$parse_args();

## config ##########################################################################################
color.map <- list(
Mutect2 = 'orange',
SomaticSniper = 'red',
MuSE = 'green',
Strelka2 = 'blue'
)

## Function: plot venn diagram #####################################################################
plot.venn <- function(tool.variants, outfile) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sorelfitzgibbon
I have adapted your script for plotting and changed some settings of venn.diagram here: https://github.com/uclahs-cds/project-disease-HeadNeckTumor-ATHC-000072-WholeGenomeLandscape/blob/b1c5fe1d7244aeea37ca40bcb4b2b8bd948b3057/analysis_WGS/pipeline/recSNV/consensusVCF/plot.venn.diagram.R#L41

You can check if some of the arguments might be useful to you?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth looking into if any arguments can be used/added

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maotian06 and I decided nothing needs to be added at this time

VennDiagram::venn.diagram(
tool.variants.ordered,
tool.variants,
filename = outfile,
fill = c('orange', 'red', 'green', 'blue'),
fill = unlist(color.map[algorithms]),
lty = 'dashed',
cex = 1,
cat.cex = 0.8,
Expand All @@ -39,18 +47,18 @@ algorithms <- gsub('isec-1-or-more.*\t', '', algorithms);
algorithms <- gsub('-.*', '', algorithms);

sites <- read.table(args$isec_sites, header = FALSE, colClasses = 'character');
sites.original.ncol <- ncol(sites);
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);
if (length(split.col[[1]]) != length(algorithms)) {
stop('Number of algorithms does not match number of columns in sites.txt file');
}
for (i in 1:length(split.col[[1]])) {
sites[, i + sites.original.ncol ] <- sapply(split.col, '[', i);
}
sites$V5 <- NULL;

header <- c('chrom', 'pos', 'ref', 'alt', algorithms);
colnames(sites) <- header
colnames(sites) <- c('chrom', 'pos', 'ref', 'alt', algorithms);

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)];
yashpatel6 marked this conversation as resolved.
Show resolved Hide resolved

plot.venn(tool.variants.ordered, args$outfile);
plot.venn(tool.variants, args$outfile);
Loading