COMPASSContainer {COMPASS} | R Documentation

## Generate the Data Object used by COMPASS

### Description

This function generates the data container suitable for use with `COMPASS`.

### Usage

    COMPASSContainer(
      data,
      counts,
      meta,
      individual_id,
      sample_id,
      countFilterThreshold = 0
    )

### Arguments

`data` | A list of matrices. Each matrix `M_i` is made up of `N_i` cells by `K` markers; for example, it could be the intensity information from an intracellular cytokine experiment. Each element of the list should be named; this name denotes which sample the cell intensities were measured from.
`counts` | A named integer vector of the cell counts(of the parent population) for each sample in `data`.
`meta` | A `data.frame` of metadata, describing the individuals in the experiment. Each row in `meta` should correspond to a row in `data`. There should be one row for each sample; i.e., one row for each element of `data`.
`individual_id` | The name of the vector in `meta` that denotes the individuals from which samples were drawn. In this sense an individual equates to a single subject, or person.
`sample_id` | The name of the vector in `meta` that denotes the samples. The sample_id identifies a combination of a subject with visit (if any), cell subset measured (e.g. CD4), and stimulation. This vector should contain all of the names in the `data` input.
`countFilterThreshold` | Numeric; if the number of parent cells is less than this threshold, we remove that file. Default is 0, which means filter is disabled.

### Details

The `names` attributes for the `data` and `counts` objects passed should match.

### Value

A `COMPASSContainer` returns a list made up of the same components as input the model, but checks and sanitizes the supplied data to ensure that it conforms to the expectations outlied above.

### Examples

    set.seed(123)
    n <- 10 ## number of samples
    k <- 3 ## number of markers

    ## generate some sample data
    sid_vec <- paste0("sid_", 1:n) ## sample ids; unique names used to denote samples
    iid_vec <- rep_len( paste0("iid_", 1:(n/2) ), n ) ## individual ids

    ## generate n matrices of 'cell intensities'
    data <- replicate(n, {
      nrow <- round(runif(1) * 1E2 + 1000)
      ncol <- k
      vals <- rexp( nrow * ncol, runif(1, 1E-5, 1E-3) )
      vals[ vals < 2000 ] <- 0
      output <- matrix(vals, nrow, ncol)
      output <- output[ apply(output, 1, sum) > 0, ]
      colnames(output) <- paste0("M", 1:k)
      return(output)
    })
    names(data) <- sid_vec

    ## make a sample metadata data.frame
    meta <- data.frame(
      sid=sid_vec,
      iid=iid_vec,
      trt=rep( c("Control", "Treatment"), each=5 )
    )

    ## generate an example total counts
    ## recall that cells not expressing any marker are not included
    ## in the 'data' matrices
    counts <- sapply(data, nrow) + round( rnorm(n, 1E3, 1E2) )
    counts <- setNames( as.integer(counts), names(counts) )

    ## insert everything into a COMPASSContainer
    CC <- COMPASSContainer(data, counts, meta, "iid", "sid")

[Package COMPASS version 1.30.0 Index]