Skip to content
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
32 changes: 28 additions & 4 deletions R/core.R
Original file line number Diff line number Diff line change
Expand Up @@ -759,9 +759,13 @@ readData <- function(bamfiles, binSize, species = "Human", filterChromosomes=c("
Biobase::pData(readCounts)["genome"] = genome
coverage = (readCounts@phenoData@data$used.reads * (as.numeric(isPaired) + 1) * read_size) / 3.2e9
Biobase::pData(readCounts)["coverage"] = coverage
} else if(species == "Mouse"){
Biobase::pData(readCounts)["genome"] = genome
coverage = (readCounts@phenoData@data$used.reads * (as.numeric(isPaired) + 1) * read_size) / 2.7e9
Biobase::pData(readCounts)["coverage"] = coverage
}
if(species == "Human" & extendedBlacklisting){

if(extendedBlacklisting & (species == "Human" | species == "Mouse")){
if(binSize < 10) stop("blacklisting doesn't support binsizes smaller than 10kb")
# this is because our blacklisted regions have a resolution of 10kb
if(binSize %in% c(200, 2000, 5000) && genome == "GRCh37"){
Expand Down Expand Up @@ -809,7 +813,9 @@ readData <- function(bamfiles, binSize, species = "Human", filterChromosomes=c("

if(species == "Human"){
Biobase::experimentData(readCounts)@other = list(species="Human", genome=genome)
}else{
} else if(species == "Mouse"){
Biobase::experimentData(readCounts)@other = list(species="Mouse", genome=genome)
} else {
Biobase::experimentData(readCounts)@other = list(species=species)
}

Expand All @@ -823,7 +829,7 @@ readData <- function(bamfiles, binSize, species = "Human", filterChromosomes=c("
#' @return QDNAseq object with updated bin usability
readFilter <- function(readCounts, genome="GRCh37"){

stopifnot(genome %in% c("GRCh37", "GRCh38"))
stopifnot(genome %in% c("GRCh37", "GRCh38", "GRCm38"))
if(genome == "GRCh37"){
gr = createGR(readCounts[,1,drop=FALSE])
excluded_regions_bed = readr::read_tsv(file.path(BASEDIR, "data/blacklisting/final_exclude_regions_hg19.bed"),
Expand All @@ -836,6 +842,24 @@ readFilter <- function(readCounts, genome="GRCh37"){
warning("blacklist has been optimized for GRCh37 only")
stop("Not supported")
}
if(genome == "GRCm38"){
gr = createGR(readCounts[,1,drop=FALSE])
valid_chrs = seqlevels(gr)
blacklist_bed = readr::read_tsv(file.path(BASEDIR, "data/blacklisting/mm10-blacklist.v2.bed"),
col_names = c("chromosome", "start", "end", "reason"), col_types="ciic")
pericentro_bed = readr::read_tsv(file.path(BASEDIR, "data/blacklisting/mm10_pericentromeric_exclude.bed"),
col_names = c("chromosome", "start", "end"), col_types="cii")
segdup_bed = readr::read_tsv(file.path(BASEDIR, "data/blacklisting/mm10_segdup.bed"),
col_names = c("chromosome", "start", "end"), col_types="cii")
excluded_regions_bed = dplyr::bind_rows(
blacklist_bed[, c("chromosome", "start", "end")],
pericentro_bed,
segdup_bed[segdup_bed$chromosome %in% valid_chrs, ]
)
excluded_regions = GRanges(seqnames=excluded_regions_bed$chromosome,
ranges = IRanges(start=excluded_regions_bed$start+1, end=excluded_regions_bed$end),
seqinfo = seqinfo(gr))
}

hits <- findOverlaps(excluded_regions, gr)

Expand Down
21 changes: 21 additions & 0 deletions data/blacklisting/mm10_pericentromeric_exclude.bed
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
chr1 0 3000000
chr2 0 3000000
chr3 0 3000000
chr4 0 3000000
chr5 0 3000000
chr6 0 3000000
chr7 0 3000000
chr8 0 3000000
chr9 0 3000000
chr10 0 3000000
chr11 0 3000000
chr12 0 3000000
chr13 0 3000000
chr14 0 3000000
chr15 0 3000000
chr16 0 3000000
chr17 0 3000000
chr18 0 3000000
chr19 0 3000000
chrX 0 3000000
chrY 0 3000000
Loading