Skip to content

Commit

Permalink
Merge pull request #31 from m-jahn/dev
Browse files Browse the repository at this point in the history
feat: various improvements for CRAN release version 1.4.0
  • Loading branch information
m-jahn authored May 6, 2024
2 parents d4f7f42 + f61e6d2 commit 3984adf
Show file tree
Hide file tree
Showing 55 changed files with 1,621 additions and 1,046 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ inst/doc
.Rhistory
.Rproj*
.Rproj.user
vignettes/*.html
vignettes/png/*
78 changes: 35 additions & 43 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,68 +1,60 @@
Package: ggcoverage
Type: Package
Package: ggcoverage
Title: Visualize Genome/Protein Coverage with Various Annotations
Version: 1.3.0
Version: 1.4.0
Authors@R: c(
person(given = "Yabing",
family = "Song",
role = c("aut", "cre"),
email = "[email protected]"),
person(given = "Michael",
family = "Jahn",
email = "[email protected]",
role = "aut",
person("Yabing", "Song", , "[email protected]", role = c("aut", "cre", "cph")),
person("Michael", "Jahn", , "[email protected]", role = c("aut", "cph"),
comment = c(ORCID = "0000-0002-3913-153X"))
)
Maintainer: Yabing Song <[email protected]>
Description: The goal of 'ggcoverage' is to simplify the process of visualizing genome/protein coverage. It contains functions to
load data from BAM, BigWig, BedGraph or txt/xlsx files, create genome/protein coverage plot, add various annotations to
the coverage plot, including base and amino acid annotation, GC annotation, gene annotation, transcript annotation, ideogram annotation,
peak annotation, contact map annotation, link annotation and peotein feature annotation.
Maintainer: Michael Jahn <[email protected]>
Description: The goal of 'ggcoverage' is to simplify the process of
visualizing genome/protein coverage. It contains functions to load
data from BAM, BigWig, BedGraph or txt/xlsx files, create
genome/protein coverage plots, add various annotations to the coverage
plot, including base and amino acid annotation, GC annotation, gene
annotation, transcript annotation, ideogram annotation, peak
annotation, contact map annotation, link annotation and protein
feature annotation.
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.3.1
URL: https://showteeth.github.io/ggcoverage/, https://github.com/showteeth/ggcoverage
URL: https://showteeth.github.io/ggcoverage/,
https://github.com/showteeth/ggcoverage
BugReports: https://github.com/showteeth/ggcoverage/issues
biocViews:
Imports:
BiocParallel,
Biostrings,
dplyr,
GenomeInfoDb,
GenomicAlignments,
GenomicRanges,
ggbio,
ggh4x,
ggpattern,
ggplot2,
ggrepel,
grDevices,
gridExtra,
IRanges,
magrittr,
methods,
patchwork,
RColorBrewer,
rlang,
Rsamtools,
rtracklayer,
scales,
stats,
utils,
methods,
GenomeInfoDb,
S4Vectors,
Biostrings,
BSgenome,
GenomicAlignments,
reshape2,
seqinr,
ggforce,
HiCBricks,
ggpattern,
BiocParallel,
openxlsx,
stringr,
gridExtra
utils
Suggests:
rmarkdown,
knitr,
BiocStyle,
htmltools,
BSgenome.Hsapiens.UCSC.hg19,
ggbio,
ggforce,
graphics,
HiCDataHumanIMR90
VignetteBuilder: knitr
HiCBricks,
HiCDataHumanIMR90,
htmltools,
knitr,
rmarkdown
VignetteBuilder:
knitr
biocViews:
Encoding: UTF-8
RoxygenNote: 7.3.1
26 changes: 14 additions & 12 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export(FormatTrack)
export(GetConsensusPeak)
export(GetPlotData)
export(LoadTrackFile)
export(geom_arrows)
export(geom_base)
export(geom_cnv)
export(geom_coverage)
Expand Down Expand Up @@ -45,14 +46,14 @@ export(theme_protein2)
export(theme_tad)
export(theme_tad2)
export(theme_transcript)
import(HiCBricks)
importFrom(BSgenome,getSeq)
importFrom(BiocParallel,MulticoreParam)
importFrom(BiocParallel,bplapply)
importFrom(BiocParallel,register)
importFrom(Biostrings,getSeq)
importFrom(Biostrings,letterFrequency)
importFrom(Biostrings,readAAStringSet)
importFrom(Biostrings,readDNAStringSet)
importFrom(Biostrings,translate)
importFrom(GenomeInfoDb,"seqlengths<-")
importFrom(GenomeInfoDb,seqlengths)
importFrom(GenomeInfoDb,seqnames)
Expand All @@ -69,10 +70,9 @@ importFrom(GenomicRanges,trim)
importFrom(IRanges,IRanges)
importFrom(IRanges,findOverlaps)
importFrom(IRanges,subsetByOverlaps)
importFrom(RColorBrewer,brewer.pal)
importFrom(Rsamtools,ScanBamParam)
importFrom(Rsamtools,indexBam)
importFrom(S4Vectors,"values<-")
importFrom(dplyr,"%>%")
importFrom(dplyr,all_of)
importFrom(dplyr,arrange)
importFrom(dplyr,filter)
Expand All @@ -81,8 +81,6 @@ importFrom(dplyr,mutate)
importFrom(dplyr,select)
importFrom(dplyr,summarise)
importFrom(dplyr,summarize)
importFrom(ggbio,layout_karyogram)
importFrom(ggforce,geom_bezier)
importFrom(ggh4x,elem_list_rect)
importFrom(ggh4x,facet_wrap2)
importFrom(ggh4x,strip_themed)
Expand All @@ -99,6 +97,7 @@ importFrom(ggplot2,element_rect)
importFrom(ggplot2,element_text)
importFrom(ggplot2,expansion)
importFrom(ggplot2,geom_bar)
importFrom(ggplot2,geom_curve)
importFrom(ggplot2,geom_hline)
importFrom(ggplot2,geom_label)
importFrom(ggplot2,geom_line)
Expand All @@ -114,7 +113,7 @@ importFrom(ggplot2,ggplot_add)
importFrom(ggplot2,labs)
importFrom(ggplot2,margin)
importFrom(ggplot2,rel)
importFrom(ggplot2,scale_color_gradient2)
importFrom(ggplot2,scale_color_gradientn)
importFrom(ggplot2,scale_color_manual)
importFrom(ggplot2,scale_fill_manual)
importFrom(ggplot2,scale_x_continuous)
Expand All @@ -125,22 +124,25 @@ importFrom(ggplot2,unit)
importFrom(ggrepel,geom_text_repel)
importFrom(grDevices,col2rgb)
importFrom(grDevices,colorRampPalette)
importFrom(grDevices,grey)
importFrom(gridExtra,tableGrob)
importFrom(gridExtra,ttheme_default)
importFrom(magrittr,"%>%")
importFrom(methods,extends)
importFrom(openxlsx,read.xlsx)
importFrom(patchwork,wrap_plots)
importFrom(reshape2,melt)
importFrom(rlang,.data)
importFrom(rlang,as_label)
importFrom(rtracklayer,GRangesForUCSCGenome)
importFrom(rtracklayer,browserSession)
importFrom(rtracklayer,getTable)
importFrom(rtracklayer,import)
importFrom(rtracklayer,tableName)
importFrom(rtracklayer,ucscGenomes)
importFrom(rtracklayer,ucscTableQuery)
importFrom(scales,comma)
importFrom(scales,rescale)
importFrom(scales,scientific)
importFrom(seqinr,translate)
importFrom(stats,as.formula)
importFrom(stringr,str_locate)
importFrom(stats,reshape)
importFrom(utils,menu)
importFrom(utils,read.csv)
importFrom(utils,read.table)
Expand Down
12 changes: 12 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# ggcoverage 1.4.0
## Major changes
* removed 11 strict dependencies, refactored many functions to work with basic solutions
* formatted all R code with 'styler'
* improved arrow style for genomic features

## Minor changes
* fixed overlapping gene arrows issue
* dont run failing ideogram example check
* fixed unavailable URLS
* use tidy description

# ggcoverage 1.3.0
## Major changes
* Refactored `LoadTrack` function.
Expand Down
1 change: 0 additions & 1 deletion R/ConsensusPeak.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
GetConsensusPeak <- function(peak.file, peak.folder = NULL, mspc.path = NULL, rep.type = c("bio", "tec"), stringency.threshold = 1e-8,
weak.threshold = 1e-4, gamma = 1e-8, alpha = 0.05, min.overlap.num = 1,
multiple.intersections = c("Lowest", "Highest"), parallelism.degree = 1) {

# check parameters
rep.type <- match.arg(arg = rep.type)
multiple.intersections <- match.arg(arg = multiple.intersections)
Expand Down
2 changes: 1 addition & 1 deletion R/FormatInput.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ GetRegion <- function(df, chr, start, end = NULL) {
#' @param extend Extend length of \code{region}. Default: 2000.
#'
#' @return A dataframe.
#' @importFrom magrittr %>%
#' @importFrom dplyr %>%
#' @importFrom dplyr filter arrange
#'
#' @export
Expand Down
58 changes: 28 additions & 30 deletions R/LoadTrack.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#' @importFrom GenomicAlignments alphabetFrequencyFromBam readGAlignments coverage
#' @importFrom GenomicRanges GRanges
#' @importFrom IRanges IRanges subsetByOverlaps
#' @importFrom magrittr %>%
#' @importFrom dplyr %>%
#' @importFrom dplyr select filter mutate all_of group_by summarize
#' @importFrom BiocParallel register MulticoreParam bplapply
#' @importFrom ggplot2 cut_width
Expand All @@ -56,17 +56,16 @@
#' meta.info = sample.meta
#' )
LoadTrackFile <- function(
track.file, track.folder = NULL,
format = c("bam", "wig", "bw", "bedgraph", "txt"),
region = NULL, extend = 2000,
gtf.gr = NULL, gene.name = "HNRNPC",
gene.name.type = c("gene_name", "gene_id"),
meta.info = NULL, meta.file = "",
bamcoverage.path = NULL,
norm.method = c("RPKM", "CPM", "BPM", "RPGC", "None"),
single.nuc = FALSE, single.nuc.region = NULL,
bin.size = 10, bc.extra.para = NULL, n.cores = 1
) {
track.file, track.folder = NULL,
format = c("bam", "wig", "bw", "bedgraph", "txt"),
region = NULL, extend = 2000,
gtf.gr = NULL, gene.name = "HNRNPC",
gene.name.type = c("gene_name", "gene_id"),
meta.info = NULL, meta.file = "",
bamcoverage.path = NULL,
norm.method = c("RPKM", "CPM", "BPM", "RPGC", "None"),
single.nuc = FALSE, single.nuc.region = NULL,
bin.size = 10, bc.extra.para = NULL, n.cores = 1) {
# check parameters
format <- match.arg(arg = format)
gene.name.type <- match.arg(arg = gene.name.type)
Expand All @@ -83,8 +82,8 @@ LoadTrackFile <- function(
if (format == "bam") {
seqnames <- Rsamtools::scanBamHeader(track.file[1]) %>%
lapply(function(x) x$targets) %>%
unname %>%
unlist
unname() %>%
unlist()
gr <- GenomicRanges::GRanges(
seqnames = names(seqnames[1]),
IRanges(start = 1, end = min(100000, seqnames[1]))
Expand Down Expand Up @@ -128,20 +127,20 @@ LoadTrackFile <- function(
BiocParallel::bplapply(track.file, BPPARAM = BiocParallel::MulticoreParam(), FUN = index_bam)
}
if (single.nuc) {
if (is.null(n.cores) || n.cores == 1) {
track.list <- lapply(
track.file,
single_nuc_cov,
single.nuc.region
)
} else {
track.list <- BiocParallel::bplapply(
track.file,
BPPARAM = BiocParallel::MulticoreParam(),
FUN = single_nuc_cov,
single.nuc.region
)
}
if (is.null(n.cores) || n.cores == 1) {
track.list <- lapply(
track.file,
single_nuc_cov,
single.nuc.region
)
} else {
track.list <- BiocParallel::bplapply(
track.file,
BPPARAM = BiocParallel::MulticoreParam(),
FUN = single_nuc_cov,
single.nuc.region
)
}
} else {
if (norm.method == "None") {
message("Calculating coverage with GenomicAlignments when 'norm.method = None'")
Expand Down Expand Up @@ -310,8 +309,7 @@ single_nuc_cov <- function(x, single.nuc.region) {
}

bam_coverage <- function(
x, bamcoverage.path, bin.size, norm.method, bc.extra.para, gr
) {
x, bamcoverage.path, bin.size, norm.method, bc.extra.para, gr) {
# bigwig file
out.bw.file <- tempfile(fileext = c(".bw"))
# prepare bamCoverage cmd
Expand Down
Loading

0 comments on commit 3984adf

Please sign in to comment.