Skip to content

Commit

Permalink
Merge pull request #116 from cbielow/rm_kableExtra
Browse files Browse the repository at this point in the history
Remove kableExtra package dependency
  • Loading branch information
cbielow authored Mar 23, 2022
2 parents bca715e + 0b31434 commit 92b81c7
Show file tree
Hide file tree
Showing 21 changed files with 56 additions and 51 deletions.
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: PTXQC
Type: Package
Title: Quality Report Generation for MaxQuant and mzTab Results
Version: 1.0.12
Date: 2021-11-02
Version: 1.0.13
Date: 2022-03-22
Author: Chris Bielow [aut, cre],
Juliane Schmachtenberg [ctb],
Swenja Wagner [ctb],
Expand All @@ -25,9 +25,10 @@ Imports:
grid,
grDevices,
gtable,
htmlTable,
jsonlite,
kableExtra,
knitr (>= 1.10),
magrittr,
methods,
ontologyIndex,
plyr,
Expand Down
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ import(ggplot2)
import(grDevices)
import(grid)
import(gtable)
import(kableExtra)
import(htmlTable)
import(knitr)
import(magrittr)
import(methods)
import(plyr)
import(reshape2, except = c(dcast, melt))
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Versions uploaded to CRAN are marked with [CRAN].
######### CHANGELOG ##########
#################################

[CRAN] v1.00.13 -- 2022/03/22
- [FIX] Remove dependency 'kableExtra' and use 'htmlTable' package instead

[CRAN] v1.00.12 -- 2021/11/02
- [FIX] Documentation and cosmetic fixes (pr #109)
- [FIX/DOC] improved legends and better links in Html reports (pr #111)
Expand Down
4 changes: 2 additions & 2 deletions R/MQDataReader.R
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,11 @@ readMQ = function(file, filter = "", type = "pg", col_subset = NA, add_fs_col =
.self$mq.data[, int_cols[int_cols_nn]] = sapply(int_cols[int_cols_nn], function(x_name)
{
x = .self$mq.data[, x_name]
if (class(x) == "integer")
if (inherits(x, "integer"))
{
x = as.numeric(x)
}
if (class(x) != "numeric")
if (!inherits(x, "numeric"))
{
cat(paste(x[grep(",", x)], collapse = ",", sep=", "))
cat(paste(unique(x), collapse = ",", sep=", "))
Expand Down
9 changes: 6 additions & 3 deletions R/MzQC_classes.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ isValidMzQC = function(x, ...)
# anchor
if (missing(x)) return(TRUE)

if ("list" %in% class(x)) {
if (inherits(x, "list")) {
idx = sapply(x, isValidMzQC)
if (any(idx == FALSE)) {
warning(paste0("In list of '", class(x[[1]]), "', the element(s) #[", paste(which(idx == FALSE), collapse = ","), "] is/are invalid."), immediate. = TRUE, call. = FALSE)
Expand Down Expand Up @@ -122,7 +122,7 @@ isValidMzQC = function(x, ...)
#'
fromDatatoMzQC = function(mzqc_class, data)
{
if ("list" %in% class(data))
if (inherits(data, "list"))
{
return(sapply(data, function(x) {
obj = mzqc_class$new()
Expand Down Expand Up @@ -190,6 +190,9 @@ NULL_to_NA = function(var_or_NULL) {
#' @examples
#' dt1 = MzQCDateTime$new("1900-01-01")
#' dt2 = MzQCDateTime$new(Sys.time())
#' ## test faulty input
#' ## errors with 'character string is not in a standard unambiguous format'
#' try(MzQCDateTime$new('lala'), silent=TRUE)
#' ## test roundtrip conversion from/to JSON
#' dt2$fromData(jsonlite::fromJSON(jsonlite::toJSON(dt1)))
# dt1$datetime == dt2$datetime ## TRUE
Expand Down Expand Up @@ -404,7 +407,7 @@ setMethod('asJSON', 'MzQCinputFile', function(x, ...) x$toJSON(...))
# x2 = jsonlite::toJSON(nif2)
# xdata = jsonlite::fromJSON(x, simplifyDataFrame = FALSE)
# xdata
# class(fromDatatoMzQC(MzQCcvParameter, xdata$fileProperties)) == "list"
# inherits(fromDatatoMzQC(MzQCcvParameter, xdata$fileProperties), "list")
# jsonlite::toJSON(xdata, pretty = TRUE, auto_unbox = T)
# isValidMzQC(l2)
# nif$fromData(xdata)
Expand Down
1 change: 0 additions & 1 deletion R/PTXQC.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#' @import grid
#' @import grDevices
#' @import gtable
#' @import kableExtra
#' @import knitr
#' @import methods
#' @import plyr
Expand Down
4 changes: 2 additions & 2 deletions R/createReport.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ createReport = function(txt_folder = NULL, mztab_file = NULL, yaml_obj = list(),
###
### prepare the YAML config
###
if (class(yaml_obj) != "list")
if (!inherits(yaml_obj, "list"))
{
stop(paste0("Argument 'yaml_obj' is not of type list\n"));
}
Expand Down Expand Up @@ -375,7 +375,7 @@ createReport = function(txt_folder = NULL, mztab_file = NULL, yaml_obj = list(),
}

### warn of special contaminants!
if (class(yaml_param$yaml_contaminants) == "list") ## SC are requested
if (inherits(yaml_param$yaml_contaminants, "list")) ## SC are requested
{
if (!is.null(df_pg))
{
Expand Down
6 changes: 3 additions & 3 deletions R/fcn_MQ.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ boxplotCompare = function(data,
}

## shorten group names
if (class(names)=='data.frame')
if (inherits(names, 'data.frame'))
{
stopifnot(sort(colnames(names)) == c("long", "short"))
data$group = names$short[match(data$group, names$long)]
Expand All @@ -58,7 +58,7 @@ boxplotCompare = function(data,
}
}
## make it a factor
if (!("factor" %in% class(data$group))) data$group = factor(data$group)
if (!inherits(data$group, "factor")) data$group = factor(data$group)

## actual number of entries in each column (e.g. LFQ often has 0)
ncol.stat = plyr::ddply(data, "group", function(x)
Expand All @@ -71,7 +71,7 @@ boxplotCompare = function(data,
data$group2 = ncol.stat$newname[match(data$group, ncol.stat$group)]

## check (ddply makes ncol.stat$newname a factor with matching levels)
#stopifnot(class(data$group2) == "factor")
#stopifnot(inherits(data$group2, "factor"))
#stopifnot(all(as.numeric(data$group) == as.numeric(data$group2))) ## as.numeric() is meaningless on factors with different levels
data$group = data$group2
## remove -inf and NA's
Expand Down
2 changes: 1 addition & 1 deletion R/fcn_misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ getMetricsObjects = function(DEBUG_PTXQC = FALSE)

lst_qcMetrics = sapply(lst_qcMetrics_str, function(m) {
q = get(m)
if (class(q) %in% "refObjectGenerator"){
if (inherits(q, "refObjectGenerator")) {
return(q$new())
}
return(NULL)
Expand Down
4 changes: 2 additions & 2 deletions R/fcn_miscGGplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ printWithFooter = function(gg_obj, bottom_left = NULL, bottom_right = NULL)
#'
scale_x_discrete_reverse = function(values, ...)
{
if ("factor" %in% class(values)) values = droplevels(values)
if (inherits(values, "factor")) values = droplevels(values)
return (scale_x_discrete(limits = rev(levels(values)), ... ))
}

Expand All @@ -80,7 +80,7 @@ scale_x_discrete_reverse = function(values, ...)
#'
scale_y_discrete_reverse = function(values, ...)
{
if ("factor" %in% class(values)) values = droplevels(values)
if (inherits(values, "factor")) values = droplevels(values)
return (scale_y_discrete(limits = rev(levels(values)), ... ))
}

Expand Down
30 changes: 13 additions & 17 deletions R/fcn_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -712,32 +712,28 @@ plotTableRaw = function(data, colours="black", fill=NA, just="centre")
#'
#'
#' @param data A data.frame which serves as table
#' @param header A set of headlines, e.g. c("top line", "bottom line")
#' @param font_size Html font size
#' @return table as character string for cat()'ing into html
#' @param caption A set of headlines, e.g. c("top line", "bottom line")
#' @return table as html character string for cat()'ing into an html document
#'
#' @import htmlTable
#' @import magrittr
#'
#' @export
#'
#' @examples
#' data = data.frame(raw.file = letters[1:4],
#' id.rate = 3:6)
#' getHTMLTable(data,
#' header = "some header line",
#' font_size = 11)
#' caption = "some header line")
#'
getHTMLTable = function(data, header = NA, font_size = 12)
getHTMLTable = function(data, caption = NA)
{
tbl = kableExtra::kable_styling(kableExtra::kable(data, row.names = FALSE, format = "html"),
bootstrap_options = c("striped", "hover", "condensed"),
full_width = FALSE,
font_size = font_size)

if (!any(is.na(header)))
{
header__ = header;
tbl = kableExtra::add_header_above(tbl, c(header__ = ncol(data)))
tbl = gsub("header__", paste(header__, sep = "", collapse = "<br>"), as.character(tbl))
}

tbl = data %>%
addHtmlTableStyle(align = 'l', ## align columns left
col.rgroup = c("none", "#F7F7F7")) %>%
htmlTable(rnames = FALSE, ## no row names
caption = caption)

return(tbl)
}
Expand Down
2 changes: 1 addition & 1 deletion R/fcn_qualities.R
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ qualHighest = function(x, N)
#'
qualBestKS = function(x) {

if (class(x) != "list") stop("Function bestKS() expects a list!")
if (!inherits(x, "list")) stop("Function bestKS() expects a list!")
if (length(x) == 0) stop("Error: qualBestKS() received empty data!")

if (is.null(names(x))) names(x) = 1:length(x)
Expand Down
4 changes: 2 additions & 2 deletions R/mzQC.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' Get the information of each CV term from an obo file.
#'
#' @param cv_obo_file A path to an .obo file
#' @return A list containing cv term information
#' @return A list containing CV term information
#'
#'
parseOBO = function(cv_obo_file){
Expand Down Expand Up @@ -190,7 +190,7 @@ assembleMZQC = function(lst_qcMetrics, raw_file_mapping)
{
mzqc_data = metric$mzQC
if (is.null(mzqc_data)) next
if (class(mzqc_data) != "list") stop("mzQC member of metric must be of class 'list()'")
if (!inherits(mzqc_data, "list")) stop("mzQC member of metric must be of class 'list()'")
if (length(mzqc_data) == 0) next
if (any(is.null(names(mzqc_data)))) stop("mzQC member of metric '", metric$qcName, "' is a list, but has no names (must be fc.raw.file names or a concatenation of those)")

Expand Down
4 changes: 2 additions & 2 deletions R/qcMetric.R
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ qcMetric = setRefClass("qcMetric",
}

if (!("plots" %in% names(r))) stop(c("Worker of '", .self$qcName, "' did not return valid result format!"))
if (!class(r[["plots"]]) == "list") stop(c("Worker of '", .self$qcName, "' did not return plots in list format!"))
if (!inherits(r[["plots"]], "list")) stop(c("Worker of '", .self$qcName, "' did not return plots in list format!"))


lpl = flattenList(r[["plots"]])
Expand All @@ -141,7 +141,7 @@ qcMetric = setRefClass("qcMetric",
if (!withTitle) { ## no title
r = lapply(.self$plots, function(p) {
## delete title
if ("ggplot" %in% class(p)) p = p + ggtitle(NULL)
if (inherits(p, "ggplot")) p = p + ggtitle(NULL)
return (p)
})
return(r)
Expand Down
2 changes: 1 addition & 1 deletion R/qcMetric_EVD.R
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ qcMetric_EVD_Charge = setRefClass(
"Charge distribution per Raw file. For typtic digests, peptides of charge 2
(one N-terminal and one at tryptic C-terminal R or K residue) should be dominant.
Ionization issues (voltage?), in-source fragmentation, missed cleavages and buffer irregularities can
cause a shift (see [Bittremieux 2017, DOI: 10.1002/mas.21544](https://onlinelibrary.wiley.com/doi/abs/10.1002/mas.21544) ).
cause a shift (see Bittremieux 2017, DOI: 10.1002/mas.21544).
The charge distribution should be similar across Raw files.
Consistent charge distribution is paramount for comparable 3D-peak intensities across samples.
Expand Down
2 changes: 1 addition & 1 deletion R/qcMetric_PAR.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ track database completeness and database version information (if given in the fi

## HTML: alternative table
## (do this before line breaks, since Html can handle larger strings)
tbl_f = getHTMLTable(d_par2, header = fasta_files, font_size = 12)
tbl_f = getHTMLTable(d_par2, caption = fasta_files)

## break long values into multiple lines (to preserve PDF table width)
splitMaxLen = function(s) {
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ PTXQC

### Latest changes / ChangeLog


- v1.00.13 - Mar 2022: internal changes (removed a deprecated dependency)
- v1.00.12 - Nov 2021: Documentation and cosmetic fixes (https://github.com/cbielow/PTXQC/pull/109); improved legends, better links in Html reports (https://github.com/cbielow/PTXQC/pull/111); avoid crash on datasets with only a single MS/MS spectrum (https://github.com/cbielow/PTXQC/pull/112)
- v1.00.11 - Sep 2021: initial support for mzQC Quality Control output (https://github.com/cbielow/PTXQC/pull/105); Missed cleavages can be computed from evidence.txt (https://github.com/cbielow/PTXQC/pull/104); minor fixes
- v1.00.10 - May 2021: detect non UK/US locale (https://github.com/cbielow/PTXQC/pull/99); Revive missing MBR metrics (https://github.com/cbielow/PTXQC/issues/97); restore full Parameter list (showing MaxQuant parameters (https://github.com/cbielow/PTXQC/issues/101); decoy distribution in MS/MS mass error plot restored (https://github.com/cbielow/PTXQC/issues/102)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,7 @@ <h3><span class="header-section-number">1.4.9</span> EVD: charge distribution</b
↓ Show Help
</div>
<div class="helpText">
<p>Charge distribution per Raw file. For typtic digests, peptides of charge 2 (one N-terminal and one at tryptic C-terminal R or K residue) should be dominant. Ionization issues (voltage?), in-source fragmentation, missed cleavages and buffer irregularities can cause a shift (see <a href="https://onlinelibrary.wiley.com/doi/abs/10.1002/mas.21544">Bittremieux 2017, DOI: 10.1002/mas.21544</a> ). The charge distribution should be similar across Raw files. Consistent charge distribution is paramount for comparable 3D-peak intensities across samples.</p>
<p>Charge distribution per Raw file. For typtic digests, peptides of charge 2 (one N-terminal and one at tryptic C-terminal R or K residue) should be dominant. Ionization issues (voltage?), in-source fragmentation, missed cleavages and buffer irregularities can cause a shift (see Bittremieux 2017, DOI: 10.1002/mas.21544). The charge distribution should be similar across Raw files. Consistent charge distribution is paramount for comparable 3D-peak intensities across samples.</p>
<p>Heatmap score [EVD: Charge]: Deviation of the charge 2 proportion from a representative Raw file (‘qualMedianDist’ function).</p>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions man/MzQCDateTime-class.Rd

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

11 changes: 4 additions & 7 deletions man/getHTMLTable.Rd

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

2 changes: 1 addition & 1 deletion man/parseOBO.Rd

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

0 comments on commit 92b81c7

Please sign in to comment.