Skip to content

Commit

Permalink
Update examples, fix global variable warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gene233 committed Mar 21, 2024
1 parent 46ea173 commit c642665
Show file tree
Hide file tree
Showing 28 changed files with 66 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-bioc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ jobs:

- name: Upload check results
if: failure()
uses: actions/upload-artifact@devel
uses: actions/upload-artifact@master
with:
name: ${{ runner.os }}-biocversion-RELEASE_3_18-r-4.3-results
path: check
Expand Down
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ Imports:
mixtools,
sparseMatrixStats,
stats,
tidyr
tidyr,
utils
Suggests:
BiocStyle,
dbscan,
Expand Down
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ import(graphics)
import(methods)
import(stats)
importClassesFrom(Matrix,dgCMatrix)
importFrom(SummarizedExperiment,SummarizedExperiment)
importFrom(SummarizedExperiment,assay)
importFrom(utils,globalVariables)
importFrom(utils,stack)
4 changes: 3 additions & 1 deletion R/AllGenerics.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ setGeneric(
#' @param data an expression object, can be matrix or SummarizedExperiment
#' @param slot a character, specify which slot to use when data is se object,
#' optional, default 'score'
#' @param suffix a character, specify the name suffix to save score when
#' features is a named list
#'
#' @return A vector of overall score for each sample
#'
#' @include score.R
#' @export
#'
#' @examples
#' data <- matrix(rnorm(100), 10, dimnames = list(seq_len(3)))
#' data <- matrix(rnorm(100), 10, dimnames = list(seq_len(10)))
#' gs_score(data, features = seq_len(3))
setGeneric(
"gs_score",
Expand Down
2 changes: 2 additions & 0 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,5 @@ score_barplot <- function(top_markers, column = ".dot", f_list, n = 30) {
theme_classic()
}

utils::globalVariables(c("Group", "Score", "x", "Scores", "Comp",
"..density..", "stack", "values", "ind", "Type"))
4 changes: 3 additions & 1 deletion R/score.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ idf_iae_methods <- function() {
#'
#' @examples
#' data <- matrix(rpois(100, 2), 10, dimnames = list(1:10))
#' cal_score_init(data, label = sample(c("A", "B"), 10, replace = TRUE))
#' label <- sample(c("A", "B"), 10, replace = TRUE)
#' smartid:::cal_score_init(data, par.idf = list(label = label),
#' par.iae = list(label = label))
cal_score_init <- function(expr, tf = c("logtf", "tf"),
idf = "prob", iae = "prob",
par.idf = NULL, par.iae = NULL) {
Expand Down
2 changes: 2 additions & 0 deletions R/smartid-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#' @import methods
#' @import stats
#' @import graphics
#' @importFrom SummarizedExperiment SummarizedExperiment assay
#' @importFrom utils globalVariables stack
#' @importClassesFrom Matrix dgCMatrix
NULL

Expand Down
32 changes: 17 additions & 15 deletions R/tf_idf_iae_wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#'
#' @examples
#' data <- matrix(rpois(100, 2), 10, dimnames = list(1:10))
#' tf(data)
#' smartid:::tf(data)
tf <- function(expr, log = FALSE) {
t.f <- sweep(expr, 2, colSums(expr, na.rm = TRUE) + 0.01, FUN = "/")
if(log) {
Expand Down Expand Up @@ -40,7 +40,7 @@ tf <- function(expr, log = FALSE) {
#'
#' @examples
#' data <- matrix(rpois(100, 2), 10, dimnames = list(1:10))
#' idf(data)
#' smartid:::idf(data)
idf <- function(expr, features = NULL, thres = 0) {
if(is.null(features)) features <- seq_len(nrow(expr))
n_obs <- ncol(expr) ## number of total obs
Expand All @@ -65,7 +65,7 @@ idf <- function(expr, features = NULL, thres = 0) {
#'
#' @examples
#' data <- matrix(rpois(100, 2), 10, dimnames = list(1:10))
#' idf_m(data)
#' smartid:::idf_m(data)
idf_m <- function(expr, features = NULL, thres = 0) {
if(is.null(features)) features <- seq_len(nrow(expr))
n_obs <- ncol(expr) ## number of total obs
Expand Down Expand Up @@ -95,7 +95,7 @@ idf_m <- function(expr, features = NULL, thres = 0) {
#'
#' @examples
#' data <- matrix(rpois(100, 2), 10, dimnames = list(1:10))
#' idf_sd(data)
#' smartid:::idf_sd(data)
idf_sd <- function(expr, features = NULL, thres = 0) {
if(is.null(features)) features <- seq_len(nrow(expr))
n_obs <- ncol(expr) ## number of total obs
Expand All @@ -120,8 +120,9 @@ idf_sd <- function(expr, features = NULL, thres = 0) {
#' @return a matrix of IDF score
#'
#' @examples
#' set.seed(123)
#' data <- matrix(rpois(100, 2), 10, dimnames = list(1:10))
#' idf_hdb(data)
#' smartid:::idf_hdb(data)
idf_hdb <- function(expr, features = NULL, multi = TRUE,
thres = 0, minPts = 2, ...) {
if(is.null(features)) features <- seq_len(nrow(expr))
Expand Down Expand Up @@ -159,7 +160,7 @@ idf_hdb <- function(expr, features = NULL, multi = TRUE,
#'
#' @examples
#' data <- matrix(rpois(100, 2), 10, dimnames = list(1:10))
#' idf_rf(data, label = sample(c("A", "B"), 10, replace = TRUE))
#' smartid:::idf_rf(data, label = sample(c("A", "B"), 10, replace = TRUE))
idf_rf <- function(expr, features = NULL, label,
multi = TRUE, thres = 0) {
if(is.null(features)) features <- seq_len(nrow(expr))
Expand Down Expand Up @@ -202,7 +203,7 @@ idf_rf <- function(expr, features = NULL, label,
#'
#' @examples
#' data <- matrix(rpois(100, 2), 10, dimnames = list(1:10))
#' idf_prob(data, label = sample(c("A", "B"), 10, replace = TRUE))
#' smartid:::idf_prob(data, label = sample(c("A", "B"), 10, replace = TRUE))
idf_prob <- function(expr, features = NULL, label,
multi = TRUE, thres = 0) {
if(is.null(features)) features <- seq_len(nrow(expr))
Expand Down Expand Up @@ -246,7 +247,7 @@ idf_prob <- function(expr, features = NULL, label,
#'
#' @examples
#' data <- matrix(rpois(100, 2), 10, dimnames = list(1:10))
#' idf_igm(data, label = sample(c("A", "B"), 10, replace = TRUE))
#' smartid:::idf_igm(data, label = sample(c("A", "B"), 10, replace = TRUE))
idf_igm <- function(expr, features = NULL, label, lambda = 7, thres = 0) {
if(is.null(features)) features <- seq_len(nrow(expr))

Expand Down Expand Up @@ -284,7 +285,7 @@ idf_igm <- function(expr, features = NULL, label, lambda = 7, thres = 0) {
#'
#' @examples
#' data <- matrix(rpois(100, 2), 10, dimnames = list(1:10))
#' iae(data)
#' smartid:::iae(data)
iae <- function(expr, features = NULL, thres = 0) {
if(is.null(features)) features <- seq_len(nrow(expr))
n_obs <- ncol(expr) ## number of total obs
Expand All @@ -311,7 +312,7 @@ iae <- function(expr, features = NULL, thres = 0) {
#'
#' @examples
#' data <- matrix(rpois(100, 2), 10, dimnames = list(1:10))
#' iae_m(data)
#' smartid:::iae_m(data)
iae_m <- function(expr, features = NULL, thres = 0) {
if(is.null(features)) features <- seq_len(nrow(expr))
n_obs <- ncol(expr) ## number of total obs
Expand Down Expand Up @@ -342,7 +343,7 @@ iae_m <- function(expr, features = NULL, thres = 0) {
#'
#' @examples
#' data <- matrix(rpois(100, 2), 10, dimnames = list(1:10))
#' iae_sd(data)
#' smartid:::iae_sd(data)
iae_sd <- function(expr, features = NULL, thres = 0) {
if(is.null(features)) features <- seq_len(nrow(expr))
n_obs <- ncol(expr) ## number of obs
Expand All @@ -369,8 +370,9 @@ iae_sd <- function(expr, features = NULL, thres = 0) {
#' @return a matrix of IAE score
#'
#' @examples
#' set.seed(123)
#' data <- matrix(rpois(100, 2), 10, dimnames = list(1:10))
#' iae_hdb(data)
#' smartid:::iae_hdb(data)
iae_hdb <- function(expr, features = NULL, multi = TRUE,
thres = 0, minPts = 2, ...) {
if(is.null(features)) features <- seq_len(nrow(expr))
Expand Down Expand Up @@ -420,7 +422,7 @@ iae_hdb <- function(expr, features = NULL, multi = TRUE,
#'
#' @examples
#' data <- matrix(rpois(100, 2), 10, dimnames = list(1:10))
#' iae_rf(data, label = sample(c("A", "B"), 10, replace = TRUE))
#' smartid:::iae_rf(data, label = sample(c("A", "B"), 10, replace = TRUE))
iae_rf <- function(expr, features = NULL, label,
multi = TRUE, thres = 0) {
if(is.null(features)) features <- seq_len(nrow(expr))
Expand Down Expand Up @@ -463,7 +465,7 @@ iae_rf <- function(expr, features = NULL, label,
#'
#' @examples
#' data <- matrix(rpois(100, 2), 10, dimnames = list(1:10))
#' iae_prob(data, label = sample(c("A", "B"), 10, replace = TRUE))
#' smartid:::iae_prob(data, label = sample(c("A", "B"), 10, replace = TRUE))
iae_prob <- function(expr, features = NULL, label,
multi = TRUE, thres = 0) {
if(is.null(features)) features <- seq_len(nrow(expr))
Expand Down Expand Up @@ -506,7 +508,7 @@ iae_prob <- function(expr, features = NULL, label,
#'
#' @examples
#' data <- matrix(rpois(100, 2), 10, dimnames = list(1:10))
#' iae_igm(data, label = sample(c("A", "B"), 10, replace = TRUE))
#' smartid:::iae_igm(data, label = sample(c("A", "B"), 10, replace = TRUE))
iae_igm <- function(expr, features = NULL, label, lambda = 7, thres = 0) {
if(is.null(features)) features <- seq_len(nrow(expr))

Expand Down
3 changes: 2 additions & 1 deletion R/top_markers.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @inheritParams top_markers_abs
#' @inheritParams top_markers_glm
#' @param use_glm logical, if to use [stats::glm()] to compute group mean score,
#' @param use.glm logical, if to use [stats::glm()] to compute group mean score,
#' if TRUE, also compute mean score difference as output
#' @param ... params for [top_markers_abs()] or [top_markers_glm()]
#'
Expand Down Expand Up @@ -190,3 +190,4 @@ softmax <- function(x, tau = 1) {
## tanh: [-1, 1], similar to sigmoid, no need to sum 1
tanh <- function(x) 2 / (1 + exp(-2*x)) - 1

utils::globalVariables(c(".dot", "Scores"))
4 changes: 3 additions & 1 deletion man/cal_score_init.Rd

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

5 changes: 4 additions & 1 deletion man/gs_score.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/iae.Rd

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

3 changes: 2 additions & 1 deletion man/iae_hdb.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/iae_igm.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/iae_m.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/iae_prob.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/iae_rf.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/iae_sd.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/idf.Rd

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

3 changes: 2 additions & 1 deletion man/idf_hdb.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/idf_igm.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/idf_m.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/idf_prob.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/idf_rf.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/idf_sd.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/tf.Rd

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

3 changes: 3 additions & 0 deletions man/top_markers.Rd

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

6 changes: 3 additions & 3 deletions man/top_markers_init.Rd

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

0 comments on commit c642665

Please sign in to comment.