Generating simulations and data:

library(TACG)
set.seed(123)
data('loci')
data('chlens')
temp <- genSimChroms(N=3, chr=17, loci=loci, minLen=200000, maxLen=10000000, datapath=NULL, chlens=chlens, save=FALSE)
sims <- lapply(1:length(temp),function(i){temp[[i]]$sim})
dataset <- lapply(1:length(temp),function(i){temp[[i]]$dat})

Running segmentation algorithms:

res <- runSegAlgs(i=1, alg='DNAcopy', data=dataset[[1]], respath=NULL,saveRes=FALSE,alpha=NULL,thresh=NULL)
algs <- c('DNAcopy','HMM','Haar','GLAD')
indices <- 1:length(dataset)
resSet <- runSegAlgsOnSet(algs=algs,indices=indices,cores=1,data=dataset,respath=NULL,save=FALSE)

Assessing results:

assessments.dnac <- assess(alg='DNAcopy',set=indices,res=resSet[1:3],sims=sims)
assessments.hmm <- assess(alg='HMM',set=indices,res=resSet[4:6],sims=sims)
assessments.haar <- assess(alg='Haar',set=indices,res=resSet[7:9],sims=sims)
assessments.glad <- assess(alg='GLAD',set=indices,res=resSet[10:12],sims=sims)

Plotting characteristics:


Now, let's simulate a tumor with mutations according to a pre-specified mutation conditional probability matrix:

#Generating 6 mutation loci:
loci <- sample(1:100000,6,replace=FALSE)
chrs <- sort(sample(1:22,length(loci),replace=TRUE))
probset <- c(.6,.15,.1,.05,.05,.05)
genenames <- c('gene_A','gene_B','gene_C','gene_D','gene_E','gene_F')
psi <- c(.35,.28,.17,.1,.07,.03)

mutationProbs <- generateMutationProbs(loci, chrs, genenames, mutually.exclusive=list(c(2,4)), probs=probset)
tumor <- Tumor(psi, rounds=6, pcnv=0, mutationProbs=mutationProbs)
data <- generateTumorData(tumor,snps.seq=1000000,snps.cgh=600000,mu=200,sigma.reads=25,sigma0.lrr=.15, sigma0.baf=.03,density.sigma=.1)

Let's look at the simulated tumor and visualize the data:

library(igraph)
tree <- tumor@tree
tree.df <- tree$tree.df
seqdf <- data$seq.data
somatic <- seqdf[seqdf$status=='somatic',]
plot(tree$tree.obj, layout = layout.reingold.tilford)
plot(somatic$VAF)


MarkRZucker/TACG documentation built on June 14, 2019, 12:28 p.m.