getCNbins.bin: Get copy-number in a bin

View source: R/dataprocessing_functions.R

getCNbins.binR Documentation

Get copy-number in a bin

Description

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

Usage

getCNbins.bin(b, pb, overlap, samples)

Arguments

b

bin number

pb

matrix with genomic positions of bins

overlap

table with overlaps between bin and segment table

samples

vector with sample names

Value

a list of copy-number values per 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_bin <- getCNbins.bin(b=2,pb,overlap,samples=samp)

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