addCells: Add cells to an existing cnr

View source: R/addCells.R

addCellsR Documentation

Add cells to an existing cnr

Description

The function deals a little with the n+1 problem.

Usage

addCells(cnr, newX, newY, newqc, newYe = NULL, do.clean = TRUE, ...)

Arguments

cnr

a cnr bundle

newX

bin data for the new cells to be incorporated

newY

phenotype data for the new cells

newqc

qc metadata for the new cells

newYe

exprssion data for new cells

do.clean

weather to remove additional data stored in the cnr, default is TRUE

...

additional parameters if needed

Details

Your data needs to be 'exact' to the existing cnr for it to be compatible. This means it needs to have the same bin coordinates and number of X bins, annotation colums, and same qc colums. It is assumed you generated it with the same pipeline.

Value

Returns a CNR object after adding new cells. If 'do.clean = TRUE' only the original eight data items will be returned.

  • X copy number data

  • Y phenotype data

  • exprs expression data

  • qc quality control data

  • chromInfo bin to chromosome information

  • gene.index gene to bin and chromosome information

  • cells list of cells

  • bulk bulk DNA or single-cell copy number. If TRUE, data is bulk DNA log2 ratio

  • ... additional analyzed results

Examples


library(gac)
data(cnr)
sapply(cnr, dim)

data(pheno)
data(qc)

## create unique cell names
n.cells <- nrow(cnr$Y)
new.cells <- paste0("cell", n.cells + 1:2)

## new X w simulated data
newX <- data.frame(cbind(rep(c(5,2), c(3000, 2000)),
                        rep(c(2,4),  c(3000, 2000))))
names(newX) <- new.cells
head(newX)
tail(newX)

## creating new phenotypes
newY <- head(pheno, n = 2)
newY$cellID <- new.cells
rownames(newY) <- newY$cellID
newY[, c(6:9)] <- newY[,c(6,9)]+3

newY

## creating new QC
newQC <- head(qc, 2)
newQC$cellID <- new.cells
rownames(newQC) <- newQC$cellID

newQC[,2:4] <- newQC[,2:4] + 2
newQC

## add cells
cnr <- addCells(cnr, newX = newX, newY = newY, newqc = newQC)
sapply(cnr, dim)



SingerLab/gac documentation built on Oct. 14, 2022, 4:09 a.m.