Skip to content

Commit

Permalink
sync with release version
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ChIPQC@118142 bc3139a8-67e5-0310-9ffc-ced21a209358
  • Loading branch information
Rory Stark committed Jun 3, 2016
1 parent aaa9466 commit b9c9bc1
Show file tree
Hide file tree
Showing 14 changed files with 205 additions and 168 deletions.
13 changes: 7 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
Package: ChIPQC
Type: Package
Title: Quality metrics for ChIPseq data
Version: 1.9.1
Version: 1.9.2
Author: Tom Carroll, Wei Liu, Ines de Santiago, Rory Stark
Maintainer: Tom Carroll <[email protected]>, Rory Stark <[email protected]>
Description: Quality metrics for ChIPseq data
Description: Quality metrics for ChIPseq data.
biocViews: Sequencing, ChIPSeq, QualityControl, ReportWriting
License: GPL (>= 3)
LazyLoad: yes
Depends: R (>= 3.0.0), ggplot2, DiffBind, GenomicRanges (>= 1.17.19)
Imports: BiocGenerics (>= 0.11.3), S4Vectors (>= 0.1.0), IRanges (>= 1.99.17),
Rsamtools (>= 1.17.28), GenomicAlignments (>= 1.1.16),
chipseq (>= 1.12.0), gtools, BiocParallel, methods, reshape2,
Nozzle.R1, Biobase, grDevices, stats, utils
Suggests: BiocStyle, TxDb.Hsapiens.UCSC.hg19.knownGene, TxDb.Hsapiens.UCSC.hg18.knownGene,
TxDb.Mmusculus.UCSC.mm10.knownGene, TxDb.Mmusculus.UCSC.mm9.knownGene,
TxDb.Rnorvegicus.UCSC.rn4.ensGene, TxDb.Celegans.UCSC.ce6.ensGene, TxDb.Dmelanogaster.UCSC.dm3.ensGene
Nozzle.R1, Biobase, grDevices, stats, utils, GenomicFeatures,
TxDb.Hsapiens.UCSC.hg19.knownGene, TxDb.Hsapiens.UCSC.hg18.knownGene,
TxDb.Mmusculus.UCSC.mm10.knownGene, TxDb.Mmusculus.UCSC.mm9.knownGene,
TxDb.Rnorvegicus.UCSC.rn4.ensGene, TxDb.Celegans.UCSC.ce6.ensGene, TxDb.Dmelanogaster.UCSC.dm3.ensGene
Suggests: BiocStyle
Collate: ChIPQCsample-class.R ChIPQCexperiment-class.R sampleQC.R ChIPQC_IF.R plots.r dbaplots.R utilities.R report.r
39 changes: 28 additions & 11 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ importClassesFrom(IRanges, IRanges)

importClassesFrom(methods, character, list, numeric, oldClass)

importMethodsFrom(BiocGenerics, as.data.frame, as.vector, cbind,
colnames, duplicated, lapply, ncol, nrow, order,
paste, rbind, rownames, sapply, strand, table,
unique, unlist, xtabs)
importMethodsFrom(BiocGenerics, as.data.frame, cbind,
colnames, duplicated, lapply, ncol, nrow, order,
paste, rbind, rownames, sapply, strand, table,
unique, xtabs)

importMethodsFrom(BiocParallel, bplapply)

importMethodsFrom(GenomicAlignments, readGAlignments)

importMethodsFrom(IRanges, as.list, as.matrix, "colnames<-",
countOverlaps, coverage, end, flank, gsub, mean, median,
merge, ranges, reduce, resize, "rownames<-",
sd, shiftApply, start, t,
viewMaxs, viewApply, Views, which, which.max, width)
countOverlaps, coverage, end, flank, gsub, mean, median,
merge, ranges, reduce, resize, "rownames<-",
sd, start,
viewMaxs, viewApply, Views, which, which.max, width)

importMethodsFrom(methods, show)

Expand All @@ -27,6 +27,8 @@ import(chipseq)

importFrom(Biobase, selectSome)

importFrom(BiocGenerics, as.vector, unlist)

import(DiffBind)

import(GenomicRanges)
Expand All @@ -35,7 +37,7 @@ importFrom(ggplot2, aes, aes_string, element_blank, element_text,
facet_grid, facet_wrap, geom_bar, geom_boxplot, geom_line,
geom_path, geom_rect, geom_tile, ggplot, ggsave, labs,
scale_fill_gradient2, scale_fill_manual, theme, xlab, xlim,
ylab)
ylab, coord_cartesian)

importFrom(grDevices, dev.off, png)

Expand All @@ -46,11 +48,14 @@ importFrom(IRanges, "%over%", IRanges)
importFrom(methods, as, new)

importFrom(Nozzle.R1, addTo, asLink, asStrong, newCustomReport,
newFigure, newList, newParagraph, newSection, newSubSection,
newTable, writeReport)
newFigure, newList, newParagraph, newSection, newSubSection,
newTable, writeReport)

importFrom(reshape2, melt)

importFrom(GenomicFeatures, fiveUTRsByTranscript, threeUTRsByTranscript, cdsBy, intronsByTranscript,
transcripts)

importFrom(Rsamtools, bamFlagAsBitMatrix, BamFile, index, indexBam)

importFrom(stats, as.formula, formula, weighted.mean)
Expand All @@ -59,6 +64,8 @@ importFrom(utils, browseURL, read.delim, read.table, sessionInfo)

importFrom(Nozzle.R1, IMAGE.TYPE.RASTER, PROTECTION.PUBLIC)

importFrom("grDevices", "boxplot.stats")

export('ChIPQCsample','ChIPQC')
exportMethods(
"averagepeaksignal",
Expand Down Expand Up @@ -106,3 +113,13 @@ exportClasses(
"ChIPQCsample",
"ChIPQCexperiment"
)

#importFrom(TxDb.Hsapiens.UCSC.hg20.knownGene,TxDb.Hsapiens.UCSC.hg20.knownGene)
importFrom(TxDb.Hsapiens.UCSC.hg19.knownGene,TxDb.Hsapiens.UCSC.hg19.knownGene)
importFrom(TxDb.Hsapiens.UCSC.hg18.knownGene,TxDb.Hsapiens.UCSC.hg18.knownGene)
importFrom(TxDb.Mmusculus.UCSC.mm10.knownGene, TxDb.Mmusculus.UCSC.mm10.knownGene)
importFrom(TxDb.Mmusculus.UCSC.mm9.knownGene,TxDb.Mmusculus.UCSC.mm9.knownGene)
importFrom(TxDb.Rnorvegicus.UCSC.rn4.ensGene, TxDb.Rnorvegicus.UCSC.rn4.ensGene)
importFrom(TxDb.Celegans.UCSC.ce6.ensGene,TxDb.Celegans.UCSC.ce6.ensGene)
importFrom(TxDb.Dmelanogaster.UCSC.dm3.ensGene,TxDb.Dmelanogaster.UCSC.dm3.ensGene)

33 changes: 23 additions & 10 deletions R/ChIPQC_IF.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
ChIPQCsample = function(reads, peaks, annotation=NULL, chromosomes=NULL,
mapQCth=15, blacklist, profileWin=400,fragmentLength=125,shifts=1:300,runCrossCor=FALSE,verboseT=TRUE) {

if(missing(peaks)) peaks=NULL
if(missing(blacklist)) blacklist=NULL
res = sampleQC(bamFile=reads, bedFile=peaks, GeneAnnotation=annotation,blklist=blacklist,ChrOfInterest=chromosomes,
Window=profileWin,FragmentLength=fragmentLength,
shiftWindowStart=min(shifts),shiftWindowEnd=max(shifts),runCrossCor=runCrossCor,verboseT=verboseT)

return(res)
if(missing(peaks)) peaks=NULL
if(missing(blacklist)) blacklist=NULL
res = sampleQC(bamFile=reads, bedFile=peaks, GeneAnnotation=annotation,blklist=blacklist,ChrOfInterest=chromosomes,
Window=profileWin,FragmentLength=fragmentLength,
shiftWindowStart=min(shifts),shiftWindowEnd=max(shifts),runCrossCor=runCrossCor,verboseT=verboseT)
return(res)
}

ChIPQC = function(experiment, annotation, chromosomes, samples,
Expand Down Expand Up @@ -116,18 +116,30 @@ ChIPQC = function(experiment, annotation, chromosomes, samples,

addconsensus = FALSE
addcontrols = FALSE
peaks=NA
setNull <- TRUE
peaks <- NA
if(consensus!=FALSE) {
addcontrols = TRUE
addconsensus = TRUE
if(consensus!=TRUE) {
peaks = consensus
setNull <- FALSE
} else {
setNull <- TRUE
peaks = dba.peakset(experiment,bRetrieve=T,numCols=3,
DataType=DBA_DATA_FRAME)
}
} else if(bCount) {
addcontrols = TRUE
if(consensus==FALSE) {
setNull <- TRUE
peaks = dba.peakset(experiment,bRetrieve=T,
DataType=DBA_DATA_FRAME)[,1:4]
}
}

if(addcontrols && controls) {
message("Adding controls...")
startpos = length(samplelist) - controls
for(i in 1:controls) {
metadata = getMeta(meta,names(samplelist)[[startpos+i]])
Expand All @@ -142,7 +154,8 @@ ChIPQC = function(experiment, annotation, chromosomes, samples,
}
meta = data.frame(t(experiment$class))
}
if(is.na(peaks)) {

if(is.na(peaks) || setNull==TRUE) {
peaks = NULL
}

Expand Down
88 changes: 44 additions & 44 deletions R/plots.r
Original file line number Diff line number Diff line change
Expand Up @@ -508,50 +508,50 @@ setMethod("plotRegi", "ChIPQCsample", function(object){

#################################################################
#################################################################
setGeneric("plotSSD", function(object="ChIPQCexperiment",method="Coverage",facet=TRUE,
facetBy=c("Tissue","Factor"),
colourBy="Replicate",
lineBy=NULL,
addMetaData=NULL
)
standardGeneric("plotSSD")
)

setMethod("plotSSD", "ChIPQCexperiment", function(object,method="Coverage",facet=TRUE,
facetBy=c("Tissue","Factor"),
colourBy="Replicate",
lineBy=NULL,
addMetaData=NULL
){

ssdvector <- ssd(object)
for(sample in names(ssdvector)){
input <- sample
}



toMelt <- data.frame("Shift_Size"=seq(1,shiftlength),
#"metadataOfInterest"=metadataOfInterest,
ccvector)
CCDataFrame <- melt(toMelt,id.vars=c("Shift_Size"))


metadataOpts <- mergeMetadata(object,addMetaData,facetBy,colourBy,lineBy)


CCDataFrameWithMetaData <- merge(CCDataFrame,metadataOpts$metadata,by.x=2,by.y=1,all=FALSE)

colnames(CCDataFrameWithMetaData)[1:3] <- c("Sample","Shift_Size","CC_Score")

Plot <- makeCCplot(CCDataFrameWithMetaData,shiftlength,readlen)
Plot <- Plot +
metadataOpts$facetBy +
metadataOpts$colour +
metadataOpts$lineType

return(Plot)
})
# setGeneric("plotSSD", function(object="ChIPQCexperiment",method="Coverage",facet=TRUE,
# facetBy=c("Tissue","Factor"),
# colourBy="Replicate",
# lineBy=NULL,
# addMetaData=NULL
# )
# standardGeneric("plotSSD")
# )
#
# setMethod("plotSSD", "ChIPQCexperiment", function(object,method="Coverage",facet=TRUE,
# facetBy=c("Tissue","Factor"),
# colourBy="Replicate",
# lineBy=NULL,
# addMetaData=NULL
# ){
#
# ssdvector <- ssd(object)
# for(sample in names(ssdvector)){
# input <- sample
# }
#
#
#
# toMelt <- data.frame("Shift_Size"=seq(1,shiftlength),
# #"metadataOfInterest"=metadataOfInterest,
# ccvector)
# CCDataFrame <- melt(toMelt,id.vars=c("Shift_Size"))
#
#
# metadataOpts <- mergeMetadata(object,addMetaData,facetBy,colourBy,lineBy)
#
#
# CCDataFrameWithMetaData <- merge(CCDataFrame,metadataOpts$metadata,by.x=2,by.y=1,all=FALSE)
#
# colnames(CCDataFrameWithMetaData)[1:3] <- c("Sample","Shift_Size","CC_Score")
#
# Plot <- makeCCplot(CCDataFrameWithMetaData,shiftlength,readlen)
# Plot <- Plot +
# metadataOpts$facetBy +
# metadataOpts$colour +
# metadataOpts$lineType
#
# return(Plot)
# })

#################################################################
#################################################################
Expand Down
22 changes: 11 additions & 11 deletions R/sampleQC.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ sampleQC <- function(bamFile,bedFile=NULL,blklist=NULL,ChrOfInterest=NULL,GeneAn
# require(GenomicAlignments)

ChrLengths <- scanBamHeader(bamFile)[[1]]$targets

if(length(ChrLengths[ChrLengths < shiftWindowEnd - shiftWindowStart]) > 0){
message("Removing ",length(ChrLengths[ChrLengths < shiftWindowEnd - shiftWindowStart]),
" chromosomes with length less than cross-coverage shift")
Expand Down Expand Up @@ -119,7 +119,7 @@ sampleQC <- function(bamFile,bedFile=NULL,blklist=NULL,ChrOfInterest=NULL,GeneAn
if(verboseT == T){

message("Calculating coverage histogram for ",names(ChrLengths)[k],"\n")

}

CovHist <- c(CovHist,list(colSums(table_RleList(Cov))))
Expand Down Expand Up @@ -397,7 +397,7 @@ GetGRanges <- function(LoadFile,AllChr=NULL,ChrOfInterest=NULL,simple=FALSE,sepr
}
}else{
if(class(LoadFile) == "character"){
RangesTable <- read.delim(LoadFile,sep=sepr,header=TRUE,comment="#")
RangesTable <- read.delim(LoadFile,sep=sepr,header=TRUE,comment.char="#")
}else if(class(LoadFile) == "matrix"){
RangesTable <- as.data.frame(LoadFile)
} else{
Expand Down Expand Up @@ -472,28 +472,28 @@ getAnnotation = function(GeneAnnotation="hg19",AllChr){

if(!is.null(GeneAnnotation)){
if(GeneAnnotation == "hg19"){
require(TxDb.Hsapiens.UCSC.hg19.knownGene)
#require(TxDb.Hsapiens.UCSC.hg19.knownGene)
txdb <- TxDb.Hsapiens.UCSC.hg19.knownGene
} else if(GeneAnnotation == "hg20"){
require(TxDb.Hsapiens.UCSC.hg20.knownGene)
#require(TxDb.Hsapiens.UCSC.hg20.knownGene)
txdb <- TxDb.Hsapiens.UCSC.hg20.knownGene
}else if(GeneAnnotation == "hg18"){
require(TxDb.Hsapiens.UCSC.hg18.knownGene)
#require(TxDb.Hsapiens.UCSC.hg18.knownGene)
txdb <- TxDb.Hsapiens.UCSC.hg18.knownGene
}else if(GeneAnnotation == "mm10"){
require(TxDb.Mmusculus.UCSC.mm10.knownGene)
#require(TxDb.Mmusculus.UCSC.mm10.knownGene)
txdb <- TxDb.Mmusculus.UCSC.mm10.knownGene
} else if(GeneAnnotation == "mm9"){
require(TxDb.Mmusculus.UCSC.mm9.knownGene)
#require(TxDb.Mmusculus.UCSC.mm9.knownGene)
txdb <- TxDb.Mmusculus.UCSC.mm9.knownGene
} else if(GeneAnnotation == "rn4"){
require(TxDb.Rnorvegicus.UCSC.rn4.ensGene)
#require(TxDb.Rnorvegicus.UCSC.rn4.ensGene)
txdb <- TxDb.Rnorvegicus.UCSC.rn4.ensGene
} else if(GeneAnnotation == "ce6"){
require(TxDb.Celegans.UCSC.ce6.ensGene)
#require(TxDb.Celegans.UCSC.ce6.ensGene)
txdb <- TxDb.Celegans.UCSC.ce6.ensGene
} else if(GeneAnnotation == "dm3"){
require(TxDb.Dmelanogaster.UCSC.dm3.ensGene)
#require(TxDb.Dmelanogaster.UCSC.dm3.ensGene)
txdb <- TxDb.Dmelanogaster.UCSC.dm3.ensGene
}else {
stop('Unsupported annotation:',GeneAnnotation)
Expand Down
6 changes: 6 additions & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
\title{ChIPQC News}
\encoding{UTF-8}

\section{Version 1.9.2}{
\itemize{
\item{Dependancy cleanup; update handling of how control samples are added}
}
}

\section{Version 1.7.2}{
\itemize{
\item{Convert data objects for DiffBind compatibility}
Expand Down
4 changes: 2 additions & 2 deletions man/ChIPQCsample-class.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ Class \code{"\linkS4class{GRanges}"}
}
}
\references{
Carroll TS, Liang Z, Salama R, Stark R and Santiago Id (in press). Impact of artefact removal on ChIP quality metrics in ChIP-seq and ChIP-exo data. Frontiers in Genetics.
Carroll TS, Liang Z, Salama R, Stark R and Santiago Id (in press). Impact of artefact removal on ChIP quality metrics in ChIP-seq and ChIP-exo data. Frontiers in Genetics.
}
\author{Thomas Carroll and Rory Stark}

Expand All @@ -146,4 +146,4 @@ readlength(ex1)
fragmentlength(ex1)
}

\keyword{classes}
\keyword{classes}
2 changes: 1 addition & 1 deletion man/plotCC-methods.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Supported methods include:
}}

\note{
plotCC uses \code{\link{ggplot2}} for plotting, and returns a \code{ggplot2} plot dataframe.
plotCC uses \code{ggplot2} for plotting, and returns a \code{ggplot2} plot dataframe.
}

\keyword{methods}
Expand Down
2 changes: 1 addition & 1 deletion man/plotCoverageHist-methods.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Generate coverage histogram plots for a sample.
}}

\note{
Uses \code{\link{ggplot2}} for plotting, and returns a \code{ggplot2} plot dataframe.
Uses \code{ggplot2} for plotting, and returns a \code{ggplot2} plot dataframe.
}

\keyword{methods}
Expand Down
Loading

0 comments on commit b9c9bc1

Please sign in to comment.