Skip to content

Extend functions (e.g., Cluster_Stats_All_Samples) to support data.frame and data.table inputs #253

@lisch7

Description

@lisch7

Hi,

First of all, thank you for developing scCustomize — it’s an excellent package and very useful in my daily workflow.

I’ve noticed that several functions in the package (for example, Cluster_Stats_All_Samples) are currently limited to accepting Seurat object inputs. While this works well, many of these functions could easily operate on a data.frame that already contains the required information. When using the seurat object when sub subsets are needed, the operation takes more time. It is better to use sce@meta.data directly.

I think it would greatly improve flexibility if these functions could also support data.frame or data.table inputs. Additionally, instead of relying exclusively on seurat_object@active.ident, a new argument could be added to specify which column should be used as the cluster identity.

A simple code is attached:

if (class(object)=="Seurat"){
    data <- object@meta.data
  } else if (class(object)=="data.frame") {
    data <- as.data.frame(object)
  } else {
    stop("'object' is not a Seurat object or a data frame.")
  }

This small enhancement would make scCustomize more general and easier to integrate into broader R workflows beyond Seurat.

Metadata

Metadata

Assignees

Labels

enhancementEnhance existing function/feature

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions