Skip to content

Commit

Permalink
Implemented an improved version to check whether bams have been mappe…
Browse files Browse the repository at this point in the history
…d to same reference genome
  • Loading branch information
Thomas Kuilman committed Jun 10, 2015
1 parent ea99c8a commit bebaee5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Package: CopywriteR
Type: Package
Title: Copy number information from targeted sequencing using off-target reads
Version: 2.0.4
Version: 2.0.5
Date: 2014-09-23
Author: Thomas Kuilman
Maintainer: Thomas Kuilman <t.kuilman@nki.nl>
Imports: matrixStats, gtools, data.table, S4Vectors, chipseq, IRanges, Rsamtools, DNAcopy, GenomicAlignments, GenomicRanges, CopyhelpeR, GenomeInfoDb, futile.logger
Depends: R(>= 3.2), BiocParallel
Depends: R(>= 3.1), BiocParallel
Suggests: BiocStyle, SCLCBam, snow
URL: https://github.com/PeeperLab/CopywriteR
Description: CopywriteR extracts DNA copy number information from targeted sequencing by utiizing off-target reads. It allows for extracting uniformly distributed copy number information, can be used without reference, and can be applied to sequencing data obtained from various techniques including chromatin immunoprecipitation and target enrichment on small gene panels. Thereby, CopywriteR constitutes a widely applicable alternative to available copy number detection tools.
Expand Down
26 changes: 14 additions & 12 deletions R/CopywriteR.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ CopywriteR <- function(sample.control, destination.folder, reference.folder,
header <- scanBamHeader(samp)
chr.sort.mode <- c(chr.sort.mode, list(header[[1]]$text$'@HD'))
current.chr.names <- names(header[[1]]$targets)
chr.names <- c(chr.names, current.chr.names)
chr.lengths <- c(chr.lengths, header[[1]]$targets)
prefixes <- append(prefixes, gsub("[[:digit:]]|X|Y|M|T",
"", chr.names[1])[1])
chr.names <- c(chr.names, list(current.chr.names))
chr.lengths <- c(chr.lengths, list(header[[1]]$targets))
prefixes <- append(prefixes, gsub("[[:digit:]]|X|Y|M|T",
"", current.chr.names)[1])
}
}, error = function(e) {
stop(.wrap("The BAM file header of file", sQuote(samp), "is corrupted",
Expand All @@ -162,14 +162,16 @@ CopywriteR <- function(sample.control, destination.folder, reference.folder,
stop(.wrap("The bam files have different chromosome name prefixes.",
"Please adjust the .bam files such that they contain the",
"same chromosome notation."))
} else if (!length(unique(chr.names)) * length(sample.paths) == length(chr.names)) {
stop(.wrap("The bam files have been mapped to different reference",
"genomes. Please run only .bam files mapped to the same",
"reference genome together."))
} else if (!length(unique(chr.lengths)) * length(sample.paths) == length(chr.lengths)) {
stop(.wrap("The bam files have different chromosome names. Please",
"adjust the .bam files such that they contain the same",
"chromosome notation."))
} else if (length(chr.names) > 1) {
if (!Reduce(function(x,y) {identical(x,y)}, chr.names)) {
stop(.wrap("The bam files have been mapped to different reference",
"genomes (the chromosome names are not identical). Please run",
"only .bam files mapped to the same reference genome together."))
} else if (!Reduce(function(x,y) {identical(x,y)}, chr.lengths)) {
stop(.wrap("The bam files have been mapped to different reference",
"genomes (the chromosome lengths are not identical). Please run",
"only .bam files mapped to the same reference genome together."))
}
} else {
prefixes <- prefixes[1]

Expand Down

0 comments on commit bebaee5

Please sign in to comment.