Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions R/bootstrapCompartments.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bootstrapCompartments <- function(
# bootstrap and recompute compartments
BiocParallel::bpprogressbar(BPPARAM) <- FALSE
resamp.compartments <- bplapply(
1:ncol(bmeans),
seq_len(ncol(bmeans)),
function(b) {
# get the shrunken bins with new global mean
boot.mean <- as.matrix(bmeans[, b])
Expand All @@ -80,7 +80,7 @@ bootstrapCompartments <- function(
cor.bins <- getCorMatrix(s.bins, squeeze = !group)

# Stupid check for perfect correlation with global mean
if (any(is.na(cor.bins$binmat.cor))) {
if (anyNA(cor.bins$binmat.cor)) {
absig <- matrix(rep(NA, nrow(cor.bins$binmat.cor)))
} else {
absig <- getABSignal(cor.bins, assay = assay)
Expand Down
6 changes: 3 additions & 3 deletions R/condenseRE.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ condenseRE <- function(obj) {
# it will build a list of SummarizedExperiments with relevant information
# from computing compartments
if (!is(obj, "RaggedExperiment")) stop("Input needs to be a RaggedExperiment")
se_list <- lapply(1:length(assayNames(obj)), function(a) {
se_list <- lapply(seq_along(assayNames(obj)), function(a) {
compactSummarizedExperiment(obj, i = a)
})

Expand Down Expand Up @@ -64,11 +64,11 @@ condenseSE <- function(obj, sample.name = NULL) {

# check and see how many samples we are extracting
if (length(sample.name) == 1) {
obj.dense <- lapply(1:length(obj), .condenseGR, obj = obj, sample = sample.name)
obj.dense <- lapply(seq_along(obj), .condenseGR, obj = obj, sample = sample.name)
return(Reduce("merge", obj.dense))
} else {
obj.dense.lst <- lapply(sample.name, function(s) {
obj.dense <- lapply(1:length(obj), .condenseGR, obj = obj, sample = s)
obj.dense <- lapply(seq_along(obj), .condenseGR, obj = obj, sample = s)
return(Reduce("merge", obj.dense))
})
names(obj.dense.lst) <- sample.name
Expand Down
2 changes: 1 addition & 1 deletion R/getBinMatrix.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ getBinMatrix <- function(
genome = c("hg19", "hg38", "mm9", "mm10")
) {

if (any(is.na(mat))){
if (anyNA(mat)){
stop("Matrix must not contain NAs")
}
if (nrow(mat) != length(genloc)){
Expand Down
6 changes: 3 additions & 3 deletions R/getCompartments.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ getCompartments <- function(
}

boot_msg <- ""
if (bootstrap & boot.parallel) {
if (bootstrap && boot.parallel) {
boot_msg <- sprintf("Bootstrapping in parallel with %d cores", bpnworkers(bpparams[[2]]))
} else if (bootstrap & !boot.parallel & group) {
} else if (bootstrap && !boot.parallel && group) {
boot_msg <- "Not bootstrapping in parallel could take a long time..."
}

Expand Down Expand Up @@ -153,7 +153,7 @@ getCompartments <- function(

obj.cor <- getCorMatrix(obj.bins, squeeze = !group)

if (any(is.na(obj.cor$binmat.cor))) {
if (anyNA(obj.cor$binmat.cor)) {
obj.cor$gr$pc <- matrix(rep(NA, nrow(obj.cor$binmat.cor)))
obj.svd <- obj.cor$gr
} else {
Expand Down
6 changes: 3 additions & 3 deletions R/getDomainInflections.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ getDomainInflections <- function(
end(tiles) <- suppressWarnings(end(tiles) - 1)

# add a column for continuous runs!
mcols(tiles)$run <- seq(1:length(tiles))
mcols(tiles)$run <- seq(seq_along(tiles))
mcols(tiles)$score <- NA

# overlap
Expand Down Expand Up @@ -83,7 +83,7 @@ getDomainInflections <- function(
}

# loop through the non-contiguous space
grl <- lapply(1:length(non_contig), function(i) {
grl <- lapply(seq_along(non_contig), function(i) {
message("Block processing non-contiguous space for block ", i)
# get block of contiguous sequence
if (non_contig[i] == non_contig[1]) {
Expand Down Expand Up @@ -132,7 +132,7 @@ getDomainInflections <- function(

# subset the original granges
# gr.inflect <- gr[gr.signs.diff,]
if (length(gr.signs) == 2 & any(gr.signs.bool)) {
if (length(gr.signs) == 2 && any(gr.signs.bool)) {
gr.inflect <- gr[2, ] # special case
gr.inflect.new <- GRanges(
seqnames = seqnames(gr.inflect),
Expand Down
2 changes: 1 addition & 1 deletion R/getShrinkageTargets.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ getShrinkageTargets <- function(obj, group) {
msg <- paste(
"Error while subsetting targets: provided column", column.type, "not found:"
)
if (no_colnames & group.is_colnames) {
if (no_colnames && group.is_colnames) {
message("The provided object does not have any column names - use column indices instead.")
}
message(msg)
Expand Down
2 changes: 1 addition & 1 deletion R/imputeKNN.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ imputeKNN <- function(
assay <- match.arg(assay)

# stop early if there aren't any NAs to impute
if (!any(is.na(assay(obj)))) {
if (!anyNA(assay(obj))) {
message("No NAs found. Nothing to impute.")
return(obj)
}
Expand Down
2 changes: 1 addition & 1 deletion R/meanSmoother.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ meanSmoother <- function(mat, k = 1, iters = 2, delta = 0, weights = NULL) {
eps <- delta + 1
weights <- weights %||% rep(1, length(mat))

while (pos < iters & eps > delta) {
while (pos < iters && eps > delta) {
mat0 <- mat
pos <- pos + 1
mat <- .meanSmoother.internal(mat0, weights = weights, k = k)
Expand Down
8 changes: 4 additions & 4 deletions R/parallel.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#' inference and bootstrapping
#' @keywords internal
check_optim <- function(workers, group, chr_count, bootstrap) {
if (group & chr_count < workers[1]) {
if (group && chr_count < workers[1]) {
flog.info(
"Grouped inference with more outer workers than chromosomes leaves %d of %d workers unused",
workers[1] - chr_count,
Expand All @@ -12,7 +12,7 @@ check_optim <- function(workers, group, chr_count, bootstrap) {
flog.info("Consider using a single core for the outer worker and more cores for the inner bootstrap worker")
}
}
if (!group & bootstrap & workers[1] < workers[2]) {
if (!group && bootstrap && workers[1] < workers[2]) {
flog.info("More outer (column-wise) than inner (bootstrap) workers is faster for single-cell inference")
}
}
Expand All @@ -29,7 +29,7 @@ check_worker_count <- function(bpparam, group, chr_count, bootstrap, avail_worke

avail_msg <- sprintf("but your system has only %d cores", avail_workers)
info_msg <- "See parallelly::availableCores(which = 'all') for more information on available resources"
if (workers[1] == 1 | workers[2] == 1) {
if (workers[1] == 1 || workers[2] == 1) {
msg <- sprintf(
"Requested %d %s workers %s\n%s",
max(workers),
Expand Down Expand Up @@ -105,7 +105,7 @@ verify_workers <- function(n_workers) {
get_nested_params <- function(BPPARAM, boot.parallel) {
stopifnot("Only two BiocParallelParam objects can be used" = length(BPPARAM) <= 2)
single_param <- length(BPPARAM) == 1
BPPARAM <- if (single_param & is.list(BPPARAM)) BPPARAM[[1]] else BPPARAM
BPPARAM <- if (single_param && is.list(BPPARAM)) BPPARAM[[1]] else BPPARAM

if (boot.parallel) {
if (single_param) {
Expand Down
2 changes: 1 addition & 1 deletion R/preprocessArrays.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ preprocessArrays <- function(
}

# impute missing values if possible
if (any(is.na(minfi::getBeta(obj.opensea)))) {
if (anyNA(minfi::getBeta(obj.opensea))) {
flog.debug("Imputing missing values.")
obj.opensea <- imputeKNN(obj.opensea, assay = "array")
}
Expand Down
2 changes: 1 addition & 1 deletion R/transformTFIDF.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#'
#' @export
transformTFIDF <- function(mat, scale.factor = 1e5, binarize = FALSE) {
if (!is(mat, "matrix") & !is(mat, "Matrix")) {
if (!is(mat, "matrix") && !is(mat, "Matrix")) {
stop("Input needs to be a matrix.")
}

Expand Down
4 changes: 2 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ flogit <- function(p, sqz = 0.000001) {
#'
#' @export
fexpit <- function(x, sqz = 0.000001) {
midpt <- .5
midpt <- 0.5
squoze <- exp(x) / (1 + exp(x))
inflate <- 1 / (1 - (sqz * midpt))
((squoze - midpt) * inflate) + midpt
Expand Down Expand Up @@ -285,7 +285,7 @@ importBigWig <- function(
}

# it is now a GRanges object
if (any(is.na(seqlengths(bw.raw)))) stop("Imported bigwig does not have seqlengths")
if (anyNA(seqlengths(bw.raw))) stop("Imported bigwig does not have seqlengths")

species <- switch(
genome,
Expand Down
Loading