CalculateMedianClusterSize: Calculate Median Cluster Size

View source: R/gruffi.R

CalculateMedianClusterSizeR Documentation

Calculate Median Cluster Size

Description

This function calculates and returns the median size of clusters for a given assay and resolution in a Seurat object. It provides an option to display the median size via message.

Usage

CalculateMedianClusterSize(
  obj,
  assay = NULL,
  res = NULL,
  suffix = "_snn_res.",
  columnName = NULL,
  q = 0.5,
  verbose = TRUE
)

Arguments

obj

A Seurat object containing metadata with clustering information.

assay

The name of the assay to which the resolution parameter is applied.

res

The resolution level for which to calculate the median cluster size.

suffix

String suffix for clustering name

columnName

Directly provide a meta.data column name instead of parsing it.

q

quantile. Default: 0.5, i.e: the median.

verbose

Logical; if TRUE, prints the median cluster size to the console. Defaults to TRUE.

Details

The function generates a column name based on the assay and resolution parameters, checks for the existence of this column in the object's metadata, calculates the median size of the clusters, and optionally outputs this information as a message.

Value

The median size of the clusters at the specified resolution.

Examples

# Assuming `seuratObj` is a Seurat object with appropriate metadata
medianSize <- CalculateMedianClusterSize(obj = seuratObj, assay = "RNA", res = 0.8)


jn-goe/gruffi documentation built on Nov. 7, 2024, 10:38 p.m.