Skip to content

Commit

Permalink
Clean up wilcox; minor bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mvfki committed Oct 30, 2023
1 parent c9a584e commit 8a8e4bf
Show file tree
Hide file tree
Showing 11 changed files with 280 additions and 637 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ set(CMAKE_CXX_FLAGS_RELEASE "")
set(CMAKE_VERBOSE_MAKEFILE TRUE)

set(srclist ModularityOptimizer.cpp RModularityOptimizer.cpp RcppExports.cpp
data_processing.cpp fast_wilcox.cpp feature_mat.cpp quantile_norm.cpp snn.cpp)
data_processing.cpp wilcoxon.cpp feature_mat.cpp quantile_norm.cpp snn.cpp)
list(TRANSFORM srclist PREPEND "${PROJECT_SOURCE_DIR}/src/")
add_library(rliger2 SHARED ${srclist})
set_target_properties(rliger2 PROPERTIES PREFIX "")
Expand Down
64 changes: 20 additions & 44 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,50 +45,6 @@ sample_cpp <- function(x, size) {
.Call(`_rliger2_sample_cpp`, x, size)
}

cpp_sumGroups_dgc <- function(x, p, i, ncol, groups, ngroups) {
.Call(`_rliger2_cpp_sumGroups_dgc`, x, p, i, ncol, groups, ngroups)
}

cpp_sumGroups_dgc_T <- function(x, p, i, ncol, nrow, groups, ngroups) {
.Call(`_rliger2_cpp_sumGroups_dgc_T`, x, p, i, ncol, nrow, groups, ngroups)
}

cpp_sumGroups_dense <- function(X, groups, ngroups) {
.Call(`_rliger2_cpp_sumGroups_dense`, X, groups, ngroups)
}

cpp_sumGroups_dense_T <- function(X, groups, ngroups) {
.Call(`_rliger2_cpp_sumGroups_dense_T`, X, groups, ngroups)
}

cpp_nnzeroGroups_dense <- function(X, groups, ngroups) {
.Call(`_rliger2_cpp_nnzeroGroups_dense`, X, groups, ngroups)
}

cpp_nnzeroGroups_dense_T <- function(X, groups, ngroups) {
.Call(`_rliger2_cpp_nnzeroGroups_dense_T`, X, groups, ngroups)
}

cpp_nnzeroGroups_dgc <- function(p, i, ncol, groups, ngroups) {
.Call(`_rliger2_cpp_nnzeroGroups_dgc`, p, i, ncol, groups, ngroups)
}

cpp_in_place_rank_mean <- function(v_temp, idx_begin, idx_end) {
.Call(`_rliger2_cpp_in_place_rank_mean`, v_temp, idx_begin, idx_end)
}

cpp_rank_matrix_dgc <- function(x, p, nrow, ncol) {
.Call(`_rliger2_cpp_rank_matrix_dgc`, x, p, nrow, ncol)
}

cpp_rank_matrix_dense <- function(X) {
.Call(`_rliger2_cpp_rank_matrix_dense`, X)
}

cpp_nnzeroGroups_dgc_T <- function(p, i, ncol, nrow, groups, ngroups) {
.Call(`_rliger2_cpp_nnzeroGroups_dgc_T`, p, i, ncol, nrow, groups, ngroups)
}

#' Fast calculation of feature count matrix
#'
#' @param bedmat A feature count list generated by bedmap
Expand Down Expand Up @@ -127,3 +83,23 @@ DirectSNNToFile <- function(nn_ranked, prune, display_progress, filename) {
.Call(`_rliger2_DirectSNNToFile`, nn_ranked, prune, display_progress, filename)
}

cpp_rank_matrix_dgc <- function(x, p, nrow, ncol) {
.Call(`_rliger2_cpp_rank_matrix_dgc`, x, p, nrow, ncol)
}

rowAggregateSum_sparse <- function(X, groups, ngroups) {
.Call(`_rliger2_rowAggregateSum_sparse`, X, groups, ngroups)
}

colAggregateSum_sparse <- function(X, groups, ngroups) {
.Call(`_rliger2_colAggregateSum_sparse`, X, groups, ngroups)
}

colNNZAggr_sparse <- function(X, groups, ngroups) {
.Call(`_rliger2_colNNZAggr_sparse`, X, groups, ngroups)
}

rowNNZAggr_sparse <- function(X, groups, ngroups) {
.Call(`_rliger2_rowNNZAggr_sparse`, X, groups, ngroups)
}

6 changes: 3 additions & 3 deletions R/embedding.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
#' \code{NULL} uses all factors.
#' @param nDims Number of dimensions to reduce to. Default \code{2}.
#' @param distance Character. Metric used to measure distance in the input
#' space. Default \code{"euclidean"}, alternative options include:
#' \code{"cosine"}, \code{"manhattan"} and \code{"hamming"}.
#' space. Default \code{"cosine"}, alternative options include:
#' \code{"euclidean"}, \code{"manhattan"} and \code{"hamming"}.
#' @param nNeighbors Number of neighboring points used in local approximations
#' of manifold structure. Default \code{10}.
#' @param minDist Numeric. Controls how tightly the embedding is allowed
Expand All @@ -47,7 +47,7 @@ runUMAP <- function(
useRaw = FALSE,
useDims = NULL,
nDims = 2,
distance = c("euclidean", "cosine", "manhattan", "hamming"),
distance = c("cosine", "euclidean", "manhattan", "hamming"),
nNeighbors = 20,
minDist = 0.1,
dimredName = "UMAP",
Expand Down
2 changes: 1 addition & 1 deletion R/preprocess.R
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ selectGenes.liger <- function(
unshared.datasets = "useUnsharedDatasets",
unshared.thresh = "unsharedThresh"),
defunct = c("tol", "do.plot", "cex.use"))
lig <- recordCommand(lig)
object <- recordCommand(object)
datasetShared <- .checkUseDatasets(object, useDatasets)
if (!is.null(useUnsharedDatasets))
datasetUnshared <- .checkUseDatasets(object, useUnsharedDatasets)
Expand Down
6 changes: 6 additions & 0 deletions R/visualization2.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ plotClusterDimRed <- function(
useDimRed = NULL,
...) {
useDimRed <- useDimRed %||% object@uns$defaultDimRed
if (is.null(useDimRed)) {
stop("No `useDimRed` given or default dimRed not set.")
}
useCluster <- useCluster %||% object@uns$defaultCluster
xVar <- paste0(useDimRed, ".1")
yVar <- paste0(useDimRed, ".2")
Expand All @@ -64,6 +67,9 @@ plotDatasetDimRed <- function(
useDimRed = NULL,
...) {
useDimRed <- useDimRed %||% object@uns$defaultDimRed
if (is.null(useDimRed)) {
stop("No `useDimRed` given or default dimRed not set.")
}
xVar <- paste0(useDimRed, ".1")
yVar <- paste0(useDimRed, ".2")
plotCellScatter(object, x = xVar, y = yVar, colorBy = "dataset",
Expand Down
Loading

0 comments on commit 8a8e4bf

Please sign in to comment.