Skip to content

Commit

Permalink
temp remove liger dep functions
Browse files Browse the repository at this point in the history
  • Loading branch information
samuel-marsh committed Nov 8, 2023
1 parent dc50ff3 commit c4a36bb
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 129 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export(Store_Palette_Seurat)
export(Top_Genes_Factor)
export(UnRotate_X)
export(VariableFeaturePlot_scCustom)
export(Variable_Features_ALL_LIGER)
export(VlnPlot_scCustom)
export(plotFactors_scCustom)
export(scCustomize_Palette)
Expand Down
140 changes: 70 additions & 70 deletions R/LIGER_Utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -898,76 +898,76 @@ Plot_By_Meta_LIGER <- function(
}


#' Perform variable gene selection over whole dataset
#'
#' Performs variable gene selection for LIGER object across the entire object instead of by
#' dataset and then taking union.
#'
#' @param liger_object LIGER object name.
#' @param num_genes Number of genes to find. Optimizes the value of `var.thresh` to get
#' this number of genes, (Default is NULL).
#' @param var.thresh Variance threshold. Main threshold used to identify variable genes.
#' Genes with expression variance greater than threshold (relative to mean) are selected.
#' (higher threshold -> fewer selected genes).
#' @param alpha.thresh Alpha threshold. Controls upper bound for expected mean gene
#' expression (lower threshold -> higher upper bound). (default 0.99)
#' @param tol Tolerance to use for optimization if num.genes values passed in (default 0.0001).
#' @param do.plot Display log plot of gene variance vs. gene expression. Selected genes are
#' plotted in green. (Default FALSE)
#' @param pt.size Point size for plot.
#' @param chunk size of chunks in hdf5 file. (Default 1000)
#'
#' @return A LIGER Object with variable genes in correct slot.
#'
#' @import cli
#'
#' @references Matching function parameter text descriptions are taken from `rliger::selectGenes`
#' which is called by this function after creating new temporary object/dataset.
#' \url{https://github.com/welch-lab/liger}. (License: GPL-3).
#'
#' @export
#'
#' @concept liger_object_util
#'
#' @examples
#' \dontrun{
#' liger_obj <- Variable_Features_ALL_LIGER(liger_object = liger_obj, num_genes = 2000)
#' }
#'

Variable_Features_ALL_LIGER <- function(
liger_object,
num_genes = NULL,
var.thresh = 0.3,
alpha.thresh = 0.99,
tol = 0.0001,
do.plot = FALSE,
pt.size = 0.3,
chunk=1000
) {
Is_LIGER(liger_object = liger_object)

raw_data <- liger_object@raw.data

cli_inform(message = "Creating temporary object with combined data.")

temp_liger <- rliger::createLiger(raw.data = list("dataset" = Merge_Sparse_Data_All(raw_data)), remove.missing = FALSE)

rm(raw_data)
gc()

cli_inform(message = "Normalizing and identifying variable features.")

temp_liger <- rliger::normalize(object = temp_liger)
temp_liger <- rliger::selectGenes(object = temp_liger, var.thresh = var.thresh, do.plot = do.plot, num.genes = num_genes, tol = tol, alpha.thresh = alpha.thresh, cex.use = pt.size, chunk = chunk)
var_genes <- temp_liger@var.genes

rm(temp_liger)
gc()

liger_object@var.genes <- var_genes
return(liger_object)
}
# #' Perform variable gene selection over whole dataset
# #'
# #' Performs variable gene selection for LIGER object across the entire object instead of by
# #' dataset and then taking union.
# #'
# #' @param liger_object LIGER object name.
# #' @param num_genes Number of genes to find. Optimizes the value of `var.thresh` to get
# #' this number of genes, (Default is NULL).
# #' @param var.thresh Variance threshold. Main threshold used to identify variable genes.
# #' Genes with expression variance greater than threshold (relative to mean) are selected.
# #' (higher threshold -> fewer selected genes).
# #' @param alpha.thresh Alpha threshold. Controls upper bound for expected mean gene
# #' expression (lower threshold -> higher upper bound). (default 0.99)
# #' @param tol Tolerance to use for optimization if num.genes values passed in (default 0.0001).
# #' @param do.plot Display log plot of gene variance vs. gene expression. Selected genes are
# #' plotted in green. (Default FALSE)
# #' @param pt.size Point size for plot.
# #' @param chunk size of chunks in hdf5 file. (Default 1000)
# #'
# #' @return A LIGER Object with variable genes in correct slot.
# #'
# #' @import cli
# #'
# #' @references Matching function parameter text descriptions are taken from `rliger::selectGenes`
# #' which is called by this function after creating new temporary object/dataset.
# #' \url{https://github.com/welch-lab/liger}. (License: GPL-3).
# #'
# #' @export
# #'
# #' @concept liger_object_util
# #'
# #' @examples
# #' \dontrun{
# #' liger_obj <- Variable_Features_ALL_LIGER(liger_object = liger_obj, num_genes = 2000)
# #' }
# #'

# Variable_Features_ALL_LIGER <- function(
# liger_object,
# num_genes = NULL,
# var.thresh = 0.3,
# alpha.thresh = 0.99,
# tol = 0.0001,
# do.plot = FALSE,
# pt.size = 0.3,
# chunk=1000
# ) {
# Is_LIGER(liger_object = liger_object)
#
# raw_data <- [email protected]
#
# cli_inform(message = "Creating temporary object with combined data.")
#
# temp_liger <- rliger::createLiger(raw.data = list("dataset" = Merge_Sparse_Data_All(raw_data)), remove.missing = FALSE)
#
# rm(raw_data)
# gc()
#
# cli_inform(message = "Normalizing and identifying variable features.")
#
# temp_liger <- rliger::normalize(object = temp_liger)
# temp_liger <- rliger::selectGenes(object = temp_liger, var.thresh = var.thresh, do.plot = do.plot, num.genes = num_genes, tol = tol, alpha.thresh = alpha.thresh, cex.use = pt.size, chunk = chunk)
# var_genes <- [email protected]
#
# rm(temp_liger)
# gc()
#
# [email protected] <- var_genes
# return(liger_object)
# }


#' Create a Seurat object containing the data from a liger object
Expand Down
58 changes: 0 additions & 58 deletions man/Variable_Features_ALL_LIGER.Rd

This file was deleted.

0 comments on commit c4a36bb

Please sign in to comment.