getUNDmatrix {BrainSABER} | R Documentation

## getUNDmatrix

### Description

This function returns a matrix showing whether gene expression values in `dataSet` are up-regulated, down-regulated, or normal. `method = "discrete"` will function on any CellScabbard object, while `method = "log2FC"` requires a trimmed data set as returned by `getTrimmedExternalSet` and a matching subset of AIBSARNA as returned by `getRelevantGenes`. Results are stored in the 'UNDmatrices' slot of the `dataSet` if it's a CellScabbard object.

### Usage

    getUNDmatrix(
      dataSet,
      relevantGenes = NULL,
      method = c("discrete", "log2FC"),
      up_threshold = 0.5,
      down_threshold = -0.5,
      matrix_type = c("num", "char")
    )

### Arguments

`dataSet` | a CellScabbard or SummarizedExperiment object
`relevantGenes` | (optional) a SummarizedExperiment and subset of AIBSARNA
`method` | `"discrete"` applies thresholds directly to expression data. `"log2FC"` applies thresholds to the log2 fold-change between the expression data of each sample from `dataSet` and `relevantGenes`.
`up_threshold` | a numerical value defining the lower bound (inclusive) by which to consider a gene up-regulated, defaults to 0.5
`down_threshold` | a numerical value defining the upper bound (inclusive) by which to consider a gene down-regulated, defaults to -0.5
`matrix_type` | either `"num"` for a numerical matrix with -1 indicating down-regulation, 1 indicating up-regulation, and 0 indicating normal, or `"char"` for a character matrix with "D" indicating down-regulation, "U" indicating up-regulation, and "N" indicating normal

### Value

a list containing as many numerical or character matrices as samples in `dataSet`, with each matrix having as many rows as genes in `dataSet` and as many columns as samples in `relevantGenes`

### Examples

    AIBSARNA <- buildAIBSARNA(mini = TRUE)
    # Example 1 - using CellScabbard class
    # get a random sample of 3 genes
    totalGenes <- nrow(AIBSARNA)
    gene_idx <- sample.int(totalGenes, 3)
    sample_idx <- c(1,3,5)
    # Subset AIBSARNA
    exprs <- assay(AIBSARNA)[gene_idx, sample_idx]
    fd <- rowData(AIBSARNA)[gene_idx, ]
    pd <- colData(AIBSARNA)[sample_idx, ]
    # build a trimmed data set
    myGenes <- CellScabbard(exprsData = exprs, phenoData = pd, featureData = fd,
                            AIBSARNA = AIBSARNA, autoTrim = TRUE)
    UNDmatrices(myGenes) <- getUNDmatrix(myGenes, method = "discrete",
                                         up_threshold = 3,
    down_threshold = 1, matrix_type = "char")
    UNDmatrices(myGenes)
    UNDmatrices(myGenes) <- getUNDmatrix(myGenes, method = "log2FC",
                                         up_threshold = 3,
    down_threshold = 1, matrix_type = "num")
    UNDmatrices(myGenes)

    # Example 2 - manual gene selection and relevant gene extraction
    myGenes <- c(4.484885, 0.121902, 0.510035)
    names(myGenes) <- c("TSPAN6", "DPM1", "C1orf112")
    myGeneSet <- getRelevantGenes(myGenes, AIBSARNA = AIBSARNA,
        AIBSARNAid = "gene_symbol")
    myTrimmedGeneSet <- getTrimmedExternalSet(myGeneSet,
        dataSetId = "gene_symbol", AIBSARNA, AIBSARNAid = "gene_symbol")
    myUNDnumericalMatrix <- getUNDmatrix(myTrimmedGeneSet, method = "discrete",
        up_threshold = 3, down_threshold = 1, matrix_type = "num")
    myUNDcharacterMatrix <- getUNDmatrix(myTrimmedGeneSet, myGeneSet,
                                         method = "log2FC",
        up_threshold = 3, down_threshold = 1, matrix_type = "char")

[Package BrainSABER version 1.4.0 Index]