getCNbins.sample: Get copy-number per bins in a sample

View source: R/dataprocessing_functions.R

getCNbins.sampleR Documentation

Get copy-number per bins in a sample

Description

This is a helper function for transforming segment tables to bin tables

Usage

getCNbins.sample(s, cn)

Arguments

s

sample name

cn

matrix with copy numbers in a bin (row) in samples (columns)

Value

a vector with copy numbers of samples in one bin

Examples

posBins <- lapply(1,function(chr)
    getBinsStartsEnds(window=1000000, chr, lengthChr[chr]))
pb=data.table::rbindlist(posBins)
samp=unique(cells_segcn$sample)[1]
data=cells_segcn[cells_segcn$sample==samp,]
data<-data.table::as.data.table(data[,c(5,4,1:3)])
data.table::setkey(pb, chromosome, start, end)
overlap=as.data.frame(data.table::foverlaps(data,pb))
cn=overlap[(overlap$chromosome=="1" & overlap$start==1 & overlap$end==500000),]
cell_bin=getCNbins.sample(s=samp,cn)

macintyrelab/CNpare documentation built on April 15, 2022, 4:46 a.m.