Skip to content

Commit

Permalink
fix: various errors and warnings from incomplete examples, missing de…
Browse files Browse the repository at this point in the history
…pendencies, etc
  • Loading branch information
m-jahn committed Jan 15, 2024
1 parent 938d56b commit a231ece
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 199 deletions.
5 changes: 2 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Description: The goal of 'ggcoverage' is to simplify the process of visualizing
peak annotation, contact map annotation, link annotation and peotein feature annotation.
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.1.1
RoxygenNote: 7.3.0
biocViews:
Imports:
dplyr,
Expand Down Expand Up @@ -56,6 +56,5 @@ Suggests:
htmltools,
BSgenome.Hsapiens.UCSC.hg19,
graphics,
HiCDataHumanIMR90,
GenomeMatrix
HiCDataHumanIMR90
VignetteBuilder: knitr
5 changes: 3 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ S3method(ggplot_add,ideogram)
S3method(ggplot_add,link)
S3method(ggplot_add,peak)
S3method(ggplot_add,tad)
S3method(ggplot_add,tad2)
S3method(ggplot_add,transcript)
export(FormatTrack)
export(GetConsensusPeak)
Expand Down Expand Up @@ -57,7 +56,6 @@ importFrom(Biostrings,readDNAStringSet)
importFrom(GenomeInfoDb,"seqlengths<-")
importFrom(GenomeInfoDb,seqlengths)
importFrom(GenomeInfoDb,seqnames)
importFrom(GenomeMatrix,matrixPlotter)
importFrom(GenomicAlignments,alphabetFrequencyFromBam)
importFrom(GenomicAlignments,coverage)
importFrom(GenomicAlignments,readGAlignments)
Expand Down Expand Up @@ -122,6 +120,7 @@ importFrom(ggplot2,theme_classic)
importFrom(ggplot2,unit)
importFrom(ggpp,annotate)
importFrom(ggrepel,geom_text_repel)
importFrom(grDevices,col2rgb)
importFrom(grDevices,colorRampPalette)
importFrom(magrittr,"%>%")
importFrom(methods,extends)
Expand All @@ -140,3 +139,5 @@ importFrom(stringr,str_locate)
importFrom(utils,menu)
importFrom(utils,read.csv)
importFrom(utils,read.table)
importFrom(utils,tail)
importFrom(utils,write.table)
14 changes: 10 additions & 4 deletions R/geom_link.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,24 @@
#'
#' @examples
#' library(ggcoverage)
#' # create test dataframe (random)
#' # create test dataframe
#' # (random, but use seed to obtain same result every time)
#' set.seed(123)
#' df <- data.frame(
#' seqnames = "chr9", start = seq(from = 4000000, to = 5999000, by = 1000),
#' end = seq(from = 4001000, to = 6000000, by = 1000), score = sample(1:100, 2000, replace = TRUE),
#' seqnames = "chr2L", start = seq(from = 8000000, to = 8300000, by = 1000),
#' end = seq(from = 8001000, to = 8301000, by = 1000), score = sample(1:100, 301, replace = TRUE),
#' Type = "Example", Group = "Example"
#' )
#' # get links
#' link.file = system.file("extdata", "HiC", "HiC_link.bedpe", package = "ggcoverage")
#'
#' # create plot
#' ggcoverage(
#' data = df, color = "grey", region = "chr9:4000000-6000000",
#' data = df, color = "grey",
#' mark.region = NULL, range.position = "out"
#' ) +
#' geom_link(link.file = link.file, file.type = "bedpe", show.rect = TRUE)
#'
geom_link <- function(link.file, file.type = "bedpe", score.col = NULL, score.threshold = NULL,
score.color = c("blue", "grey", "red"), scale.range = 10,
plot.space = 0.1, plot.height = 0.2, show.rect = FALSE) {
Expand Down
48 changes: 46 additions & 2 deletions R/geom_tad.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,54 @@
#' @importFrom ggplot2 ggplot_add ggplot labs theme_classic theme element_blank element_rect
#' element_text margin scale_y_continuous scale_x_continuous
#' @importFrom patchwork wrap_plots
#' @importFrom utils write.table
#'
#' @export
#' @examples
#' library(ggcoverage)
#' library(GenomicRanges)
#'
#' # prepare track dataframe
#' track.file = system.file("extdata", "HiC", "H3K36me3.bw", package = "ggcoverage")
#' track.df = LoadTrackFile(track.file = track.file, format = "bw",
#' region = "chr2L:8050000-8300000", extend = 0)
#' track.df$score = ifelse(track.df$score <0, 0, track.df$score)
#' # check the data
#' head(track.df)
#'
#' # Load Hi-C data
#' hic.mat.file = system.file("extdata", "HiC", "HiC_mat.txt", package = "ggcoverage")
#' hic.mat = read.table(file = hic.mat.file, sep = "\t")
#' hic.mat = as.matrix(hic.mat)
#'
#' # bin data
#' hic.bin.file = system.file("extdata", "HiC", "HiC_bin.txt", package = "ggcoverage")
#' hic.bin = read.table(file = hic.bin.file, sep = "\t")
#' colnames(hic.bin) = c("chr", "start", "end")
#' hic.bin.gr = GenomicRanges::makeGRangesFromDataFrame(df = hic.bin)
#'
#' # transfrom function
#' FailSafe_log10 <- function(x){
#' x[is.na(x) | is.nan(x) | is.infinite(x)] <- 0
#' return(log10(x+1))
#' }
#'
#' # load link data: prepare arcs
#' link.file = system.file("extdata", "HiC", "HiC_link.bedpe", package = "ggcoverage")
#'
#' # basic coverage
#' basic.coverage = ggcoverage(
#' data = track.df, color = "grey",
#' mark.region = NULL, range.position = "out"
#' )
#'
#' # add annotations
#' basic.coverage +
#' geom_tad(matrix = hic.mat, granges = hic.bin.gr, value.cut = 0.99,
#' color.palette = "viridis", transform.fun = FailSafe_log10,
#' top = FALSE, show.rect = TRUE) +
#' geom_link(link.file = link.file, file.type = "bedpe", show.rect = TRUE)
#'
#' @export
geom_tad <- function(matrix, granges, color.palette = NULL, value.cut = NULL,
transform.fun = NULL, plot.space = 0.1, plot.height = 1,
top = TRUE, show.rect = FALSE) {
Expand All @@ -35,7 +80,6 @@ geom_tad <- function(matrix, granges, color.palette = NULL, value.cut = NULL,
class = "tad"
)
}

#' @export
ggplot_add.tad <- function(object, plot, object_name) {
# get plot data
Expand Down
116 changes: 0 additions & 116 deletions R/geom_tad2.R

This file was deleted.

1 change: 1 addition & 0 deletions ggcoverage.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace,vignette
14 changes: 10 additions & 4 deletions man/geom_link.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions man/geom_tad.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a231ece

Please sign in to comment.