Skip to content

Commit

Permalink
update scKirkby
Browse files Browse the repository at this point in the history
  • Loading branch information
bschilder committed Apr 21, 2024
1 parent 3ba75d8 commit 008d72d
Show file tree
Hide file tree
Showing 25 changed files with 19 additions and 71 deletions.
31 changes: 1 addition & 30 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -87,48 +87,19 @@ export(to_se)
export(to_seurat)
export(to_sparse)
export(update_seurat)
import(Seurat)
import(data.table)
import(orthogene)
importClassesFrom(SeuratObject,Graph)
importFrom(DelayedArray,DelayedArray)
importFrom(EWCE,generate_celltype_data)
importFrom(EWCE,merge_sce)
importFrom(EWCE,standardise_ctd)
importFrom(Matrix,t)
importFrom(Seurat,CreateAssayObject)
importFrom(Seurat,CreateSeuratObject)
importFrom(Seurat,DefaultAssay)
importFrom(Seurat,FindClusters)
importFrom(Seurat,FindNeighbors)
importFrom(Seurat,FindVariableFeatures)
importFrom(Seurat,GetAssayData)
importFrom(Seurat,LogNormalize)
importFrom(Seurat,NormalizeData)
importFrom(Seurat,RunPCA)
importFrom(Seurat,RunUMAP)
importFrom(Seurat,ScaleData)
importFrom(Seurat,as.CellDataSet)
importFrom(SeuratObject,CreateDimReducObject)
importFrom(SeuratObject,Graphs)
importFrom(SeuratObject,as.Graph)
importFrom(SingleCellExperiment,colData)
importFrom(SummarizedExperiment,assay)
importFrom(SummarizedExperiment,assayNames)
importFrom(data.table,as.data.table)
importFrom(data.table,data.table)
importFrom(data.table,setkeyv)
importFrom(data.table,tstrsplit)
importFrom(echoconda,activate_env)
importFrom(future,plan)
importFrom(methods,.hasSlot)
importFrom(methods,as)
importFrom(methods,is)
importFrom(methods,slot)
importFrom(orthogene,map_orthologs)
importFrom(sceasy,convertFormat)
importFrom(stats,setNames)
importFrom(tidyr,all_of)
importFrom(tidyr,unite)
importFrom(utils,data)
importFrom(utils,getFromNamespace)
importFrom(utils,installed.packages)
2 changes: 1 addition & 1 deletion R/_docs.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#' @inheritParams converters
#' @inheritParams map_data
#' @inheritParams to_se
#' @inheritParams orthogene::aggregate_rows
#' @inheritParams orthogene::aggregate_mapped_genes
#' @inheritParams EWCE::generate_celltype_data
#' @inheritParams EWCE::standardise_ctd
#' @returns Converted object.
Expand Down
1 change: 0 additions & 1 deletion R/anndata_to_seurat.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#'
#' @param ... Parameters passed to \code{sceasy::convertFormat}.
#' @export
#' @importFrom sceasy convertFormat
#' @examples
#' obj <- example_obj("anndata")
#' seurat <- anndata_to_seurat(obj)
Expand Down
2 changes: 0 additions & 2 deletions R/calc_cor.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#' @returns A single-cell object with a graph.
#'
#' @keywords internal
#' @importFrom Matrix t
#' @importFrom methods as slot
calc_cor <- function(obj,
keys = NULL,
graph_key = NULL,
Expand Down
10 changes: 4 additions & 6 deletions R/converters.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
#' Converters
#'
#' @describeIn converters
#' Functions to convert one single-cell format to another.
#' @param obj A single-cell object supported by \pkg{scKirby}.
#' See \link[scKirby]{converters} for a table of all supported conversions.
#' See \link{converters} for a table of all supported conversions.
#' @param verbose Print messages.
#' @param ... Additional arguments passed to the respective
#' \link[scKirby]{converters} function.
#' @param ... Additional arguments passed to the respective converter function.
#' \link{converters} function.
#'
#' @export
#' @importFrom data.table data.table tstrsplit setkeyv
#' @examples
#' map_dt <- converters()
converters <- function(){
converters <- function(obj, verbose, ...){
func <- NULL;

ns <- getNamespaceExports("scKirby")
Expand Down
3 changes: 0 additions & 3 deletions R/example_obj.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
#' @returns A single-cell object.
#'
#' @export
#' @importFrom utils data
#' @importClassesFrom SeuratObject Graph
#' @importFrom SeuratObject Graphs
#' @examples
#' se <- example_obj("se")
#' sce <- example_obj("sce")
Expand Down
1 change: 0 additions & 1 deletion R/get_obsm.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#' @returns A matrix of cell embeddings coordinates.
#'
#' @export
#' @importFrom methods is
#' @examples
#' obj <- example_obj("cds")
#' obsm <- get_obsm(obj)
Expand Down
1 change: 0 additions & 1 deletion R/get_obsp.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#' @returns Named list of graph objects.
#'
#' @export
#' @importFrom methods is
#' @examples
#' obj <- example_obj("seurat")
#' g <- get_obsp(obj)
Expand Down
1 change: 0 additions & 1 deletion R/get_varm.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#' @returns A named list of matrices containing the feature loadings.
#'
#' @export
#' @importFrom methods is
#' @examples
#' obj <- example_obj("seurat")
#' varm <- get_varm(obj)
Expand Down
1 change: 0 additions & 1 deletion R/get_x.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#' @returns A named list of matrices.
#'
#' @export
#' @importFrom Matrix t
#' @examples
#' obj <- example_obj("seurat")
#' X <- get_x(obj)
Expand Down
2 changes: 1 addition & 1 deletion R/is_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' When \code{group} is supplied,
#' determine whether a single-cell object belongs to a particular group of
#' object classes.
#' See \linkp[scKirby]{dict_class} for details.
#' See \link{dict_class} for details.
#' @inheritParams converters
#' @inheritParams dict_class
#'
Expand Down
1 change: 0 additions & 1 deletion R/is_installed.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#' @returns Boolean
#'
#' @keywords internal
#' @importFrom utils installed.packages
is_installed <- function(pkg,
error=FALSE) {
bool <- requireNamespace(pkg, quietly = TRUE)
Expand Down
1 change: 0 additions & 1 deletion R/list_to_dimreduc.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#' @inheritDotParams SeuratObject::CreateDimReducObject
#'
#' @export
#' @importFrom SeuratObject CreateDimReducObject
list_to_dimreduc <- function(obj,
assay,
key,
Expand Down
2 changes: 1 addition & 1 deletion R/matrices_to_assayobjects.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @param X_list A named list of matrices (one per unique assay in
#' \code{X_list}) to be put in the \code{counts} slot of each
#' \code{AssayObject}.
#' @param var_features [Optional] A named list of feature metadata data.frames
#' @param var_features (Optional) A named list of feature metadata data.frames
#' (one per unique assay in \code{X_list}) to be put in the
#' \code{meta.features} slot of each \code{AssayObject}.
#' @inheritParams converters
Expand Down
14 changes: 9 additions & 5 deletions R/process_seurat.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,18 @@
#' @inheritParams Seurat::FindVariableFeatures
#' @inheritParams Seurat::ScaleData
#' @inheritParams Seurat::RunUMAP
#' @inheritParams Seurat::FindClusters
#' @returns A preprocessed \link[SeuratObject]{Seurat} object.
#'
#' @export
#' @importFrom Seurat CreateSeuratObject GetAssayData CreateAssayObject
#' DefaultAssay FindVariableFeatures NormalizeData LogNormalize ScaleData
#' RunPCA FindNeighbors RunUMAP FindClusters
#' @import Seurat
#' @importFrom future plan
#' @examples
#' obj <- example_obj("seurat")
#' obj2 <- process_seurat(obj = obj)
process_seurat <- function(obj = NULL,
meta.data = NULL,
nfeatures = 2000,
nfeatures = NULL,
reduction="pca",
dims = seq(100),
add_specificity = FALSE,
Expand All @@ -56,6 +55,8 @@ process_seurat <- function(obj = NULL,
scale_data=TRUE,
vars.to.regress = NULL,
cluster_reduction = "umap",
algorithm = 1,
resolution = 0.8,
workers = 1,
max_mem = 8000*1024^2,
seed = 2020,
Expand Down Expand Up @@ -116,7 +117,10 @@ process_seurat <- function(obj = NULL,
reduction = cluster_reduction,
dims = seq_len(n.components))
}
obj2 <- Seurat::FindClusters(obj2)
obj2 <- Seurat::FindClusters(obj2,
algorithm=algorithm,
resolution=resolution,
random.seed=seed)
#### Return ####
return(obj2)
}
1 change: 0 additions & 1 deletion R/se_to_anndata.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#' @returns \link[anndata]{AnnData} object.
#'
#' @export
#' @importFrom sceasy convertFormat
#' @examples
#' obj <- example_obj("se")
#' obj2 <- se_to_anndata(obj)
Expand Down
1 change: 0 additions & 1 deletion R/se_to_loom.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#' Convert: \code{SummarizedExperiment} ==> \code{loom}
#'
#' @describeIn converters Convert
#' \link[SummarizedExperiment]{SummarizedExperiment} to
#' \link[SeuratDisk]{loom}
#' @inheritParams converters
Expand Down
1 change: 0 additions & 1 deletion R/set_obsp.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#' @returns Named list of graph objects.
#'
#' @export
#' @importFrom methods is
#' @examples
#' obj <- example_obj("seurat")
#' g <- get_cor(obj)
Expand Down
1 change: 0 additions & 1 deletion R/seurat_to_cds.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#' \link[monocle]{CellDataSet} object.
#'
#' @export
#' @importFrom Seurat as.CellDataSet
#' @examples
#' obj <- example_obj("seurat")
#' obj2 <- seurat_to_cds(obj)
Expand Down
7 changes: 2 additions & 5 deletions R/seurat_to_hdf5se.R
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
#' Convert: \code{Seurat} ==> \code{hdf5se}
#'
#' @inheritDotParams save_hdf5se
#' @inheritParams converters
#' @export
#' @examples
#' obj <- example_obj("seurat")
#' obj2 <- seurat_to_hdf5se(obj)
seurat_to_hdf5se <- function(obj,
save_path = tempfile(),
verbose = TRUE,
...){
verbose = TRUE){

messager("+ Seurat ==> hdf5se",v=verbose)
obj <- seurat_to_se(obj = obj,
verbose = verbose)
save_hdf5se(obj = obj,
save_dir = save_path,
verbose = verbose,
...)
verbose = verbose)
}
2 changes: 0 additions & 2 deletions R/seurat_to_list.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#' @returns A named list.
#'
#' @export
#' @importFrom methods .hasSlot slot
#' @importFrom stats setNames
#' @examples
#' obj <- example_obj("seurat")
#' obj2 <- seurat_to_list(obj)
Expand Down
1 change: 0 additions & 1 deletion R/to_anndata.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#' To \code{AnnData}
#'
#' @describeIn converters
#' Convert any single-cell object to \link[anndata]{AnnData} format.
#' @param reimport Save and re-import the \link[anndata]{AnnData} object
#' into R to ensure all data has been converted from Python-native to
Expand Down
1 change: 0 additions & 1 deletion R/to_cds.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#' Convert: to \code{CellDataSet}
#'
#' @describeIn converters
#' Convert any object to \code{CellDataSet} format.
#' @inheritParams converters
#' @returns A \code{CellDataSet} object.
Expand Down
1 change: 0 additions & 1 deletion R/to_datatable.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#' @returns A \code{data.table} object.
#'
#' @export
#' @importFrom data.table as.data.table
#' @examples
#' obj <- example_obj("cds")
#' obj2 <- to_dataframe(obj)
Expand Down
1 change: 0 additions & 1 deletion R/to_graph.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#' @returns A sparse \link[SeuratObject]{as.Graph} object.
#'
#' @export
#' @importFrom SeuratObject as.Graph
#' @examples
#' obj <- example_obj("matrix")
#' obj2 <- to_graph(obj)
Expand Down

0 comments on commit 008d72d

Please sign in to comment.