Commit 5812b169 authored by Sudeep Sahadevan's avatar Sudeep Sahadevan

toBED function fix, URL fix

parent 25e42f15
Package: DEWSeq
Type: Package
Title: Differential Expressed Windows Based on Negative Binomial Distribution
Version: 0.99.2
Version: 0.99.4
Author: Sudeep Sahadevan <sahadeva@embl.de>, Thomas Schwarzl <schwarzl@embl.de>
Maintainer: Hentze bioinformatics team <biohentze@embl.de>
Description: Differential expression analysis of windows for next-generation sequencing data like eCLIP or iCLIP data.
......@@ -31,7 +31,7 @@ biocViews: Sequencing,
FunctionalGenomics,
DifferentialExpression
License: LGPL (>= 3)
URL: https://git.embl.de/biohentze/DEWSeq
URL: https://github.com/EMBL-Hentze-group/DEWSeq/
Encoding: UTF-8
LazyData: false
RoxygenNote: 6.1.1
......
......@@ -69,19 +69,23 @@ toBED <- function(windowRes,regionRes,fileName,
if(nrow(windowRes)==0){
stop('There are no significant windows/regions under the current threshold!')
}
regionRes <- regionRes[ regionRes$windows_in_region>1, ]
windowRes <- windowRes[order(windowRes$chromosome,windowRes$begin),]
regionRes <- regionRes[order(regionRes$chromosome,regionRes$region_begin),]
regionRes$strand <- as.character(regionRes$strand)
windowRes$strand <- as.character(windowRes$strand)
# RGB color space for a red color, to show windows/regions as up regulated
itemRGB <- '237,28,36' # #ed1c24
windowRes$RGB <- itemRGB
regionRes$RGB <- itemRGB
windowRes <- windowRes[,c('chromosome','begin','end','unique_id',
padjCol,'strand','begin','end','RGB')]
regionRes <- regionRes[,c('chromosome','region_begin','region_end','regionStartId',
'padj_mean','strand','region_begin','region_end','RGB')]
windowsInRegion <- sum(regionRes$windows_in_region>1)
if(windowsInRegion>0){
regionRes <- regionRes[ regionRes$windows_in_region>1, ]
regionRes <- regionRes[order(regionRes$chromosome,regionRes$region_begin),]
regionRes$strand <- as.character(regionRes$strand)
regionRes$RGB <- itemRGB
regionRes <- regionRes[,c('chromosome','region_begin','region_end','regionStartId',
'padj_mean','strand','region_begin','region_end','RGB')]
}
# convert pvalues to bed scores with range 100-1000
bedrange <- c(100,1000) # min max values for bed score
allMin <- 1-padjThresh
......@@ -89,14 +93,16 @@ toBED <- function(windowRes,regionRes,fileName,
# windows
windowRes[,padjCol] <- 1-windowRes[,padjCol]
windowRes[,padjCol] <- round(((windowRes[,padjCol]-allMin)/(allMax-allMin))*(bedrange[2]-bedrange[1])+bedrange[1])
# regions
rmin <- floor(min(regionRes$padj_mean))
regionRes$padj_mean <- 1-regionRes$padj_mean
regionRes$padj_mean <- round(((regionRes$padj_mean-allMin)/(allMax-allMin))*(bedrange[2]-bedrange[1])+bedrange[1])
# now start writing
write(sprintf('track name="%s" description="%s" visibility=2 itemRgb="On" useScore=1',trackName,description),file=fileName)
for(i in seq_len(nrow(regionRes))){
write(paste(regionRes[i,],collapse="\t"),file=fileName,append=TRUE)
# regions
if(windowsInRegion>0){
rmin <- floor(min(regionRes$padj_mean))
regionRes$padj_mean <- 1-regionRes$padj_mean
regionRes$padj_mean <- round(((regionRes$padj_mean-allMin)/(allMax-allMin))*(bedrange[2]-bedrange[1])+bedrange[1])
# now start writing
for(i in seq_len(nrow(regionRes))){
write(paste(regionRes[i,],collapse="\t"),file=fileName,append=TRUE)
}
}
for(i in seq_len(nrow(windowRes))){
write(paste(windowRes[i,],collapse="\t"),file=fileName,append=TRUE)
......
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