@@ -52,7 +52,7 @@ load.data <- function(list_of_data_files, cellularity, Chromosome, position, WT.
52
52
53
53
# ' This inner function takes a list of loaded data tables and transforms them into
54
54
# ' a dataset, which is a list that contains a table per data type
55
- # ' @noRD
55
+ # ' @noRd
56
56
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" ) {
57
57
no.subsamples = length(list_of_tables )
58
58
no.muts = nrow(list_of_tables [[1 ]])
@@ -173,7 +173,7 @@ load.indel.data = function(infiles) {
173
173
}
174
174
175
175
# ' 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 ) {
177
177
# If clonal events are to be added, make a selection. For now this just takes the largest event
178
178
if (num.clonal.events.to.add > 0 ) {
179
179
# 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
247
247
}
248
248
249
249
# ' 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 ) {
251
251
252
252
# The subclonal events can be used for clustering
253
253
allowed.cn = c(" sHD" , " sLOH" , " sAmp" , " sGain" , " sLoss" )
@@ -470,14 +470,19 @@ get.conflicting.indices = function(dataset, cndata) {
470
470
471
471
# ' Replace the pseudo SNV clusters that represent a CNA event during clustering
472
472
# ' 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
473
475
remove_pseudo_snv_cna_clusters = function (dataset ) {
474
476
# Remove the pseudo CNAs
475
477
pseudo_snv_index = which(dataset $ mutationType == " CNA" )
476
478
dataset = remove_mutations(dataset , pseudo_snv_index )
477
-
479
+ return ( dataset )
478
480
}
479
481
480
482
# ' 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
481
486
remove_mutations = function (dataset , mutation_index ) {
482
487
dataset $ chromosome = dataset $ chromosome [- mutation_index ,,drop = F ]
483
488
dataset $ position = dataset $ position [- mutation_index ,,drop = F ]
@@ -498,6 +503,10 @@ remove_mutations = function(dataset, mutation_index) {
498
503
}
499
504
500
505
# ' 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
501
510
add.mutphasing = function (dataset , mutphasing , add.conflicts = F ) {
502
511
dataset $ mutphasing = mutphasing
503
512
@@ -535,6 +544,12 @@ add.mutphasing = function(dataset, mutphasing, add.conflicts=F) {
535
544
}
536
545
537
546
# ' 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
538
553
add.in.indels = function (dataset , indeldata , is.male , min.depth , min.mutreads , supported_chroms ) {
539
554
indelset = load.data.inner(list_of_tables = indeldata ,
540
555
cellularity = dataset $ cellularity ,
@@ -560,6 +575,9 @@ add.in.indels = function(dataset, indeldata, is.male, min.depth, min.mutreads, s
560
575
561
576
562
577
# ' 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
563
581
append.dataset = function (a , b ) {
564
582
if (dim(a $ mutCount ) != dim(b $ mutCount ) & a $ cellularity != b $ cellularity ) {
565
583
stop(" Cannot append two datasets of different sizes or with different cellularities" )
0 commit comments