Conversions: Data class conversions

ConversionsR Documentation

Data class conversions

Description

All functions to convert a COTAN object to/from other data classes used by the BioConductor analysis packages

Usage

convertToSingleCellExperiment(objCOTAN)

convertFromSingleCellExperiment(objSCE, clNamesPattern = "")

Arguments

objCOTAN

a COTAN object

objSCE

A SingleCellExperiment object to be converted

clNamesPattern

A regular expression pattern used to identify the clustering columns in colData. Default supports Seurat conventions: "^(COTAN_clusters_|seurat_clusters$|.*_snn_res\\..*|wsnn_res\\..*)"

Details

convertToSingleCellExperiment() converts a COTAN object into a SingleCellExperiment object. Stores the raw counts in the "counts" Assays, the metadata for genes and cells as rowData and colData slots respectively and finally the genes' and cells' coex along the dataset metadata into the metadata slot.

The function performs the following steps:

  • Extracts the raw counts matrix, gene metadata, cell metadata, gene and cell co-expression matrix from the COTAN object; the clustersCoex slot is not converted

  • Identifies clusterizations and conditions in the cell metadata by the prefixes "CL_" and "COND_"

  • Renames clusterization columns with the prefix "COTAN_clusters_" and condition columns with the prefix "COTAN_conditions_"

  • Constructs a SingleCellExperiment object with the counts matrix, gene metadata, updated cell metadata, and stores the co-expression matrices in the metadata slot.

The resulting SingleCellExperiment object is compatible with downstream analysis packages and workflows within the Bioconductor ecosystem

convertFromSingleCellExperiment() converts a SingleCellExperiment object back into a COTAN object. It supports SCE objects that were originally created from either a COTAN object or a Seurat object. The function extracts the "counts" matrix, genes' metadata, cells' metadata, co-expression matrices (if available), and reconstructs the COTAN object accordingly.

The function performs the following steps:

  • Extracts the raw matrix from the "counts" Assays

  • Extracts gene metadata from rowData

  • Extracts cell metadata from colData, excluding any clusterizations or conditions present

  • Attempts to retrieve co-expression matrices from the metadata slot if they exist

  • Constructs a COTAN object using the extracted data

  • Adds back the clusterizations and conditions using COTAN methods If the COEX is not present (e.g., in SCE objects created from Seurat), the genesCoex and cellsCoex slots in the resulting COTAN object will be empty matrices

Value

A SingleCellExperiment object containing the data from the input COTAN object, with clusterizations and conditions appropriately prefixed and stored in the cell metadata.

A COTAN object containing the data extracted from the input SingleCellExperiment object

See Also

COTAN, SingleCellExperiment

COTAN, SingleCellExperiment

Examples

  data("test.dataset")
  obj <- COTAN(raw = test.dataset)
  obj <- proceedToCoex(obj, calcCoex = FALSE, saveObj = FALSE)

  sce <- convertToSingleCellExperiment(objCOTAN = obj)

  newObj <- convertFromSingleCellExperiment(sce)

  identical(getDims(newObj), getDims(obj))


seriph78/COTAN documentation built on Dec. 10, 2024, 3:30 a.m.