Skip to content

Commit 38972e2

Browse files
committed
Removed MPEAR, code cleanup and added documentation
1 parent 1bbdab1 commit 38972e2

13 files changed

+276
-712
lines changed

Diff for: DESCRIPTION

100644100755
+2-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ Depends:
1414
ks,
1515
lattice,
1616
ggplot2,
17-
gridExtra,
18-
mcclust
17+
gridExtra
1918
LazyLoad: yes
19+
RoxygenNote: 6.1.1

Diff for: Dockerfile

100644100755
+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ USER root
44

55
RUN apt-get update && apt-get -y install r-base
66

7-
RUN R -q -e 'source("http://bioconductor.org/biocLite.R"); biocLite(c("optparse"","KernSmooth","ks","lattice","ggplot2","gridExtra","mcclust"))'
7+
RUN R -q -e 'source("http://bioconductor.org/biocLite.R"); biocLite(c("optparse"","KernSmooth","ks","lattice","ggplot2","gridExtra"))'
88

99
RUN mkdir -p /opt/dpclust
1010
COPY . /opt/dpclust/

Diff for: NAMESPACE

100644100755
+47-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,48 @@
1-
exportPattern("^[[:alpha:]]+")
2-
import(lattice)
3-
import(KernSmooth)
4-
import(ks)
5-
import(mcclust)
6-
import(gridExtra)
7-
import(ggplot2)
1+
# Generated by roxygen2: do not edit by hand
82

3+
export(RunDP)
4+
export(make_advanced_params)
5+
export(make_run_params)
6+
export(make_sample_params)
7+
import(ggplot2)
8+
import(gridExtra)
9+
importFrom(KernSmooth,bkde)
10+
importFrom(KernSmooth,bkde2D)
11+
importFrom(grDevices,cm.colors)
12+
importFrom(grDevices,colorRampPalette)
13+
importFrom(grDevices,dev.cur)
14+
importFrom(grDevices,dev.off)
15+
importFrom(grDevices,dev.set)
16+
importFrom(grDevices,pdf)
17+
importFrom(grDevices,png)
18+
importFrom(grDevices,rainbow)
19+
importFrom(grDevices,rgb)
20+
importFrom(graphics,hist)
21+
importFrom(graphics,legend)
22+
importFrom(graphics,lines)
23+
importFrom(graphics,par)
24+
importFrom(graphics,plot)
25+
importFrom(graphics,points)
26+
importFrom(graphics,polygon)
27+
importFrom(graphics,text)
28+
importFrom(graphics,title)
29+
importFrom(ks,kde)
30+
importFrom(lattice,levelplot)
31+
importFrom(lattice,lpoints)
32+
importFrom(lattice,panel.abline)
33+
importFrom(lattice,panel.levelplot)
34+
importFrom(stats,density)
35+
importFrom(stats,median)
36+
importFrom(stats,pchisq)
37+
importFrom(stats,quantile)
38+
importFrom(stats,rbeta)
39+
importFrom(stats,rbinom)
40+
importFrom(stats,rgamma)
41+
importFrom(stats,rmultinom)
42+
importFrom(stats,runif)
43+
importFrom(stats,sd)
44+
importFrom(utils,head)
45+
importFrom(utils,read.csv)
46+
importFrom(utils,read.table)
47+
importFrom(utils,write.csv)
48+
importFrom(utils,write.table)

Diff for: R/DensityEstimator.R

100644100755
+4-4
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ Gibbs.subclone.density.est <- function(burden, GS.data, pngFile, density.smooth
183183
write.csv(density.data,gsub(".png",paste("_densityData",i,".csv",sep=""),pngFile))
184184
}
185185
if(num.timepoints==2){
186-
d=bkde2D(density.data,bandwidth=density.smooth,gridsize=gridsize,range.x=range)
186+
d=KernSmooth::bkde2D(density.data,bandwidth=density.smooth,gridsize=gridsize,range.x=range)
187187
#if(i==post.burn.in.start){
188188
if(i==1){
189189
xvals=d$x1
@@ -193,7 +193,7 @@ Gibbs.subclone.density.est <- function(burden, GS.data, pngFile, density.smooth
193193
post.ints[,,i]=d$fhat
194194

195195
}else{
196-
d=bkde(density.data,bandwidth=density.smooth,gridsize=512L,range.x=range)
196+
d=KernSmooth::bkde(density.data,bandwidth=density.smooth,gridsize=512L,range.x=range)
197197
#post.ints[,i - post.burn.in.start + 1]=d$y
198198
post.ints[,i]=d$y
199199
}
@@ -336,10 +336,10 @@ Gibbs.subclone.density.est.nd <- function(burden, GS.data, density.smooth = 0.1,
336336
if (i %% 100 == 0) { print(paste(i, "/", length(sampledIters), sep=" ")) }
337337
if(num.timepoints>=4){
338338
#use weights
339-
d=kde(pi.h.cols[sampledIters[i]-1,,],H=diag(num.timepoints)*density.smooth,eval.points = evaluation.points,w=C*wts[sampledIters[i],])
339+
d=ks::kde(pi.h.cols[sampledIters[i]-1,,],H=diag(num.timepoints)*density.smooth,eval.points = evaluation.points,w=C*wts[sampledIters[i],])
340340
}else{
341341
#use weights
342-
d=kde(pi.h.cols[sampledIters[i]-1,,],H=diag(num.timepoints)*density.smooth,gridsize=gridsize,xmin=range[,1],xmax=range[,2],w=C*wts[sampledIters[i],])
342+
d=ks::kde(pi.h.cols[sampledIters[i]-1,,],H=diag(num.timepoints)*density.smooth,gridsize=gridsize,xmin=range[,1],xmax=range[,2],w=C*wts[sampledIters[i],])
343343
}
344344
if(i==1){
345345
eval.points = d$eval.points

Diff for: R/DirichletProcessClustering.R

100644100755
+73-80
Large diffs are not rendered by default.

Diff for: R/InformationCriterions.R

100644100755
File mode changed.

Diff for: R/LoadData.R

100644100755
+22-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ load.data <- function(list_of_data_files, cellularity, Chromosome, position, WT.
5252

5353
#' This inner function takes a list of loaded data tables and transforms them into
5454
#' a dataset, which is a list that contains a table per data type
55-
#' @noRD
55+
#' @noRd
5656
load.data.inner = function(list_of_tables, cellularity, Chromosome, position, WT.count, mut.count, subclonal.CN, no.chrs.bearing.mut, mutation.copy.number, subclonal.fraction, phase, is.male, min.depth, min.mutreads, supported_chroms, mutation_type="SNV") {
5757
no.subsamples = length(list_of_tables)
5858
no.muts = nrow(list_of_tables[[1]])
@@ -173,7 +173,7 @@ load.indel.data = function(infiles) {
173173
}
174174

175175
#' Function that adds copy number as a series of SNVs into a data set
176-
add.in.cn.as.snv.cluster = function(dataset, cndata, add.conflicts=T, conflicting.events.only=F, num.clonal.events.to.add=0, min.cna.size=10) {
176+
add.in.cn.as.snv.cluster = function(dataset, cndata, cellularity, add.conflicts=T, conflicting.events.only=F, num.clonal.events.to.add=0, min.cna.size=10) {
177177
# If clonal events are to be added, make a selection. For now this just takes the largest event
178178
if (num.clonal.events.to.add > 0) {
179179
# Save the largest clonal event to add to the CNAs
@@ -247,7 +247,7 @@ add.in.cn.as.snv.cluster = function(dataset, cndata, add.conflicts=T, conflictin
247247
}
248248

249249
#' Function that adds copy number as a single SNV into a data set
250-
add.in.cn.as.single.snv = function(dataset, cndata, add.conflicts=T) {
250+
add.in.cn.as.single.snv = function(dataset, cndata, cellularity, add.conflicts=T) {
251251

252252
# The subclonal events can be used for clustering
253253
allowed.cn = c("sHD", "sLOH", "sAmp", "sGain", "sLoss")
@@ -470,14 +470,19 @@ get.conflicting.indices = function(dataset, cndata) {
470470

471471
#' Replace the pseudo SNV clusters that represent a CNA event during clustering
472472
#' by amalgamated assignments for each CNA
473+
#' @param dataset A data set object
474+
#' @return a data set in which the pseudo SNVs are removed
473475
remove_pseudo_snv_cna_clusters = function(dataset) {
474476
# Remove the pseudo CNAs
475477
pseudo_snv_index = which(dataset$mutationType=="CNA")
476478
dataset = remove_mutations(dataset, pseudo_snv_index)
477-
479+
return(dataset)
478480
}
479481

480482
#' Helper function to remove a set of mutations from a dataset by their index
483+
#' @param dataset A data set object
484+
#' @param mutation_index Index of mutations to be removed
485+
#' @return a data set in which the pseudo SNVs are removed
481486
remove_mutations = function(dataset, mutation_index) {
482487
dataset$chromosome = dataset$chromosome[-mutation_index,,drop=F]
483488
dataset$position = dataset$position[-mutation_index,,drop=F]
@@ -498,6 +503,10 @@ remove_mutations = function(dataset, mutation_index) {
498503
}
499504

500505
#' Add mutation phasing information to a dataset
506+
#' @param dataset A data set object
507+
#' @param mutphasing data.frame with phasing data
508+
#' @param add.conflicts Supply TRUE when a mutation-to-mutation confict matrix is to be built (Default: FALSE)
509+
#' @return a dataset with field mutphasing and potentially field conflict.array added
501510
add.mutphasing = function(dataset, mutphasing, add.conflicts=F) {
502511
dataset$mutphasing = mutphasing
503512

@@ -535,6 +544,12 @@ add.mutphasing = function(dataset, mutphasing, add.conflicts=F) {
535544
}
536545

537546
#' Add indels to an existing dataset
547+
#' @param dataset A data set object
548+
#' @param indeldata A list of read in data.frames (one per sample) with output from dpclust3p
549+
#' @param min.depth Minimum depth required to keep an indel
550+
#' @param min.mutreads Minimum number of mutant reads to keep an indel
551+
#' @param supported_chroms Chromosomes that are supported
552+
#' @return the provided dataset with indels added
538553
add.in.indels = function(dataset, indeldata, is.male, min.depth, min.mutreads, supported_chroms) {
539554
indelset = load.data.inner(list_of_tables=indeldata,
540555
cellularity=dataset$cellularity,
@@ -560,6 +575,9 @@ add.in.indels = function(dataset, indeldata, is.male, min.depth, min.mutreads, s
560575

561576

562577
#' Convenience function to append two datasets
578+
#' @param a dataset a
579+
#' @param b dataset b
580+
#' @return a dataset in which a and b are appended
563581
append.dataset = function(a, b) {
564582
if (dim(a$mutCount) != dim(b$mutCount) & a$cellularity!=b$cellularity) {
565583
stop("Cannot append two datasets of different sizes or with different cellularities")

0 commit comments

Comments
 (0)