findSignatures: A function to construct a signature matrix

View source: R/findSignatures.R

findSignaturesR Documentation

A function to construct a signature matrix

Description

A function to construct a signature matrix

Usage

findSignatures(
  samples,
  sampleMeta,
  atlas = NULL,
  variation_cutoff = NULL,
  K = 100,
  IDs = NULL,
  tissueSpecCpGs = FALSE,
  tissueSpecDMPs = FALSE
)

Arguments

samples

dataframe, has first column IDs, rest of columns are samples (must have column name as sample accession ID which should be found in sampleMeta), rows are units of signature (e.g. CpGs)

sampleMeta

dataframe, must have first column for accession ID of each sample, and second column for cell type of sample, rows are samples

atlas

dataframe, the reference atlas to which new signatures can be added, if not present then a new reference atlas will be created using sample(s). Should be dataframe with column for each cell type, rows units of signature (e.g. CpGs)

variation_cutoff

either a number between 0 to 1, or NULL.For multiple samples from the same cell type, ignore CpGs with variation > variation_cutoff with that cell type. defaults to NULL (i.e. no cutoff)

K

only valid when tissueSpecCpGs is TRUE. K is the number of top methylation signature to be extracted.

IDs

the name of the column indicates ids

tissueSpecCpGs

if TRUE and atlas provided, it will extract tissue specific CpGs.

tissueSpecDMPs

if TRUE and atlas provided, it will extract tissue specific DMPs. Note that both tissueSpecCpGs and tissueSpecDMPs can't be TRUE at the same time.

Value

A dataframe extendedAtlas which contains all cell types in atlas (if given), and those in samples added by cell type, has first column "IDs", rest of columns are cell types, rows are have first cell with the ID (e.g. CpG ID) and then values of signature (e.g. methylation values) If tissueSpecCpGs is TRUE, it will return a list of list containing tissue specific methylation signatures. If tissueSpecDMPs is TRUE, it will return a list containing tissue specific DMPs.

Examples

data("HumanCellTypeMethAtlas")
exampleSamples <- simulateCellMix(1,
  reference = HumanCellTypeMethAtlas
)$simulated
exampleMeta <- data.table(
  "Experiment_accession" = "example_sample",
  "Biosample_term_name" = "example_cell_type"
)
colnames(exampleSamples) <- c("CpGs", "example_sample")
colnames(HumanCellTypeMethAtlas)[1] <- c("CpGs")

signatures <- findSignatures(
  samples = exampleSamples,
  sampleMeta = exampleMeta,
  atlas = HumanCellTypeMethAtlas,
  IDs = "CpGs", tissueSpecCpGs = FALSE
)
signatures <- findSignatures(
  samples = exampleSamples,
  sampleMeta = exampleMeta,
  atlas = HumanCellTypeMethAtlas,
  IDs = "CpGs", K = 100, tissueSpecCpGs = TRUE
)

BIMSBbioinfo/deconvR documentation built on April 26, 2023, 7:05 a.m.