Skip to content

Commit a231ece

Browse files
committed
fix: various errors and warnings from incomplete examples, missing dependencies, etc
1 parent 938d56b commit a231ece

File tree

9 files changed

+118
-199
lines changed

9 files changed

+118
-199
lines changed

DESCRIPTION

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Description: The goal of 'ggcoverage' is to simplify the process of visualizing
1414
peak annotation, contact map annotation, link annotation and peotein feature annotation.
1515
License: MIT + file LICENSE
1616
Encoding: UTF-8
17-
RoxygenNote: 7.1.1
17+
RoxygenNote: 7.3.0
1818
biocViews:
1919
Imports:
2020
dplyr,
@@ -56,6 +56,5 @@ Suggests:
5656
htmltools,
5757
BSgenome.Hsapiens.UCSC.hg19,
5858
graphics,
59-
HiCDataHumanIMR90,
60-
GenomeMatrix
59+
HiCDataHumanIMR90
6160
VignetteBuilder: knitr

NAMESPACE

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ S3method(ggplot_add,ideogram)
99
S3method(ggplot_add,link)
1010
S3method(ggplot_add,peak)
1111
S3method(ggplot_add,tad)
12-
S3method(ggplot_add,tad2)
1312
S3method(ggplot_add,transcript)
1413
export(FormatTrack)
1514
export(GetConsensusPeak)
@@ -57,7 +56,6 @@ importFrom(Biostrings,readDNAStringSet)
5756
importFrom(GenomeInfoDb,"seqlengths<-")
5857
importFrom(GenomeInfoDb,seqlengths)
5958
importFrom(GenomeInfoDb,seqnames)
60-
importFrom(GenomeMatrix,matrixPlotter)
6159
importFrom(GenomicAlignments,alphabetFrequencyFromBam)
6260
importFrom(GenomicAlignments,coverage)
6361
importFrom(GenomicAlignments,readGAlignments)
@@ -122,6 +120,7 @@ importFrom(ggplot2,theme_classic)
122120
importFrom(ggplot2,unit)
123121
importFrom(ggpp,annotate)
124122
importFrom(ggrepel,geom_text_repel)
123+
importFrom(grDevices,col2rgb)
125124
importFrom(grDevices,colorRampPalette)
126125
importFrom(magrittr,"%>%")
127126
importFrom(methods,extends)
@@ -140,3 +139,5 @@ importFrom(stringr,str_locate)
140139
importFrom(utils,menu)
141140
importFrom(utils,read.csv)
142141
importFrom(utils,read.table)
142+
importFrom(utils,tail)
143+
importFrom(utils,write.table)

R/geom_link.R

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,24 @@
2626
#'
2727
#' @examples
2828
#' library(ggcoverage)
29-
#' # create test dataframe (random)
29+
#' # create test dataframe
30+
#' # (random, but use seed to obtain same result every time)
31+
#' set.seed(123)
3032
#' df <- data.frame(
31-
#' seqnames = "chr9", start = seq(from = 4000000, to = 5999000, by = 1000),
32-
#' end = seq(from = 4001000, to = 6000000, by = 1000), score = sample(1:100, 2000, replace = TRUE),
33+
#' seqnames = "chr2L", start = seq(from = 8000000, to = 8300000, by = 1000),
34+
#' end = seq(from = 8001000, to = 8301000, by = 1000), score = sample(1:100, 301, replace = TRUE),
3335
#' Type = "Example", Group = "Example"
3436
#' )
37+
#' # get links
38+
#' link.file = system.file("extdata", "HiC", "HiC_link.bedpe", package = "ggcoverage")
39+
#'
3540
#' # create plot
3641
#' ggcoverage(
37-
#' data = df, color = "grey", region = "chr9:4000000-6000000",
42+
#' data = df, color = "grey",
3843
#' mark.region = NULL, range.position = "out"
3944
#' ) +
4045
#' geom_link(link.file = link.file, file.type = "bedpe", show.rect = TRUE)
46+
#'
4147
geom_link <- function(link.file, file.type = "bedpe", score.col = NULL, score.threshold = NULL,
4248
score.color = c("blue", "grey", "red"), scale.range = 10,
4349
plot.space = 0.1, plot.height = 0.2, show.rect = FALSE) {

R/geom_tad.R

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,54 @@
2121
#' @importFrom ggplot2 ggplot_add ggplot labs theme_classic theme element_blank element_rect
2222
#' element_text margin scale_y_continuous scale_x_continuous
2323
#' @importFrom patchwork wrap_plots
24+
#' @importFrom utils write.table
2425
#'
25-
#' @export
26+
#' @examples
27+
#' library(ggcoverage)
28+
#' library(GenomicRanges)
29+
#'
30+
#' # prepare track dataframe
31+
#' track.file = system.file("extdata", "HiC", "H3K36me3.bw", package = "ggcoverage")
32+
#' track.df = LoadTrackFile(track.file = track.file, format = "bw",
33+
#' region = "chr2L:8050000-8300000", extend = 0)
34+
#' track.df$score = ifelse(track.df$score <0, 0, track.df$score)
35+
#' # check the data
36+
#' head(track.df)
37+
#'
38+
#' # Load Hi-C data
39+
#' hic.mat.file = system.file("extdata", "HiC", "HiC_mat.txt", package = "ggcoverage")
40+
#' hic.mat = read.table(file = hic.mat.file, sep = "\t")
41+
#' hic.mat = as.matrix(hic.mat)
42+
#'
43+
#' # bin data
44+
#' hic.bin.file = system.file("extdata", "HiC", "HiC_bin.txt", package = "ggcoverage")
45+
#' hic.bin = read.table(file = hic.bin.file, sep = "\t")
46+
#' colnames(hic.bin) = c("chr", "start", "end")
47+
#' hic.bin.gr = GenomicRanges::makeGRangesFromDataFrame(df = hic.bin)
48+
#'
49+
#' # transfrom function
50+
#' FailSafe_log10 <- function(x){
51+
#' x[is.na(x) | is.nan(x) | is.infinite(x)] <- 0
52+
#' return(log10(x+1))
53+
#' }
2654
#'
55+
#' # load link data: prepare arcs
56+
#' link.file = system.file("extdata", "HiC", "HiC_link.bedpe", package = "ggcoverage")
57+
#'
58+
#' # basic coverage
59+
#' basic.coverage = ggcoverage(
60+
#' data = track.df, color = "grey",
61+
#' mark.region = NULL, range.position = "out"
62+
#' )
63+
#'
64+
#' # add annotations
65+
#' basic.coverage +
66+
#' geom_tad(matrix = hic.mat, granges = hic.bin.gr, value.cut = 0.99,
67+
#' color.palette = "viridis", transform.fun = FailSafe_log10,
68+
#' top = FALSE, show.rect = TRUE) +
69+
#' geom_link(link.file = link.file, file.type = "bedpe", show.rect = TRUE)
70+
#'
71+
#' @export
2772
geom_tad <- function(matrix, granges, color.palette = NULL, value.cut = NULL,
2873
transform.fun = NULL, plot.space = 0.1, plot.height = 1,
2974
top = TRUE, show.rect = FALSE) {
@@ -35,7 +80,6 @@ geom_tad <- function(matrix, granges, color.palette = NULL, value.cut = NULL,
3580
class = "tad"
3681
)
3782
}
38-
3983
#' @export
4084
ggplot_add.tad <- function(object, plot, object_name) {
4185
# get plot data

R/geom_tad2.R

Lines changed: 0 additions & 116 deletions
This file was deleted.

ggcoverage.Rproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ StripTrailingWhitespace: Yes
1818
BuildType: Package
1919
PackageUseDevtools: Yes
2020
PackageInstallArgs: --no-multiarch --with-keep.source
21+
PackageRoxygenize: rd,collate,namespace,vignette

man/geom_link.Rd

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/geom_tad.Rd

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)