From c4a36bb1d8f08213b51fc6cbaf187e4d98fa3133 Mon Sep 17 00:00:00 2001 From: samuel-marsh Date: Wed, 8 Nov 2023 09:33:10 -0500 Subject: [PATCH] temp remove liger dep functions --- NAMESPACE | 1 - R/LIGER_Utilities.R | 140 ++++++++++++++--------------- man/Variable_Features_ALL_LIGER.Rd | 58 ------------ 3 files changed, 70 insertions(+), 129 deletions(-) delete mode 100644 man/Variable_Features_ALL_LIGER.Rd diff --git a/NAMESPACE b/NAMESPACE index 443a865739..d5b83e4e64 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/R/LIGER_Utilities.R b/R/LIGER_Utilities.R index 927bebb55d..01bad5e1f5 100644 --- a/R/LIGER_Utilities.R +++ b/R/LIGER_Utilities.R @@ -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 <- 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) +# } #' Create a Seurat object containing the data from a liger object diff --git a/man/Variable_Features_ALL_LIGER.Rd b/man/Variable_Features_ALL_LIGER.Rd deleted file mode 100644 index d9ceffd94b..0000000000 --- a/man/Variable_Features_ALL_LIGER.Rd +++ /dev/null @@ -1,58 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/LIGER_Utilities.R -\name{Variable_Features_ALL_LIGER} -\alias{Variable_Features_ALL_LIGER} -\title{Perform variable gene selection over whole dataset} -\usage{ -Variable_Features_ALL_LIGER( - liger_object, - num_genes = NULL, - var.thresh = 0.3, - alpha.thresh = 0.99, - tol = 1e-04, - do.plot = FALSE, - pt.size = 0.3, - chunk = 1000 -) -} -\arguments{ -\item{liger_object}{LIGER object name.} - -\item{num_genes}{Number of genes to find. Optimizes the value of \code{var.thresh} to get -this number of genes, (Default is NULL).} - -\item{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).} - -\item{alpha.thresh}{Alpha threshold. Controls upper bound for expected mean gene -expression (lower threshold -> higher upper bound). (default 0.99)} - -\item{tol}{Tolerance to use for optimization if num.genes values passed in (default 0.0001).} - -\item{do.plot}{Display log plot of gene variance vs. gene expression. Selected genes are -plotted in green. (Default FALSE)} - -\item{pt.size}{Point size for plot.} - -\item{chunk}{size of chunks in hdf5 file. (Default 1000)} -} -\value{ -A LIGER Object with variable genes in correct slot. -} -\description{ -Performs variable gene selection for LIGER object across the entire object instead of by -dataset and then taking union. -} -\examples{ -\dontrun{ -liger_obj <- Variable_Features_ALL_LIGER(liger_object = liger_obj, num_genes = 2000) -} - -} -\references{ -Matching function parameter text descriptions are taken from \code{rliger::selectGenes} -which is called by this function after creating new temporary object/dataset. -\url{https://github.com/welch-lab/liger}. (License: GPL-3). -} -\concept{liger_object_util}